babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009
  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 options used to compile the shader.
  19699. * They can be modified to trigger a new compilation
  19700. */
  19701. readonly options: IShaderMaterialOptions;
  19702. /**
  19703. * Gets the current class name of the material e.g. "ShaderMaterial"
  19704. * Mainly use in serialization.
  19705. * @returns the class name
  19706. */
  19707. getClassName(): string;
  19708. /**
  19709. * Specifies if the material will require alpha blending
  19710. * @returns a boolean specifying if alpha blending is needed
  19711. */
  19712. needAlphaBlending(): boolean;
  19713. /**
  19714. * Specifies if this material should be rendered in alpha test mode
  19715. * @returns a boolean specifying if an alpha test is needed.
  19716. */
  19717. needAlphaTesting(): boolean;
  19718. private _checkUniform;
  19719. /**
  19720. * Set a texture in the shader.
  19721. * @param name Define the name of the uniform samplers as defined in the shader
  19722. * @param texture Define the texture to bind to this sampler
  19723. * @return the material itself allowing "fluent" like uniform updates
  19724. */
  19725. setTexture(name: string, texture: Texture): ShaderMaterial;
  19726. /**
  19727. * Set a texture array in the shader.
  19728. * @param name Define the name of the uniform sampler array as defined in the shader
  19729. * @param textures Define the list of textures to bind to this sampler
  19730. * @return the material itself allowing "fluent" like uniform updates
  19731. */
  19732. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19733. /**
  19734. * Set a float in the shader.
  19735. * @param name Define the name of the uniform as defined in the shader
  19736. * @param value Define the value to give to the uniform
  19737. * @return the material itself allowing "fluent" like uniform updates
  19738. */
  19739. setFloat(name: string, value: number): ShaderMaterial;
  19740. /**
  19741. * Set a int in the shader.
  19742. * @param name Define the name of the uniform as defined in the shader
  19743. * @param value Define the value to give to the uniform
  19744. * @return the material itself allowing "fluent" like uniform updates
  19745. */
  19746. setInt(name: string, value: number): ShaderMaterial;
  19747. /**
  19748. * Set an array of floats in the shader.
  19749. * @param name Define the name of the uniform as defined in the shader
  19750. * @param value Define the value to give to the uniform
  19751. * @return the material itself allowing "fluent" like uniform updates
  19752. */
  19753. setFloats(name: string, value: number[]): ShaderMaterial;
  19754. /**
  19755. * Set a vec3 in the shader from a Color3.
  19756. * @param name Define the name of the uniform as defined in the shader
  19757. * @param value Define the value to give to the uniform
  19758. * @return the material itself allowing "fluent" like uniform updates
  19759. */
  19760. setColor3(name: string, value: Color3): ShaderMaterial;
  19761. /**
  19762. * Set a vec3 array in the shader from a Color3 array.
  19763. * @param name Define the name of the uniform as defined in the shader
  19764. * @param value Define the value to give to the uniform
  19765. * @return the material itself allowing "fluent" like uniform updates
  19766. */
  19767. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19768. /**
  19769. * Set a vec4 in the shader from a Color4.
  19770. * @param name Define the name of the uniform as defined in the shader
  19771. * @param value Define the value to give to the uniform
  19772. * @return the material itself allowing "fluent" like uniform updates
  19773. */
  19774. setColor4(name: string, value: Color4): ShaderMaterial;
  19775. /**
  19776. * Set a vec4 array in the shader from a Color4 array.
  19777. * @param name Define the name of the uniform as defined in the shader
  19778. * @param value Define the value to give to the uniform
  19779. * @return the material itself allowing "fluent" like uniform updates
  19780. */
  19781. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19782. /**
  19783. * Set a vec2 in the shader from a Vector2.
  19784. * @param name Define the name of the uniform as defined in the shader
  19785. * @param value Define the value to give to the uniform
  19786. * @return the material itself allowing "fluent" like uniform updates
  19787. */
  19788. setVector2(name: string, value: Vector2): ShaderMaterial;
  19789. /**
  19790. * Set a vec3 in the shader from a Vector3.
  19791. * @param name Define the name of the uniform as defined in the shader
  19792. * @param value Define the value to give to the uniform
  19793. * @return the material itself allowing "fluent" like uniform updates
  19794. */
  19795. setVector3(name: string, value: Vector3): ShaderMaterial;
  19796. /**
  19797. * Set a vec4 in the shader from a Vector4.
  19798. * @param name Define the name of the uniform as defined in the shader
  19799. * @param value Define the value to give to the uniform
  19800. * @return the material itself allowing "fluent" like uniform updates
  19801. */
  19802. setVector4(name: string, value: Vector4): ShaderMaterial;
  19803. /**
  19804. * Set a mat4 in the shader from a Matrix.
  19805. * @param name Define the name of the uniform as defined in the shader
  19806. * @param value Define the value to give to the uniform
  19807. * @return the material itself allowing "fluent" like uniform updates
  19808. */
  19809. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19810. /**
  19811. * Set a float32Array in the shader from a matrix array.
  19812. * @param name Define the name of the uniform as defined in the shader
  19813. * @param value Define the value to give to the uniform
  19814. * @return the material itself allowing "fluent" like uniform updates
  19815. */
  19816. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19817. /**
  19818. * Set a mat3 in the shader from a Float32Array.
  19819. * @param name Define the name of the uniform as defined in the shader
  19820. * @param value Define the value to give to the uniform
  19821. * @return the material itself allowing "fluent" like uniform updates
  19822. */
  19823. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19824. /**
  19825. * Set a mat2 in the shader from a Float32Array.
  19826. * @param name Define the name of the uniform as defined in the shader
  19827. * @param value Define the value to give to the uniform
  19828. * @return the material itself allowing "fluent" like uniform updates
  19829. */
  19830. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19831. /**
  19832. * Set a vec2 array in the shader from a number array.
  19833. * @param name Define the name of the uniform as defined in the shader
  19834. * @param value Define the value to give to the uniform
  19835. * @return the material itself allowing "fluent" like uniform updates
  19836. */
  19837. setArray2(name: string, value: number[]): ShaderMaterial;
  19838. /**
  19839. * Set a vec3 array in the shader from a number array.
  19840. * @param name Define the name of the uniform as defined in the shader
  19841. * @param value Define the value to give to the uniform
  19842. * @return the material itself allowing "fluent" like uniform updates
  19843. */
  19844. setArray3(name: string, value: number[]): ShaderMaterial;
  19845. /**
  19846. * Set a vec4 array in the shader from a number array.
  19847. * @param name Define the name of the uniform as defined in the shader
  19848. * @param value Define the value to give to the uniform
  19849. * @return the material itself allowing "fluent" like uniform updates
  19850. */
  19851. setArray4(name: string, value: number[]): ShaderMaterial;
  19852. private _checkCache;
  19853. /**
  19854. * Specifies that the submesh is ready to be used
  19855. * @param mesh defines the mesh to check
  19856. * @param subMesh defines which submesh to check
  19857. * @param useInstances specifies that instances should be used
  19858. * @returns a boolean indicating that the submesh is ready or not
  19859. */
  19860. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19861. /**
  19862. * Checks if the material is ready to render the requested mesh
  19863. * @param mesh Define the mesh to render
  19864. * @param useInstances Define whether or not the material is used with instances
  19865. * @returns true if ready, otherwise false
  19866. */
  19867. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19868. /**
  19869. * Binds the world matrix to the material
  19870. * @param world defines the world transformation matrix
  19871. */
  19872. bindOnlyWorldMatrix(world: Matrix): void;
  19873. /**
  19874. * Binds the material to the mesh
  19875. * @param world defines the world transformation matrix
  19876. * @param mesh defines the mesh to bind the material to
  19877. */
  19878. bind(world: Matrix, mesh?: Mesh): void;
  19879. /**
  19880. * Gets the active textures from the material
  19881. * @returns an array of textures
  19882. */
  19883. getActiveTextures(): BaseTexture[];
  19884. /**
  19885. * Specifies if the material uses a texture
  19886. * @param texture defines the texture to check against the material
  19887. * @returns a boolean specifying if the material uses the texture
  19888. */
  19889. hasTexture(texture: BaseTexture): boolean;
  19890. /**
  19891. * Makes a duplicate of the material, and gives it a new name
  19892. * @param name defines the new name for the duplicated material
  19893. * @returns the cloned material
  19894. */
  19895. clone(name: string): ShaderMaterial;
  19896. /**
  19897. * Disposes the material
  19898. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19899. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19900. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19901. */
  19902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19903. /**
  19904. * Serializes this material in a JSON representation
  19905. * @returns the serialized material object
  19906. */
  19907. serialize(): any;
  19908. /**
  19909. * Creates a shader material from parsed shader material data
  19910. * @param source defines the JSON represnetation of the material
  19911. * @param scene defines the hosting scene
  19912. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19913. * @returns a new material
  19914. */
  19915. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19916. }
  19917. }
  19918. declare module "babylonjs/Shaders/color.fragment" {
  19919. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19920. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19921. /** @hidden */
  19922. export var colorPixelShader: {
  19923. name: string;
  19924. shader: string;
  19925. };
  19926. }
  19927. declare module "babylonjs/Shaders/color.vertex" {
  19928. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19929. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19930. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19931. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19932. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19933. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19934. /** @hidden */
  19935. export var colorVertexShader: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module "babylonjs/Meshes/linesMesh" {
  19941. import { Nullable } from "babylonjs/types";
  19942. import { Scene } from "babylonjs/scene";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { Node } from "babylonjs/node";
  19945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19946. import { Mesh } from "babylonjs/Meshes/mesh";
  19947. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19948. import { Effect } from "babylonjs/Materials/effect";
  19949. import { Material } from "babylonjs/Materials/material";
  19950. import "babylonjs/Shaders/color.fragment";
  19951. import "babylonjs/Shaders/color.vertex";
  19952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19953. /**
  19954. * Line mesh
  19955. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19956. */
  19957. export class LinesMesh extends Mesh {
  19958. /**
  19959. * If vertex color should be applied to the mesh
  19960. */
  19961. readonly useVertexColor?: boolean | undefined;
  19962. /**
  19963. * If vertex alpha should be applied to the mesh
  19964. */
  19965. readonly useVertexAlpha?: boolean | undefined;
  19966. /**
  19967. * Color of the line (Default: White)
  19968. */
  19969. color: Color3;
  19970. /**
  19971. * Alpha of the line (Default: 1)
  19972. */
  19973. alpha: number;
  19974. /**
  19975. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19976. * This margin is expressed in world space coordinates, so its value may vary.
  19977. * Default value is 0.1
  19978. */
  19979. intersectionThreshold: number;
  19980. private _colorShader;
  19981. private color4;
  19982. /**
  19983. * Creates a new LinesMesh
  19984. * @param name defines the name
  19985. * @param scene defines the hosting scene
  19986. * @param parent defines the parent mesh if any
  19987. * @param source defines the optional source LinesMesh used to clone data from
  19988. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19989. * When false, achieved by calling a clone(), also passing False.
  19990. * This will make creation of children, recursive.
  19991. * @param useVertexColor defines if this LinesMesh supports vertex color
  19992. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19993. */
  19994. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19995. /**
  19996. * If vertex color should be applied to the mesh
  19997. */
  19998. useVertexColor?: boolean | undefined,
  19999. /**
  20000. * If vertex alpha should be applied to the mesh
  20001. */
  20002. useVertexAlpha?: boolean | undefined);
  20003. private _addClipPlaneDefine;
  20004. private _removeClipPlaneDefine;
  20005. isReady(): boolean;
  20006. /**
  20007. * Returns the string "LineMesh"
  20008. */
  20009. getClassName(): string;
  20010. /**
  20011. * @hidden
  20012. */
  20013. /**
  20014. * @hidden
  20015. */
  20016. material: Material;
  20017. /**
  20018. * @hidden
  20019. */
  20020. readonly checkCollisions: boolean;
  20021. /** @hidden */
  20022. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20023. /** @hidden */
  20024. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20025. /**
  20026. * Disposes of the line mesh
  20027. * @param doNotRecurse If children should be disposed
  20028. */
  20029. dispose(doNotRecurse?: boolean): void;
  20030. /**
  20031. * Returns a new LineMesh object cloned from the current one.
  20032. */
  20033. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20034. /**
  20035. * Creates a new InstancedLinesMesh object from the mesh model.
  20036. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20037. * @param name defines the name of the new instance
  20038. * @returns a new InstancedLinesMesh
  20039. */
  20040. createInstance(name: string): InstancedLinesMesh;
  20041. }
  20042. /**
  20043. * Creates an instance based on a source LinesMesh
  20044. */
  20045. export class InstancedLinesMesh extends InstancedMesh {
  20046. /**
  20047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20048. * This margin is expressed in world space coordinates, so its value may vary.
  20049. * Initilized with the intersectionThreshold value of the source LinesMesh
  20050. */
  20051. intersectionThreshold: number;
  20052. constructor(name: string, source: LinesMesh);
  20053. /**
  20054. * Returns the string "InstancedLinesMesh".
  20055. */
  20056. getClassName(): string;
  20057. }
  20058. }
  20059. declare module "babylonjs/Shaders/line.fragment" {
  20060. /** @hidden */
  20061. export var linePixelShader: {
  20062. name: string;
  20063. shader: string;
  20064. };
  20065. }
  20066. declare module "babylonjs/Shaders/line.vertex" {
  20067. /** @hidden */
  20068. export var lineVertexShader: {
  20069. name: string;
  20070. shader: string;
  20071. };
  20072. }
  20073. declare module "babylonjs/Rendering/edgesRenderer" {
  20074. import { Nullable } from "babylonjs/types";
  20075. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20077. import { Vector3 } from "babylonjs/Maths/math.vector";
  20078. import { IDisposable } from "babylonjs/scene";
  20079. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20080. import "babylonjs/Shaders/line.fragment";
  20081. import "babylonjs/Shaders/line.vertex";
  20082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20083. module "babylonjs/Meshes/abstractMesh" {
  20084. interface AbstractMesh {
  20085. /**
  20086. * Gets the edgesRenderer associated with the mesh
  20087. */
  20088. edgesRenderer: Nullable<EdgesRenderer>;
  20089. }
  20090. }
  20091. module "babylonjs/Meshes/linesMesh" {
  20092. interface LinesMesh {
  20093. /**
  20094. * Enables the edge rendering mode on the mesh.
  20095. * This mode makes the mesh edges visible
  20096. * @param epsilon defines the maximal distance between two angles to detect a face
  20097. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20098. * @returns the currentAbstractMesh
  20099. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20100. */
  20101. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20102. }
  20103. }
  20104. module "babylonjs/Meshes/linesMesh" {
  20105. interface InstancedLinesMesh {
  20106. /**
  20107. * Enables the edge rendering mode on the mesh.
  20108. * This mode makes the mesh edges visible
  20109. * @param epsilon defines the maximal distance between two angles to detect a face
  20110. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20111. * @returns the current InstancedLinesMesh
  20112. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20113. */
  20114. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20115. }
  20116. }
  20117. /**
  20118. * Defines the minimum contract an Edges renderer should follow.
  20119. */
  20120. export interface IEdgesRenderer extends IDisposable {
  20121. /**
  20122. * Gets or sets a boolean indicating if the edgesRenderer is active
  20123. */
  20124. isEnabled: boolean;
  20125. /**
  20126. * Renders the edges of the attached mesh,
  20127. */
  20128. render(): void;
  20129. /**
  20130. * Checks wether or not the edges renderer is ready to render.
  20131. * @return true if ready, otherwise false.
  20132. */
  20133. isReady(): boolean;
  20134. }
  20135. /**
  20136. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20137. */
  20138. export class EdgesRenderer implements IEdgesRenderer {
  20139. /**
  20140. * Define the size of the edges with an orthographic camera
  20141. */
  20142. edgesWidthScalerForOrthographic: number;
  20143. /**
  20144. * Define the size of the edges with a perspective camera
  20145. */
  20146. edgesWidthScalerForPerspective: number;
  20147. protected _source: AbstractMesh;
  20148. protected _linesPositions: number[];
  20149. protected _linesNormals: number[];
  20150. protected _linesIndices: number[];
  20151. protected _epsilon: number;
  20152. protected _indicesCount: number;
  20153. protected _lineShader: ShaderMaterial;
  20154. protected _ib: DataBuffer;
  20155. protected _buffers: {
  20156. [key: string]: Nullable<VertexBuffer>;
  20157. };
  20158. protected _checkVerticesInsteadOfIndices: boolean;
  20159. private _meshRebuildObserver;
  20160. private _meshDisposeObserver;
  20161. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20162. isEnabled: boolean;
  20163. /**
  20164. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20165. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20166. * @param source Mesh used to create edges
  20167. * @param epsilon sum of angles in adjacency to check for edge
  20168. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20169. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20170. */
  20171. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20172. protected _prepareRessources(): void;
  20173. /** @hidden */
  20174. _rebuild(): void;
  20175. /**
  20176. * Releases the required resources for the edges renderer
  20177. */
  20178. dispose(): void;
  20179. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20180. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20181. /**
  20182. * Checks if the pair of p0 and p1 is en edge
  20183. * @param faceIndex
  20184. * @param edge
  20185. * @param faceNormals
  20186. * @param p0
  20187. * @param p1
  20188. * @private
  20189. */
  20190. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20191. /**
  20192. * push line into the position, normal and index buffer
  20193. * @protected
  20194. */
  20195. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20196. /**
  20197. * Generates lines edges from adjacencjes
  20198. * @private
  20199. */
  20200. _generateEdgesLines(): void;
  20201. /**
  20202. * Checks wether or not the edges renderer is ready to render.
  20203. * @return true if ready, otherwise false.
  20204. */
  20205. isReady(): boolean;
  20206. /**
  20207. * Renders the edges of the attached mesh,
  20208. */
  20209. render(): void;
  20210. }
  20211. /**
  20212. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20213. */
  20214. export class LineEdgesRenderer extends EdgesRenderer {
  20215. /**
  20216. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20217. * @param source LineMesh used to generate edges
  20218. * @param epsilon not important (specified angle for edge detection)
  20219. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20220. */
  20221. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20222. /**
  20223. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20224. */
  20225. _generateEdgesLines(): void;
  20226. }
  20227. }
  20228. declare module "babylonjs/Rendering/renderingGroup" {
  20229. import { SmartArray } from "babylonjs/Misc/smartArray";
  20230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20232. import { Nullable } from "babylonjs/types";
  20233. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20234. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20235. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20236. import { Material } from "babylonjs/Materials/material";
  20237. import { Scene } from "babylonjs/scene";
  20238. /**
  20239. * This represents the object necessary to create a rendering group.
  20240. * This is exclusively used and created by the rendering manager.
  20241. * To modify the behavior, you use the available helpers in your scene or meshes.
  20242. * @hidden
  20243. */
  20244. export class RenderingGroup {
  20245. index: number;
  20246. private static _zeroVector;
  20247. private _scene;
  20248. private _opaqueSubMeshes;
  20249. private _transparentSubMeshes;
  20250. private _alphaTestSubMeshes;
  20251. private _depthOnlySubMeshes;
  20252. private _particleSystems;
  20253. private _spriteManagers;
  20254. private _opaqueSortCompareFn;
  20255. private _alphaTestSortCompareFn;
  20256. private _transparentSortCompareFn;
  20257. private _renderOpaque;
  20258. private _renderAlphaTest;
  20259. private _renderTransparent;
  20260. /** @hidden */
  20261. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20262. onBeforeTransparentRendering: () => void;
  20263. /**
  20264. * Set the opaque sort comparison function.
  20265. * If null the sub meshes will be render in the order they were created
  20266. */
  20267. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20268. /**
  20269. * Set the alpha test sort comparison function.
  20270. * If null the sub meshes will be render in the order they were created
  20271. */
  20272. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20273. /**
  20274. * Set the transparent sort comparison function.
  20275. * If null the sub meshes will be render in the order they were created
  20276. */
  20277. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20278. /**
  20279. * Creates a new rendering group.
  20280. * @param index The rendering group index
  20281. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20282. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20283. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20284. */
  20285. 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>);
  20286. /**
  20287. * Render all the sub meshes contained in the group.
  20288. * @param customRenderFunction Used to override the default render behaviour of the group.
  20289. * @returns true if rendered some submeshes.
  20290. */
  20291. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20292. /**
  20293. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20294. * @param subMeshes The submeshes to render
  20295. */
  20296. private renderOpaqueSorted;
  20297. /**
  20298. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20299. * @param subMeshes The submeshes to render
  20300. */
  20301. private renderAlphaTestSorted;
  20302. /**
  20303. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20304. * @param subMeshes The submeshes to render
  20305. */
  20306. private renderTransparentSorted;
  20307. /**
  20308. * Renders the submeshes in a specified order.
  20309. * @param subMeshes The submeshes to sort before render
  20310. * @param sortCompareFn The comparison function use to sort
  20311. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20312. * @param transparent Specifies to activate blending if true
  20313. */
  20314. private static renderSorted;
  20315. /**
  20316. * Renders the submeshes in the order they were dispatched (no sort applied).
  20317. * @param subMeshes The submeshes to render
  20318. */
  20319. private static renderUnsorted;
  20320. /**
  20321. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20322. * are rendered back to front if in the same alpha index.
  20323. *
  20324. * @param a The first submesh
  20325. * @param b The second submesh
  20326. * @returns The result of the comparison
  20327. */
  20328. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  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.
  20332. *
  20333. * @param a The first submesh
  20334. * @param b The second submesh
  20335. * @returns The result of the comparison
  20336. */
  20337. static backToFrontSortCompare(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 front to back (prevent overdraw).
  20341. *
  20342. * @param a The first submesh
  20343. * @param b The second submesh
  20344. * @returns The result of the comparison
  20345. */
  20346. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20347. /**
  20348. * Resets the different lists of submeshes to prepare a new frame.
  20349. */
  20350. prepare(): void;
  20351. dispose(): void;
  20352. /**
  20353. * Inserts the submesh in its correct queue depending on its material.
  20354. * @param subMesh The submesh to dispatch
  20355. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20356. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20357. */
  20358. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20359. dispatchSprites(spriteManager: ISpriteManager): void;
  20360. dispatchParticles(particleSystem: IParticleSystem): void;
  20361. private _renderParticles;
  20362. private _renderSprites;
  20363. }
  20364. }
  20365. declare module "babylonjs/Rendering/renderingManager" {
  20366. import { Nullable } from "babylonjs/types";
  20367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20369. import { SmartArray } from "babylonjs/Misc/smartArray";
  20370. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20372. import { Material } from "babylonjs/Materials/material";
  20373. import { Scene } from "babylonjs/scene";
  20374. import { Camera } from "babylonjs/Cameras/camera";
  20375. /**
  20376. * Interface describing the different options available in the rendering manager
  20377. * regarding Auto Clear between groups.
  20378. */
  20379. export interface IRenderingManagerAutoClearSetup {
  20380. /**
  20381. * Defines whether or not autoclear is enable.
  20382. */
  20383. autoClear: boolean;
  20384. /**
  20385. * Defines whether or not to autoclear the depth buffer.
  20386. */
  20387. depth: boolean;
  20388. /**
  20389. * Defines whether or not to autoclear the stencil buffer.
  20390. */
  20391. stencil: boolean;
  20392. }
  20393. /**
  20394. * This class is used by the onRenderingGroupObservable
  20395. */
  20396. export class RenderingGroupInfo {
  20397. /**
  20398. * The Scene that being rendered
  20399. */
  20400. scene: Scene;
  20401. /**
  20402. * The camera currently used for the rendering pass
  20403. */
  20404. camera: Nullable<Camera>;
  20405. /**
  20406. * The ID of the renderingGroup being processed
  20407. */
  20408. renderingGroupId: number;
  20409. }
  20410. /**
  20411. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20412. * It is enable to manage the different groups as well as the different necessary sort functions.
  20413. * This should not be used directly aside of the few static configurations
  20414. */
  20415. export class RenderingManager {
  20416. /**
  20417. * The max id used for rendering groups (not included)
  20418. */
  20419. static MAX_RENDERINGGROUPS: number;
  20420. /**
  20421. * The min id used for rendering groups (included)
  20422. */
  20423. static MIN_RENDERINGGROUPS: number;
  20424. /**
  20425. * Used to globally prevent autoclearing scenes.
  20426. */
  20427. static AUTOCLEAR: boolean;
  20428. /**
  20429. * @hidden
  20430. */
  20431. _useSceneAutoClearSetup: boolean;
  20432. private _scene;
  20433. private _renderingGroups;
  20434. private _depthStencilBufferAlreadyCleaned;
  20435. private _autoClearDepthStencil;
  20436. private _customOpaqueSortCompareFn;
  20437. private _customAlphaTestSortCompareFn;
  20438. private _customTransparentSortCompareFn;
  20439. private _renderingGroupInfo;
  20440. /**
  20441. * Instantiates a new rendering group for a particular scene
  20442. * @param scene Defines the scene the groups belongs to
  20443. */
  20444. constructor(scene: Scene);
  20445. private _clearDepthStencilBuffer;
  20446. /**
  20447. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20448. * @hidden
  20449. */
  20450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20451. /**
  20452. * Resets the different information of the group to prepare a new frame
  20453. * @hidden
  20454. */
  20455. reset(): void;
  20456. /**
  20457. * Dispose and release the group and its associated resources.
  20458. * @hidden
  20459. */
  20460. dispose(): void;
  20461. /**
  20462. * Clear the info related to rendering groups preventing retention points during dispose.
  20463. */
  20464. freeRenderingGroups(): void;
  20465. private _prepareRenderingGroup;
  20466. /**
  20467. * Add a sprite manager to the rendering manager in order to render it this frame.
  20468. * @param spriteManager Define the sprite manager to render
  20469. */
  20470. dispatchSprites(spriteManager: ISpriteManager): void;
  20471. /**
  20472. * Add a particle system to the rendering manager in order to render it this frame.
  20473. * @param particleSystem Define the particle system to render
  20474. */
  20475. dispatchParticles(particleSystem: IParticleSystem): void;
  20476. /**
  20477. * Add a submesh to the manager in order to render it this frame
  20478. * @param subMesh The submesh to dispatch
  20479. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20480. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20481. */
  20482. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20483. /**
  20484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20485. * This allowed control for front to back rendering or reversly depending of the special needs.
  20486. *
  20487. * @param renderingGroupId The rendering group id corresponding to its index
  20488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20491. */
  20492. 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;
  20493. /**
  20494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20495. *
  20496. * @param renderingGroupId The rendering group id corresponding to its index
  20497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20500. */
  20501. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20502. /**
  20503. * Gets the current auto clear configuration for one rendering group of the rendering
  20504. * manager.
  20505. * @param index the rendering group index to get the information for
  20506. * @returns The auto clear setup for the requested rendering group
  20507. */
  20508. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20509. }
  20510. }
  20511. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20512. import { Observable } from "babylonjs/Misc/observable";
  20513. import { SmartArray } from "babylonjs/Misc/smartArray";
  20514. import { Nullable } from "babylonjs/types";
  20515. import { Camera } from "babylonjs/Cameras/camera";
  20516. import { Scene } from "babylonjs/scene";
  20517. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20518. import { Color4 } from "babylonjs/Maths/math.color";
  20519. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20523. import { Texture } from "babylonjs/Materials/Textures/texture";
  20524. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20525. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20526. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20527. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20528. import { Engine } from "babylonjs/Engines/engine";
  20529. /**
  20530. * This Helps creating a texture that will be created from a camera in your scene.
  20531. * It is basically a dynamic texture that could be used to create special effects for instance.
  20532. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20533. */
  20534. export class RenderTargetTexture extends Texture {
  20535. isCube: boolean;
  20536. /**
  20537. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20538. */
  20539. static readonly REFRESHRATE_RENDER_ONCE: number;
  20540. /**
  20541. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20542. */
  20543. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20544. /**
  20545. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20546. * the central point of your effect and can save a lot of performances.
  20547. */
  20548. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20549. /**
  20550. * Use this predicate to dynamically define the list of mesh you want to render.
  20551. * If set, the renderList property will be overwritten.
  20552. */
  20553. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20554. private _renderList;
  20555. /**
  20556. * Use this list to define the list of mesh you want to render.
  20557. */
  20558. renderList: Nullable<Array<AbstractMesh>>;
  20559. private _hookArray;
  20560. /**
  20561. * Define if particles should be rendered in your texture.
  20562. */
  20563. renderParticles: boolean;
  20564. /**
  20565. * Define if sprites should be rendered in your texture.
  20566. */
  20567. renderSprites: boolean;
  20568. /**
  20569. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20570. */
  20571. coordinatesMode: number;
  20572. /**
  20573. * Define the camera used to render the texture.
  20574. */
  20575. activeCamera: Nullable<Camera>;
  20576. /**
  20577. * Override the render function of the texture with your own one.
  20578. */
  20579. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20580. /**
  20581. * Define if camera post processes should be use while rendering the texture.
  20582. */
  20583. useCameraPostProcesses: boolean;
  20584. /**
  20585. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20586. */
  20587. ignoreCameraViewport: boolean;
  20588. private _postProcessManager;
  20589. private _postProcesses;
  20590. private _resizeObserver;
  20591. /**
  20592. * An event triggered when the texture is unbind.
  20593. */
  20594. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20595. /**
  20596. * An event triggered when the texture is unbind.
  20597. */
  20598. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20599. private _onAfterUnbindObserver;
  20600. /**
  20601. * Set a after unbind callback in the texture.
  20602. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20603. */
  20604. onAfterUnbind: () => void;
  20605. /**
  20606. * An event triggered before rendering the texture
  20607. */
  20608. onBeforeRenderObservable: Observable<number>;
  20609. private _onBeforeRenderObserver;
  20610. /**
  20611. * Set a before render callback in the texture.
  20612. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20613. */
  20614. onBeforeRender: (faceIndex: number) => void;
  20615. /**
  20616. * An event triggered after rendering the texture
  20617. */
  20618. onAfterRenderObservable: Observable<number>;
  20619. private _onAfterRenderObserver;
  20620. /**
  20621. * Set a after render callback in the texture.
  20622. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20623. */
  20624. onAfterRender: (faceIndex: number) => void;
  20625. /**
  20626. * An event triggered after the texture clear
  20627. */
  20628. onClearObservable: Observable<Engine>;
  20629. private _onClearObserver;
  20630. /**
  20631. * Set a clear callback in the texture.
  20632. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20633. */
  20634. onClear: (Engine: Engine) => void;
  20635. /**
  20636. * An event triggered when the texture is resized.
  20637. */
  20638. onResizeObservable: Observable<RenderTargetTexture>;
  20639. /**
  20640. * Define the clear color of the Render Target if it should be different from the scene.
  20641. */
  20642. clearColor: Color4;
  20643. protected _size: number | {
  20644. width: number;
  20645. height: number;
  20646. };
  20647. protected _initialSizeParameter: number | {
  20648. width: number;
  20649. height: number;
  20650. } | {
  20651. ratio: number;
  20652. };
  20653. protected _sizeRatio: Nullable<number>;
  20654. /** @hidden */
  20655. _generateMipMaps: boolean;
  20656. protected _renderingManager: RenderingManager;
  20657. /** @hidden */
  20658. _waitingRenderList: string[];
  20659. protected _doNotChangeAspectRatio: boolean;
  20660. protected _currentRefreshId: number;
  20661. protected _refreshRate: number;
  20662. protected _textureMatrix: Matrix;
  20663. protected _samples: number;
  20664. protected _renderTargetOptions: RenderTargetCreationOptions;
  20665. /**
  20666. * Gets render target creation options that were used.
  20667. */
  20668. readonly renderTargetOptions: RenderTargetCreationOptions;
  20669. protected _engine: Engine;
  20670. protected _onRatioRescale(): void;
  20671. /**
  20672. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20673. * It must define where the camera used to render the texture is set
  20674. */
  20675. boundingBoxPosition: Vector3;
  20676. private _boundingBoxSize;
  20677. /**
  20678. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20679. * When defined, the cubemap will switch to local mode
  20680. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20681. * @example https://www.babylonjs-playground.com/#RNASML
  20682. */
  20683. boundingBoxSize: Vector3;
  20684. /**
  20685. * In case the RTT has been created with a depth texture, get the associated
  20686. * depth texture.
  20687. * Otherwise, return null.
  20688. */
  20689. depthStencilTexture: Nullable<InternalTexture>;
  20690. /**
  20691. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20692. * or used a shadow, depth texture...
  20693. * @param name The friendly name of the texture
  20694. * @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)
  20695. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20696. * @param generateMipMaps True if mip maps need to be generated after render.
  20697. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20698. * @param type The type of the buffer in the RTT (int, half float, float...)
  20699. * @param isCube True if a cube texture needs to be created
  20700. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20701. * @param generateDepthBuffer True to generate a depth buffer
  20702. * @param generateStencilBuffer True to generate a stencil buffer
  20703. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20704. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20705. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20706. */
  20707. constructor(name: string, size: number | {
  20708. width: number;
  20709. height: number;
  20710. } | {
  20711. ratio: number;
  20712. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20713. /**
  20714. * Creates a depth stencil texture.
  20715. * This is only available in WebGL 2 or with the depth texture extension available.
  20716. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20717. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20718. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20719. */
  20720. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20721. private _processSizeParameter;
  20722. /**
  20723. * Define the number of samples to use in case of MSAA.
  20724. * It defaults to one meaning no MSAA has been enabled.
  20725. */
  20726. samples: number;
  20727. /**
  20728. * Resets the refresh counter of the texture and start bak from scratch.
  20729. * Could be useful to regenerate the texture if it is setup to render only once.
  20730. */
  20731. resetRefreshCounter(): void;
  20732. /**
  20733. * Define the refresh rate of the texture or the rendering frequency.
  20734. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20735. */
  20736. refreshRate: number;
  20737. /**
  20738. * Adds a post process to the render target rendering passes.
  20739. * @param postProcess define the post process to add
  20740. */
  20741. addPostProcess(postProcess: PostProcess): void;
  20742. /**
  20743. * Clear all the post processes attached to the render target
  20744. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20745. */
  20746. clearPostProcesses(dispose?: boolean): void;
  20747. /**
  20748. * Remove one of the post process from the list of attached post processes to the texture
  20749. * @param postProcess define the post process to remove from the list
  20750. */
  20751. removePostProcess(postProcess: PostProcess): void;
  20752. /** @hidden */
  20753. _shouldRender(): boolean;
  20754. /**
  20755. * Gets the actual render size of the texture.
  20756. * @returns the width of the render size
  20757. */
  20758. getRenderSize(): number;
  20759. /**
  20760. * Gets the actual render width of the texture.
  20761. * @returns the width of the render size
  20762. */
  20763. getRenderWidth(): number;
  20764. /**
  20765. * Gets the actual render height of the texture.
  20766. * @returns the height of the render size
  20767. */
  20768. getRenderHeight(): number;
  20769. /**
  20770. * Get if the texture can be rescaled or not.
  20771. */
  20772. readonly canRescale: boolean;
  20773. /**
  20774. * Resize the texture using a ratio.
  20775. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20776. */
  20777. scale(ratio: number): void;
  20778. /**
  20779. * Get the texture reflection matrix used to rotate/transform the reflection.
  20780. * @returns the reflection matrix
  20781. */
  20782. getReflectionTextureMatrix(): Matrix;
  20783. /**
  20784. * Resize the texture to a new desired size.
  20785. * Be carrefull as it will recreate all the data in the new texture.
  20786. * @param size Define the new size. It can be:
  20787. * - a number for squared texture,
  20788. * - an object containing { width: number, height: number }
  20789. * - or an object containing a ratio { ratio: number }
  20790. */
  20791. resize(size: number | {
  20792. width: number;
  20793. height: number;
  20794. } | {
  20795. ratio: number;
  20796. }): void;
  20797. /**
  20798. * Renders all the objects from the render list into the texture.
  20799. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20800. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20801. */
  20802. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20803. private _bestReflectionRenderTargetDimension;
  20804. /**
  20805. * @hidden
  20806. * @param faceIndex face index to bind to if this is a cubetexture
  20807. */
  20808. _bindFrameBuffer(faceIndex?: number): void;
  20809. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20810. private renderToTarget;
  20811. /**
  20812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20813. * This allowed control for front to back rendering or reversly depending of the special needs.
  20814. *
  20815. * @param renderingGroupId The rendering group id corresponding to its index
  20816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20819. */
  20820. 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;
  20821. /**
  20822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20823. *
  20824. * @param renderingGroupId The rendering group id corresponding to its index
  20825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20826. */
  20827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20828. /**
  20829. * Clones the texture.
  20830. * @returns the cloned texture
  20831. */
  20832. clone(): RenderTargetTexture;
  20833. /**
  20834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20835. * @returns The JSON representation of the texture
  20836. */
  20837. serialize(): any;
  20838. /**
  20839. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20840. */
  20841. disposeFramebufferObjects(): void;
  20842. /**
  20843. * Dispose the texture and release its associated resources.
  20844. */
  20845. dispose(): void;
  20846. /** @hidden */
  20847. _rebuild(): void;
  20848. /**
  20849. * Clear the info related to rendering groups preventing retention point in material dispose.
  20850. */
  20851. freeRenderingGroups(): void;
  20852. /**
  20853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20854. * @returns the view count
  20855. */
  20856. getViewCount(): number;
  20857. }
  20858. }
  20859. declare module "babylonjs/Materials/material" {
  20860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20861. import { SmartArray } from "babylonjs/Misc/smartArray";
  20862. import { Observable } from "babylonjs/Misc/observable";
  20863. import { Nullable } from "babylonjs/types";
  20864. import { Scene } from "babylonjs/scene";
  20865. import { Matrix } from "babylonjs/Maths/math.vector";
  20866. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20869. import { Effect } from "babylonjs/Materials/effect";
  20870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20872. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20873. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20874. import { Mesh } from "babylonjs/Meshes/mesh";
  20875. import { Animation } from "babylonjs/Animations/animation";
  20876. /**
  20877. * Options for compiling materials.
  20878. */
  20879. export interface IMaterialCompilationOptions {
  20880. /**
  20881. * Defines whether clip planes are enabled.
  20882. */
  20883. clipPlane: boolean;
  20884. /**
  20885. * Defines whether instances are enabled.
  20886. */
  20887. useInstances: boolean;
  20888. }
  20889. /**
  20890. * Base class for the main features of a material in Babylon.js
  20891. */
  20892. export class Material implements IAnimatable {
  20893. /**
  20894. * Returns the triangle fill mode
  20895. */
  20896. static readonly TriangleFillMode: number;
  20897. /**
  20898. * Returns the wireframe mode
  20899. */
  20900. static readonly WireFrameFillMode: number;
  20901. /**
  20902. * Returns the point fill mode
  20903. */
  20904. static readonly PointFillMode: number;
  20905. /**
  20906. * Returns the point list draw mode
  20907. */
  20908. static readonly PointListDrawMode: number;
  20909. /**
  20910. * Returns the line list draw mode
  20911. */
  20912. static readonly LineListDrawMode: number;
  20913. /**
  20914. * Returns the line loop draw mode
  20915. */
  20916. static readonly LineLoopDrawMode: number;
  20917. /**
  20918. * Returns the line strip draw mode
  20919. */
  20920. static readonly LineStripDrawMode: number;
  20921. /**
  20922. * Returns the triangle strip draw mode
  20923. */
  20924. static readonly TriangleStripDrawMode: number;
  20925. /**
  20926. * Returns the triangle fan draw mode
  20927. */
  20928. static readonly TriangleFanDrawMode: number;
  20929. /**
  20930. * Stores the clock-wise side orientation
  20931. */
  20932. static readonly ClockWiseSideOrientation: number;
  20933. /**
  20934. * Stores the counter clock-wise side orientation
  20935. */
  20936. static readonly CounterClockWiseSideOrientation: number;
  20937. /**
  20938. * The dirty texture flag value
  20939. */
  20940. static readonly TextureDirtyFlag: number;
  20941. /**
  20942. * The dirty light flag value
  20943. */
  20944. static readonly LightDirtyFlag: number;
  20945. /**
  20946. * The dirty fresnel flag value
  20947. */
  20948. static readonly FresnelDirtyFlag: number;
  20949. /**
  20950. * The dirty attribute flag value
  20951. */
  20952. static readonly AttributesDirtyFlag: number;
  20953. /**
  20954. * The dirty misc flag value
  20955. */
  20956. static readonly MiscDirtyFlag: number;
  20957. /**
  20958. * The all dirty flag value
  20959. */
  20960. static readonly AllDirtyFlag: number;
  20961. /**
  20962. * The ID of the material
  20963. */
  20964. id: string;
  20965. /**
  20966. * Gets or sets the unique id of the material
  20967. */
  20968. uniqueId: number;
  20969. /**
  20970. * The name of the material
  20971. */
  20972. name: string;
  20973. /**
  20974. * Gets or sets user defined metadata
  20975. */
  20976. metadata: any;
  20977. /**
  20978. * For internal use only. Please do not use.
  20979. */
  20980. reservedDataStore: any;
  20981. /**
  20982. * Specifies if the ready state should be checked on each call
  20983. */
  20984. checkReadyOnEveryCall: boolean;
  20985. /**
  20986. * Specifies if the ready state should be checked once
  20987. */
  20988. checkReadyOnlyOnce: boolean;
  20989. /**
  20990. * The state of the material
  20991. */
  20992. state: string;
  20993. /**
  20994. * The alpha value of the material
  20995. */
  20996. protected _alpha: number;
  20997. /**
  20998. * List of inspectable custom properties (used by the Inspector)
  20999. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21000. */
  21001. inspectableCustomProperties: IInspectable[];
  21002. /**
  21003. * Sets the alpha value of the material
  21004. */
  21005. /**
  21006. * Gets the alpha value of the material
  21007. */
  21008. alpha: number;
  21009. /**
  21010. * Specifies if back face culling is enabled
  21011. */
  21012. protected _backFaceCulling: boolean;
  21013. /**
  21014. * Sets the back-face culling state
  21015. */
  21016. /**
  21017. * Gets the back-face culling state
  21018. */
  21019. backFaceCulling: boolean;
  21020. /**
  21021. * Stores the value for side orientation
  21022. */
  21023. sideOrientation: number;
  21024. /**
  21025. * Callback triggered when the material is compiled
  21026. */
  21027. onCompiled: Nullable<(effect: Effect) => void>;
  21028. /**
  21029. * Callback triggered when an error occurs
  21030. */
  21031. onError: Nullable<(effect: Effect, errors: string) => void>;
  21032. /**
  21033. * Callback triggered to get the render target textures
  21034. */
  21035. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21036. /**
  21037. * Gets a boolean indicating that current material needs to register RTT
  21038. */
  21039. readonly hasRenderTargetTextures: boolean;
  21040. /**
  21041. * Specifies if the material should be serialized
  21042. */
  21043. doNotSerialize: boolean;
  21044. /**
  21045. * @hidden
  21046. */
  21047. _storeEffectOnSubMeshes: boolean;
  21048. /**
  21049. * Stores the animations for the material
  21050. */
  21051. animations: Nullable<Array<Animation>>;
  21052. /**
  21053. * An event triggered when the material is disposed
  21054. */
  21055. onDisposeObservable: Observable<Material>;
  21056. /**
  21057. * An observer which watches for dispose events
  21058. */
  21059. private _onDisposeObserver;
  21060. private _onUnBindObservable;
  21061. /**
  21062. * Called during a dispose event
  21063. */
  21064. onDispose: () => void;
  21065. private _onBindObservable;
  21066. /**
  21067. * An event triggered when the material is bound
  21068. */
  21069. readonly onBindObservable: Observable<AbstractMesh>;
  21070. /**
  21071. * An observer which watches for bind events
  21072. */
  21073. private _onBindObserver;
  21074. /**
  21075. * Called during a bind event
  21076. */
  21077. onBind: (Mesh: AbstractMesh) => void;
  21078. /**
  21079. * An event triggered when the material is unbound
  21080. */
  21081. readonly onUnBindObservable: Observable<Material>;
  21082. /**
  21083. * Stores the value of the alpha mode
  21084. */
  21085. private _alphaMode;
  21086. /**
  21087. * Sets the value of the alpha mode.
  21088. *
  21089. * | Value | Type | Description |
  21090. * | --- | --- | --- |
  21091. * | 0 | ALPHA_DISABLE | |
  21092. * | 1 | ALPHA_ADD | |
  21093. * | 2 | ALPHA_COMBINE | |
  21094. * | 3 | ALPHA_SUBTRACT | |
  21095. * | 4 | ALPHA_MULTIPLY | |
  21096. * | 5 | ALPHA_MAXIMIZED | |
  21097. * | 6 | ALPHA_ONEONE | |
  21098. * | 7 | ALPHA_PREMULTIPLIED | |
  21099. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21100. * | 9 | ALPHA_INTERPOLATE | |
  21101. * | 10 | ALPHA_SCREENMODE | |
  21102. *
  21103. */
  21104. /**
  21105. * Gets the value of the alpha mode
  21106. */
  21107. alphaMode: number;
  21108. /**
  21109. * Stores the state of the need depth pre-pass value
  21110. */
  21111. private _needDepthPrePass;
  21112. /**
  21113. * Sets the need depth pre-pass value
  21114. */
  21115. /**
  21116. * Gets the depth pre-pass value
  21117. */
  21118. needDepthPrePass: boolean;
  21119. /**
  21120. * Specifies if depth writing should be disabled
  21121. */
  21122. disableDepthWrite: boolean;
  21123. /**
  21124. * Specifies if depth writing should be forced
  21125. */
  21126. forceDepthWrite: boolean;
  21127. /**
  21128. * Specifies if there should be a separate pass for culling
  21129. */
  21130. separateCullingPass: boolean;
  21131. /**
  21132. * Stores the state specifing if fog should be enabled
  21133. */
  21134. private _fogEnabled;
  21135. /**
  21136. * Sets the state for enabling fog
  21137. */
  21138. /**
  21139. * Gets the value of the fog enabled state
  21140. */
  21141. fogEnabled: boolean;
  21142. /**
  21143. * Stores the size of points
  21144. */
  21145. pointSize: number;
  21146. /**
  21147. * Stores the z offset value
  21148. */
  21149. zOffset: number;
  21150. /**
  21151. * Gets a value specifying if wireframe mode is enabled
  21152. */
  21153. /**
  21154. * Sets the state of wireframe mode
  21155. */
  21156. wireframe: boolean;
  21157. /**
  21158. * Gets the value specifying if point clouds are enabled
  21159. */
  21160. /**
  21161. * Sets the state of point cloud mode
  21162. */
  21163. pointsCloud: boolean;
  21164. /**
  21165. * Gets the material fill mode
  21166. */
  21167. /**
  21168. * Sets the material fill mode
  21169. */
  21170. fillMode: number;
  21171. /**
  21172. * @hidden
  21173. * Stores the effects for the material
  21174. */
  21175. _effect: Nullable<Effect>;
  21176. /**
  21177. * @hidden
  21178. * Specifies if the material was previously ready
  21179. */
  21180. _wasPreviouslyReady: boolean;
  21181. /**
  21182. * Specifies if uniform buffers should be used
  21183. */
  21184. private _useUBO;
  21185. /**
  21186. * Stores a reference to the scene
  21187. */
  21188. private _scene;
  21189. /**
  21190. * Stores the fill mode state
  21191. */
  21192. private _fillMode;
  21193. /**
  21194. * Specifies if the depth write state should be cached
  21195. */
  21196. private _cachedDepthWriteState;
  21197. /**
  21198. * Stores the uniform buffer
  21199. */
  21200. protected _uniformBuffer: UniformBuffer;
  21201. /** @hidden */
  21202. _indexInSceneMaterialArray: number;
  21203. /** @hidden */
  21204. meshMap: Nullable<{
  21205. [id: string]: AbstractMesh | undefined;
  21206. }>;
  21207. /**
  21208. * Creates a material instance
  21209. * @param name defines the name of the material
  21210. * @param scene defines the scene to reference
  21211. * @param doNotAdd specifies if the material should be added to the scene
  21212. */
  21213. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21214. /**
  21215. * Returns a string representation of the current material
  21216. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21217. * @returns a string with material information
  21218. */
  21219. toString(fullDetails?: boolean): string;
  21220. /**
  21221. * Gets the class name of the material
  21222. * @returns a string with the class name of the material
  21223. */
  21224. getClassName(): string;
  21225. /**
  21226. * Specifies if updates for the material been locked
  21227. */
  21228. readonly isFrozen: boolean;
  21229. /**
  21230. * Locks updates for the material
  21231. */
  21232. freeze(): void;
  21233. /**
  21234. * Unlocks updates for the material
  21235. */
  21236. unfreeze(): void;
  21237. /**
  21238. * Specifies if the material is ready to be used
  21239. * @param mesh defines the mesh to check
  21240. * @param useInstances specifies if instances should be used
  21241. * @returns a boolean indicating if the material is ready to be used
  21242. */
  21243. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21244. /**
  21245. * Specifies that the submesh is ready to be used
  21246. * @param mesh defines the mesh to check
  21247. * @param subMesh defines which submesh to check
  21248. * @param useInstances specifies that instances should be used
  21249. * @returns a boolean indicating that the submesh is ready or not
  21250. */
  21251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21252. /**
  21253. * Returns the material effect
  21254. * @returns the effect associated with the material
  21255. */
  21256. getEffect(): Nullable<Effect>;
  21257. /**
  21258. * Returns the current scene
  21259. * @returns a Scene
  21260. */
  21261. getScene(): Scene;
  21262. /**
  21263. * Specifies if the material will require alpha blending
  21264. * @returns a boolean specifying if alpha blending is needed
  21265. */
  21266. needAlphaBlending(): boolean;
  21267. /**
  21268. * Specifies if the mesh will require alpha blending
  21269. * @param mesh defines the mesh to check
  21270. * @returns a boolean specifying if alpha blending is needed for the mesh
  21271. */
  21272. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21273. /**
  21274. * Specifies if this material should be rendered in alpha test mode
  21275. * @returns a boolean specifying if an alpha test is needed.
  21276. */
  21277. needAlphaTesting(): boolean;
  21278. /**
  21279. * Gets the texture used for the alpha test
  21280. * @returns the texture to use for alpha testing
  21281. */
  21282. getAlphaTestTexture(): Nullable<BaseTexture>;
  21283. /**
  21284. * Marks the material to indicate that it needs to be re-calculated
  21285. */
  21286. markDirty(): void;
  21287. /** @hidden */
  21288. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21289. /**
  21290. * Binds the material to the mesh
  21291. * @param world defines the world transformation matrix
  21292. * @param mesh defines the mesh to bind the material to
  21293. */
  21294. bind(world: Matrix, mesh?: Mesh): void;
  21295. /**
  21296. * Binds the submesh to the material
  21297. * @param world defines the world transformation matrix
  21298. * @param mesh defines the mesh containing the submesh
  21299. * @param subMesh defines the submesh to bind the material to
  21300. */
  21301. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21302. /**
  21303. * Binds the world matrix to the material
  21304. * @param world defines the world transformation matrix
  21305. */
  21306. bindOnlyWorldMatrix(world: Matrix): void;
  21307. /**
  21308. * Binds the scene's uniform buffer to the effect.
  21309. * @param effect defines the effect to bind to the scene uniform buffer
  21310. * @param sceneUbo defines the uniform buffer storing scene data
  21311. */
  21312. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21313. /**
  21314. * Binds the view matrix to the effect
  21315. * @param effect defines the effect to bind the view matrix to
  21316. */
  21317. bindView(effect: Effect): void;
  21318. /**
  21319. * Binds the view projection matrix to the effect
  21320. * @param effect defines the effect to bind the view projection matrix to
  21321. */
  21322. bindViewProjection(effect: Effect): void;
  21323. /**
  21324. * Specifies if material alpha testing should be turned on for the mesh
  21325. * @param mesh defines the mesh to check
  21326. */
  21327. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21328. /**
  21329. * Processes to execute after binding the material to a mesh
  21330. * @param mesh defines the rendered mesh
  21331. */
  21332. protected _afterBind(mesh?: Mesh): void;
  21333. /**
  21334. * Unbinds the material from the mesh
  21335. */
  21336. unbind(): void;
  21337. /**
  21338. * Gets the active textures from the material
  21339. * @returns an array of textures
  21340. */
  21341. getActiveTextures(): BaseTexture[];
  21342. /**
  21343. * Specifies if the material uses a texture
  21344. * @param texture defines the texture to check against the material
  21345. * @returns a boolean specifying if the material uses the texture
  21346. */
  21347. hasTexture(texture: BaseTexture): boolean;
  21348. /**
  21349. * Makes a duplicate of the material, and gives it a new name
  21350. * @param name defines the new name for the duplicated material
  21351. * @returns the cloned material
  21352. */
  21353. clone(name: string): Nullable<Material>;
  21354. /**
  21355. * Gets the meshes bound to the material
  21356. * @returns an array of meshes bound to the material
  21357. */
  21358. getBindedMeshes(): AbstractMesh[];
  21359. /**
  21360. * Force shader compilation
  21361. * @param mesh defines the mesh associated with this material
  21362. * @param onCompiled defines a function to execute once the material is compiled
  21363. * @param options defines the options to configure the compilation
  21364. * @param onError defines a function to execute if the material fails compiling
  21365. */
  21366. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21367. /**
  21368. * Force shader compilation
  21369. * @param mesh defines the mesh that will use this material
  21370. * @param options defines additional options for compiling the shaders
  21371. * @returns a promise that resolves when the compilation completes
  21372. */
  21373. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21374. private static readonly _AllDirtyCallBack;
  21375. private static readonly _ImageProcessingDirtyCallBack;
  21376. private static readonly _TextureDirtyCallBack;
  21377. private static readonly _FresnelDirtyCallBack;
  21378. private static readonly _MiscDirtyCallBack;
  21379. private static readonly _LightsDirtyCallBack;
  21380. private static readonly _AttributeDirtyCallBack;
  21381. private static _FresnelAndMiscDirtyCallBack;
  21382. private static _TextureAndMiscDirtyCallBack;
  21383. private static readonly _DirtyCallbackArray;
  21384. private static readonly _RunDirtyCallBacks;
  21385. /**
  21386. * Marks a define in the material to indicate that it needs to be re-computed
  21387. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21388. */
  21389. markAsDirty(flag: number): void;
  21390. /**
  21391. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21392. * @param func defines a function which checks material defines against the submeshes
  21393. */
  21394. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21395. /**
  21396. * Indicates that we need to re-calculated for all submeshes
  21397. */
  21398. protected _markAllSubMeshesAsAllDirty(): void;
  21399. /**
  21400. * Indicates that image processing needs to be re-calculated for all submeshes
  21401. */
  21402. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21403. /**
  21404. * Indicates that textures need to be re-calculated for all submeshes
  21405. */
  21406. protected _markAllSubMeshesAsTexturesDirty(): void;
  21407. /**
  21408. * Indicates that fresnel needs to be re-calculated for all submeshes
  21409. */
  21410. protected _markAllSubMeshesAsFresnelDirty(): void;
  21411. /**
  21412. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21413. */
  21414. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21415. /**
  21416. * Indicates that lights need to be re-calculated for all submeshes
  21417. */
  21418. protected _markAllSubMeshesAsLightsDirty(): void;
  21419. /**
  21420. * Indicates that attributes need to be re-calculated for all submeshes
  21421. */
  21422. protected _markAllSubMeshesAsAttributesDirty(): void;
  21423. /**
  21424. * Indicates that misc needs to be re-calculated for all submeshes
  21425. */
  21426. protected _markAllSubMeshesAsMiscDirty(): void;
  21427. /**
  21428. * Indicates that textures and misc need to be re-calculated for all submeshes
  21429. */
  21430. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21431. /**
  21432. * Disposes the material
  21433. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21434. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21435. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21436. */
  21437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21438. /** @hidden */
  21439. private releaseVertexArrayObject;
  21440. /**
  21441. * Serializes this material
  21442. * @returns the serialized material object
  21443. */
  21444. serialize(): any;
  21445. /**
  21446. * Creates a material from parsed material data
  21447. * @param parsedMaterial defines parsed material data
  21448. * @param scene defines the hosting scene
  21449. * @param rootUrl defines the root URL to use to load textures
  21450. * @returns a new material
  21451. */
  21452. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21453. }
  21454. }
  21455. declare module "babylonjs/Materials/multiMaterial" {
  21456. import { Nullable } from "babylonjs/types";
  21457. import { Scene } from "babylonjs/scene";
  21458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21459. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21461. import { Material } from "babylonjs/Materials/material";
  21462. /**
  21463. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21464. * separate meshes. This can be use to improve performances.
  21465. * @see http://doc.babylonjs.com/how_to/multi_materials
  21466. */
  21467. export class MultiMaterial extends Material {
  21468. private _subMaterials;
  21469. /**
  21470. * Gets or Sets the list of Materials used within the multi material.
  21471. * They need to be ordered according to the submeshes order in the associated mesh
  21472. */
  21473. subMaterials: Nullable<Material>[];
  21474. /**
  21475. * Function used to align with Node.getChildren()
  21476. * @returns the list of Materials used within the multi material
  21477. */
  21478. getChildren(): Nullable<Material>[];
  21479. /**
  21480. * Instantiates a new Multi Material
  21481. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21482. * separate meshes. This can be use to improve performances.
  21483. * @see http://doc.babylonjs.com/how_to/multi_materials
  21484. * @param name Define the name in the scene
  21485. * @param scene Define the scene the material belongs to
  21486. */
  21487. constructor(name: string, scene: Scene);
  21488. private _hookArray;
  21489. /**
  21490. * Get one of the submaterial by its index in the submaterials array
  21491. * @param index The index to look the sub material at
  21492. * @returns The Material if the index has been defined
  21493. */
  21494. getSubMaterial(index: number): Nullable<Material>;
  21495. /**
  21496. * Get the list of active textures for the whole sub materials list.
  21497. * @returns All the textures that will be used during the rendering
  21498. */
  21499. getActiveTextures(): BaseTexture[];
  21500. /**
  21501. * Gets the current class name of the material e.g. "MultiMaterial"
  21502. * Mainly use in serialization.
  21503. * @returns the class name
  21504. */
  21505. getClassName(): string;
  21506. /**
  21507. * Checks if the material is ready to render the requested sub mesh
  21508. * @param mesh Define the mesh the submesh belongs to
  21509. * @param subMesh Define the sub mesh to look readyness for
  21510. * @param useInstances Define whether or not the material is used with instances
  21511. * @returns true if ready, otherwise false
  21512. */
  21513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21514. /**
  21515. * Clones the current material and its related sub materials
  21516. * @param name Define the name of the newly cloned material
  21517. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21518. * @returns the cloned material
  21519. */
  21520. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21521. /**
  21522. * Serializes the materials into a JSON representation.
  21523. * @returns the JSON representation
  21524. */
  21525. serialize(): any;
  21526. /**
  21527. * Dispose the material and release its associated resources
  21528. * @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)
  21529. * @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)
  21530. * @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)
  21531. */
  21532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21533. /**
  21534. * Creates a MultiMaterial from parsed MultiMaterial data.
  21535. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21536. * @param scene defines the hosting scene
  21537. * @returns a new MultiMaterial
  21538. */
  21539. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21540. }
  21541. }
  21542. declare module "babylonjs/Meshes/subMesh" {
  21543. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21544. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21545. import { Engine } from "babylonjs/Engines/engine";
  21546. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21547. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21548. import { Effect } from "babylonjs/Materials/effect";
  21549. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21550. import { Plane } from "babylonjs/Maths/math.plane";
  21551. import { Collider } from "babylonjs/Collisions/collider";
  21552. import { Material } from "babylonjs/Materials/material";
  21553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21555. import { Mesh } from "babylonjs/Meshes/mesh";
  21556. import { Ray } from "babylonjs/Culling/ray";
  21557. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21558. /**
  21559. * Base class for submeshes
  21560. */
  21561. export class BaseSubMesh {
  21562. /** @hidden */
  21563. _materialDefines: Nullable<MaterialDefines>;
  21564. /** @hidden */
  21565. _materialEffect: Nullable<Effect>;
  21566. /**
  21567. * Gets associated effect
  21568. */
  21569. readonly effect: Nullable<Effect>;
  21570. /**
  21571. * Sets associated effect (effect used to render this submesh)
  21572. * @param effect defines the effect to associate with
  21573. * @param defines defines the set of defines used to compile this effect
  21574. */
  21575. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21576. }
  21577. /**
  21578. * Defines a subdivision inside a mesh
  21579. */
  21580. export class SubMesh extends BaseSubMesh implements ICullable {
  21581. /** the material index to use */
  21582. materialIndex: number;
  21583. /** vertex index start */
  21584. verticesStart: number;
  21585. /** vertices count */
  21586. verticesCount: number;
  21587. /** index start */
  21588. indexStart: number;
  21589. /** indices count */
  21590. indexCount: number;
  21591. /** @hidden */
  21592. _linesIndexCount: number;
  21593. private _mesh;
  21594. private _renderingMesh;
  21595. private _boundingInfo;
  21596. private _linesIndexBuffer;
  21597. /** @hidden */
  21598. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21599. /** @hidden */
  21600. _trianglePlanes: Plane[];
  21601. /** @hidden */
  21602. _lastColliderTransformMatrix: Nullable<Matrix>;
  21603. /** @hidden */
  21604. _renderId: number;
  21605. /** @hidden */
  21606. _alphaIndex: number;
  21607. /** @hidden */
  21608. _distanceToCamera: number;
  21609. /** @hidden */
  21610. _id: number;
  21611. private _currentMaterial;
  21612. /**
  21613. * Add a new submesh to a mesh
  21614. * @param materialIndex defines the material index to use
  21615. * @param verticesStart defines vertex index start
  21616. * @param verticesCount defines vertices count
  21617. * @param indexStart defines index start
  21618. * @param indexCount defines indices count
  21619. * @param mesh defines the parent mesh
  21620. * @param renderingMesh defines an optional rendering mesh
  21621. * @param createBoundingBox defines if bounding box should be created for this submesh
  21622. * @returns the new submesh
  21623. */
  21624. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21625. /**
  21626. * Creates a new submesh
  21627. * @param materialIndex defines the material index to use
  21628. * @param verticesStart defines vertex index start
  21629. * @param verticesCount defines vertices count
  21630. * @param indexStart defines index start
  21631. * @param indexCount defines indices count
  21632. * @param mesh defines the parent mesh
  21633. * @param renderingMesh defines an optional rendering mesh
  21634. * @param createBoundingBox defines if bounding box should be created for this submesh
  21635. */
  21636. constructor(
  21637. /** the material index to use */
  21638. materialIndex: number,
  21639. /** vertex index start */
  21640. verticesStart: number,
  21641. /** vertices count */
  21642. verticesCount: number,
  21643. /** index start */
  21644. indexStart: number,
  21645. /** indices count */
  21646. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21647. /**
  21648. * Returns true if this submesh covers the entire parent mesh
  21649. * @ignorenaming
  21650. */
  21651. readonly IsGlobal: boolean;
  21652. /**
  21653. * Returns the submesh BoudingInfo object
  21654. * @returns current bounding info (or mesh's one if the submesh is global)
  21655. */
  21656. getBoundingInfo(): BoundingInfo;
  21657. /**
  21658. * Sets the submesh BoundingInfo
  21659. * @param boundingInfo defines the new bounding info to use
  21660. * @returns the SubMesh
  21661. */
  21662. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21663. /**
  21664. * Returns the mesh of the current submesh
  21665. * @return the parent mesh
  21666. */
  21667. getMesh(): AbstractMesh;
  21668. /**
  21669. * Returns the rendering mesh of the submesh
  21670. * @returns the rendering mesh (could be different from parent mesh)
  21671. */
  21672. getRenderingMesh(): Mesh;
  21673. /**
  21674. * Returns the submesh material
  21675. * @returns null or the current material
  21676. */
  21677. getMaterial(): Nullable<Material>;
  21678. /**
  21679. * Sets a new updated BoundingInfo object to the submesh
  21680. * @param data defines an optional position array to use to determine the bounding info
  21681. * @returns the SubMesh
  21682. */
  21683. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21684. /** @hidden */
  21685. _checkCollision(collider: Collider): boolean;
  21686. /**
  21687. * Updates the submesh BoundingInfo
  21688. * @param world defines the world matrix to use to update the bounding info
  21689. * @returns the submesh
  21690. */
  21691. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21692. /**
  21693. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21694. * @param frustumPlanes defines the frustum planes
  21695. * @returns true if the submesh is intersecting with the frustum
  21696. */
  21697. isInFrustum(frustumPlanes: Plane[]): boolean;
  21698. /**
  21699. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21700. * @param frustumPlanes defines the frustum planes
  21701. * @returns true if the submesh is inside the frustum
  21702. */
  21703. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21704. /**
  21705. * Renders the submesh
  21706. * @param enableAlphaMode defines if alpha needs to be used
  21707. * @returns the submesh
  21708. */
  21709. render(enableAlphaMode: boolean): SubMesh;
  21710. /**
  21711. * @hidden
  21712. */
  21713. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21714. /**
  21715. * Checks if the submesh intersects with a ray
  21716. * @param ray defines the ray to test
  21717. * @returns true is the passed ray intersects the submesh bounding box
  21718. */
  21719. canIntersects(ray: Ray): boolean;
  21720. /**
  21721. * Intersects current submesh with a ray
  21722. * @param ray defines the ray to test
  21723. * @param positions defines mesh's positions array
  21724. * @param indices defines mesh's indices array
  21725. * @param fastCheck defines if only bounding info should be used
  21726. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21727. * @returns intersection info or null if no intersection
  21728. */
  21729. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21730. /** @hidden */
  21731. private _intersectLines;
  21732. /** @hidden */
  21733. private _intersectUnIndexedLines;
  21734. /** @hidden */
  21735. private _intersectTriangles;
  21736. /** @hidden */
  21737. private _intersectUnIndexedTriangles;
  21738. /** @hidden */
  21739. _rebuild(): void;
  21740. /**
  21741. * Creates a new submesh from the passed mesh
  21742. * @param newMesh defines the new hosting mesh
  21743. * @param newRenderingMesh defines an optional rendering mesh
  21744. * @returns the new submesh
  21745. */
  21746. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21747. /**
  21748. * Release associated resources
  21749. */
  21750. dispose(): void;
  21751. /**
  21752. * Gets the class name
  21753. * @returns the string "SubMesh".
  21754. */
  21755. getClassName(): string;
  21756. /**
  21757. * Creates a new submesh from indices data
  21758. * @param materialIndex the index of the main mesh material
  21759. * @param startIndex the index where to start the copy in the mesh indices array
  21760. * @param indexCount the number of indices to copy then from the startIndex
  21761. * @param mesh the main mesh to create the submesh from
  21762. * @param renderingMesh the optional rendering mesh
  21763. * @returns a new submesh
  21764. */
  21765. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21766. }
  21767. }
  21768. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21769. /**
  21770. * Class used to represent data loading progression
  21771. */
  21772. export class SceneLoaderFlags {
  21773. private static _ForceFullSceneLoadingForIncremental;
  21774. private static _ShowLoadingScreen;
  21775. private static _CleanBoneMatrixWeights;
  21776. private static _loggingLevel;
  21777. /**
  21778. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21779. */
  21780. static ForceFullSceneLoadingForIncremental: boolean;
  21781. /**
  21782. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21783. */
  21784. static ShowLoadingScreen: boolean;
  21785. /**
  21786. * Defines the current logging level (while loading the scene)
  21787. * @ignorenaming
  21788. */
  21789. static loggingLevel: number;
  21790. /**
  21791. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21792. */
  21793. static CleanBoneMatrixWeights: boolean;
  21794. }
  21795. }
  21796. declare module "babylonjs/Meshes/geometry" {
  21797. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21798. import { Scene } from "babylonjs/scene";
  21799. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21800. import { Engine } from "babylonjs/Engines/engine";
  21801. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21802. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21803. import { Effect } from "babylonjs/Materials/effect";
  21804. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21805. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21806. import { Mesh } from "babylonjs/Meshes/mesh";
  21807. /**
  21808. * Class used to store geometry data (vertex buffers + index buffer)
  21809. */
  21810. export class Geometry implements IGetSetVerticesData {
  21811. /**
  21812. * Gets or sets the ID of the geometry
  21813. */
  21814. id: string;
  21815. /**
  21816. * Gets or sets the unique ID of the geometry
  21817. */
  21818. uniqueId: number;
  21819. /**
  21820. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21821. */
  21822. delayLoadState: number;
  21823. /**
  21824. * Gets the file containing the data to load when running in delay load state
  21825. */
  21826. delayLoadingFile: Nullable<string>;
  21827. /**
  21828. * Callback called when the geometry is updated
  21829. */
  21830. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21831. private _scene;
  21832. private _engine;
  21833. private _meshes;
  21834. private _totalVertices;
  21835. /** @hidden */
  21836. _indices: IndicesArray;
  21837. /** @hidden */
  21838. _vertexBuffers: {
  21839. [key: string]: VertexBuffer;
  21840. };
  21841. private _isDisposed;
  21842. private _extend;
  21843. private _boundingBias;
  21844. /** @hidden */
  21845. _delayInfo: Array<string>;
  21846. private _indexBuffer;
  21847. private _indexBufferIsUpdatable;
  21848. /** @hidden */
  21849. _boundingInfo: Nullable<BoundingInfo>;
  21850. /** @hidden */
  21851. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21852. /** @hidden */
  21853. _softwareSkinningFrameId: number;
  21854. private _vertexArrayObjects;
  21855. private _updatable;
  21856. /** @hidden */
  21857. _positions: Nullable<Vector3[]>;
  21858. /**
  21859. * 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
  21860. */
  21861. /**
  21862. * 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
  21863. */
  21864. boundingBias: Vector2;
  21865. /**
  21866. * Static function used to attach a new empty geometry to a mesh
  21867. * @param mesh defines the mesh to attach the geometry to
  21868. * @returns the new Geometry
  21869. */
  21870. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21871. /**
  21872. * Creates a new geometry
  21873. * @param id defines the unique ID
  21874. * @param scene defines the hosting scene
  21875. * @param vertexData defines the VertexData used to get geometry data
  21876. * @param updatable defines if geometry must be updatable (false by default)
  21877. * @param mesh defines the mesh that will be associated with the geometry
  21878. */
  21879. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21880. /**
  21881. * Gets the current extend of the geometry
  21882. */
  21883. readonly extend: {
  21884. minimum: Vector3;
  21885. maximum: Vector3;
  21886. };
  21887. /**
  21888. * Gets the hosting scene
  21889. * @returns the hosting Scene
  21890. */
  21891. getScene(): Scene;
  21892. /**
  21893. * Gets the hosting engine
  21894. * @returns the hosting Engine
  21895. */
  21896. getEngine(): Engine;
  21897. /**
  21898. * Defines if the geometry is ready to use
  21899. * @returns true if the geometry is ready to be used
  21900. */
  21901. isReady(): boolean;
  21902. /**
  21903. * Gets a value indicating that the geometry should not be serialized
  21904. */
  21905. readonly doNotSerialize: boolean;
  21906. /** @hidden */
  21907. _rebuild(): void;
  21908. /**
  21909. * Affects all geometry data in one call
  21910. * @param vertexData defines the geometry data
  21911. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21912. */
  21913. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21914. /**
  21915. * Set specific vertex data
  21916. * @param kind defines the data kind (Position, normal, etc...)
  21917. * @param data defines the vertex data to use
  21918. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21919. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21920. */
  21921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21922. /**
  21923. * Removes a specific vertex data
  21924. * @param kind defines the data kind (Position, normal, etc...)
  21925. */
  21926. removeVerticesData(kind: string): void;
  21927. /**
  21928. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21929. * @param buffer defines the vertex buffer to use
  21930. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21931. */
  21932. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21933. /**
  21934. * Update a specific vertex buffer
  21935. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21936. * It will do nothing if the buffer is not updatable
  21937. * @param kind defines the data kind (Position, normal, etc...)
  21938. * @param data defines the data to use
  21939. * @param offset defines the offset in the target buffer where to store the data
  21940. * @param useBytes set to true if the offset is in bytes
  21941. */
  21942. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21943. /**
  21944. * Update a specific vertex buffer
  21945. * This function will create a new buffer if the current one is not updatable
  21946. * @param kind defines the data kind (Position, normal, etc...)
  21947. * @param data defines the data to use
  21948. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21949. */
  21950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21951. private _updateBoundingInfo;
  21952. /** @hidden */
  21953. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21954. /**
  21955. * Gets total number of vertices
  21956. * @returns the total number of vertices
  21957. */
  21958. getTotalVertices(): number;
  21959. /**
  21960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21961. * @param kind defines the data kind (Position, normal, etc...)
  21962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21964. * @returns a float array containing vertex data
  21965. */
  21966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21967. /**
  21968. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21969. * @param kind defines the data kind (Position, normal, etc...)
  21970. * @returns true if the vertex buffer with the specified kind is updatable
  21971. */
  21972. isVertexBufferUpdatable(kind: string): boolean;
  21973. /**
  21974. * Gets a specific vertex buffer
  21975. * @param kind defines the data kind (Position, normal, etc...)
  21976. * @returns a VertexBuffer
  21977. */
  21978. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21979. /**
  21980. * Returns all vertex buffers
  21981. * @return an object holding all vertex buffers indexed by kind
  21982. */
  21983. getVertexBuffers(): Nullable<{
  21984. [key: string]: VertexBuffer;
  21985. }>;
  21986. /**
  21987. * Gets a boolean indicating if specific vertex buffer is present
  21988. * @param kind defines the data kind (Position, normal, etc...)
  21989. * @returns true if data is present
  21990. */
  21991. isVerticesDataPresent(kind: string): boolean;
  21992. /**
  21993. * Gets a list of all attached data kinds (Position, normal, etc...)
  21994. * @returns a list of string containing all kinds
  21995. */
  21996. getVerticesDataKinds(): string[];
  21997. /**
  21998. * Update index buffer
  21999. * @param indices defines the indices to store in the index buffer
  22000. * @param offset defines the offset in the target buffer where to store the data
  22001. * @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)
  22002. */
  22003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22004. /**
  22005. * Creates a new index buffer
  22006. * @param indices defines the indices to store in the index buffer
  22007. * @param totalVertices defines the total number of vertices (could be null)
  22008. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22009. */
  22010. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22011. /**
  22012. * Return the total number of indices
  22013. * @returns the total number of indices
  22014. */
  22015. getTotalIndices(): number;
  22016. /**
  22017. * Gets the index buffer array
  22018. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22020. * @returns the index buffer array
  22021. */
  22022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22023. /**
  22024. * Gets the index buffer
  22025. * @return the index buffer
  22026. */
  22027. getIndexBuffer(): Nullable<DataBuffer>;
  22028. /** @hidden */
  22029. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22030. /**
  22031. * Release the associated resources for a specific mesh
  22032. * @param mesh defines the source mesh
  22033. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22034. */
  22035. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22036. /**
  22037. * Apply current geometry to a given mesh
  22038. * @param mesh defines the mesh to apply geometry to
  22039. */
  22040. applyToMesh(mesh: Mesh): void;
  22041. private _updateExtend;
  22042. private _applyToMesh;
  22043. private notifyUpdate;
  22044. /**
  22045. * Load the geometry if it was flagged as delay loaded
  22046. * @param scene defines the hosting scene
  22047. * @param onLoaded defines a callback called when the geometry is loaded
  22048. */
  22049. load(scene: Scene, onLoaded?: () => void): void;
  22050. private _queueLoad;
  22051. /**
  22052. * Invert the geometry to move from a right handed system to a left handed one.
  22053. */
  22054. toLeftHanded(): void;
  22055. /** @hidden */
  22056. _resetPointsArrayCache(): void;
  22057. /** @hidden */
  22058. _generatePointsArray(): boolean;
  22059. /**
  22060. * Gets a value indicating if the geometry is disposed
  22061. * @returns true if the geometry was disposed
  22062. */
  22063. isDisposed(): boolean;
  22064. private _disposeVertexArrayObjects;
  22065. /**
  22066. * Free all associated resources
  22067. */
  22068. dispose(): void;
  22069. /**
  22070. * Clone the current geometry into a new geometry
  22071. * @param id defines the unique ID of the new geometry
  22072. * @returns a new geometry object
  22073. */
  22074. copy(id: string): Geometry;
  22075. /**
  22076. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22077. * @return a JSON representation of the current geometry data (without the vertices data)
  22078. */
  22079. serialize(): any;
  22080. private toNumberArray;
  22081. /**
  22082. * Serialize all vertices data into a JSON oject
  22083. * @returns a JSON representation of the current geometry data
  22084. */
  22085. serializeVerticeData(): any;
  22086. /**
  22087. * Extracts a clone of a mesh geometry
  22088. * @param mesh defines the source mesh
  22089. * @param id defines the unique ID of the new geometry object
  22090. * @returns the new geometry object
  22091. */
  22092. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22093. /**
  22094. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22095. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22096. * Be aware Math.random() could cause collisions, but:
  22097. * "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"
  22098. * @returns a string containing a new GUID
  22099. */
  22100. static RandomId(): string;
  22101. /** @hidden */
  22102. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22103. private static _CleanMatricesWeights;
  22104. /**
  22105. * Create a new geometry from persisted data (Using .babylon file format)
  22106. * @param parsedVertexData defines the persisted data
  22107. * @param scene defines the hosting scene
  22108. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22109. * @returns the new geometry object
  22110. */
  22111. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22112. }
  22113. }
  22114. declare module "babylonjs/Meshes/mesh.vertexData" {
  22115. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22116. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22117. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22118. import { Geometry } from "babylonjs/Meshes/geometry";
  22119. import { Mesh } from "babylonjs/Meshes/mesh";
  22120. /**
  22121. * Define an interface for all classes that will get and set the data on vertices
  22122. */
  22123. export interface IGetSetVerticesData {
  22124. /**
  22125. * Gets a boolean indicating if specific vertex data is present
  22126. * @param kind defines the vertex data kind to use
  22127. * @returns true is data kind is present
  22128. */
  22129. isVerticesDataPresent(kind: string): boolean;
  22130. /**
  22131. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22132. * @param kind defines the data kind (Position, normal, etc...)
  22133. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22134. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22135. * @returns a float array containing vertex data
  22136. */
  22137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22138. /**
  22139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22140. * @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.
  22141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22142. * @returns the indices array or an empty array if the mesh has no geometry
  22143. */
  22144. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22145. /**
  22146. * Set specific vertex data
  22147. * @param kind defines the data kind (Position, normal, etc...)
  22148. * @param data defines the vertex data to use
  22149. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22150. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22151. */
  22152. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22153. /**
  22154. * Update a specific associated vertex buffer
  22155. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22156. * - VertexBuffer.PositionKind
  22157. * - VertexBuffer.UVKind
  22158. * - VertexBuffer.UV2Kind
  22159. * - VertexBuffer.UV3Kind
  22160. * - VertexBuffer.UV4Kind
  22161. * - VertexBuffer.UV5Kind
  22162. * - VertexBuffer.UV6Kind
  22163. * - VertexBuffer.ColorKind
  22164. * - VertexBuffer.MatricesIndicesKind
  22165. * - VertexBuffer.MatricesIndicesExtraKind
  22166. * - VertexBuffer.MatricesWeightsKind
  22167. * - VertexBuffer.MatricesWeightsExtraKind
  22168. * @param data defines the data source
  22169. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22170. * @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)
  22171. */
  22172. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22173. /**
  22174. * Creates a new index buffer
  22175. * @param indices defines the indices to store in the index buffer
  22176. * @param totalVertices defines the total number of vertices (could be null)
  22177. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22178. */
  22179. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22180. }
  22181. /**
  22182. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22183. */
  22184. export class VertexData {
  22185. /**
  22186. * Mesh side orientation : usually the external or front surface
  22187. */
  22188. static readonly FRONTSIDE: number;
  22189. /**
  22190. * Mesh side orientation : usually the internal or back surface
  22191. */
  22192. static readonly BACKSIDE: number;
  22193. /**
  22194. * Mesh side orientation : both internal and external or front and back surfaces
  22195. */
  22196. static readonly DOUBLESIDE: number;
  22197. /**
  22198. * Mesh side orientation : by default, `FRONTSIDE`
  22199. */
  22200. static readonly DEFAULTSIDE: number;
  22201. /**
  22202. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22203. */
  22204. positions: Nullable<FloatArray>;
  22205. /**
  22206. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22207. */
  22208. normals: Nullable<FloatArray>;
  22209. /**
  22210. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22211. */
  22212. tangents: Nullable<FloatArray>;
  22213. /**
  22214. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22215. */
  22216. uvs: Nullable<FloatArray>;
  22217. /**
  22218. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22219. */
  22220. uvs2: Nullable<FloatArray>;
  22221. /**
  22222. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22223. */
  22224. uvs3: Nullable<FloatArray>;
  22225. /**
  22226. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22227. */
  22228. uvs4: Nullable<FloatArray>;
  22229. /**
  22230. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22231. */
  22232. uvs5: Nullable<FloatArray>;
  22233. /**
  22234. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22235. */
  22236. uvs6: Nullable<FloatArray>;
  22237. /**
  22238. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22239. */
  22240. colors: Nullable<FloatArray>;
  22241. /**
  22242. * 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).
  22243. */
  22244. matricesIndices: Nullable<FloatArray>;
  22245. /**
  22246. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22247. */
  22248. matricesWeights: Nullable<FloatArray>;
  22249. /**
  22250. * An array extending the number of possible indices
  22251. */
  22252. matricesIndicesExtra: Nullable<FloatArray>;
  22253. /**
  22254. * An array extending the number of possible weights when the number of indices is extended
  22255. */
  22256. matricesWeightsExtra: Nullable<FloatArray>;
  22257. /**
  22258. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22259. */
  22260. indices: Nullable<IndicesArray>;
  22261. /**
  22262. * Uses the passed data array to set the set the values for the specified kind of data
  22263. * @param data a linear array of floating numbers
  22264. * @param kind the type of data that is being set, eg positions, colors etc
  22265. */
  22266. set(data: FloatArray, kind: string): void;
  22267. /**
  22268. * Associates the vertexData to the passed Mesh.
  22269. * Sets it as updatable or not (default `false`)
  22270. * @param mesh the mesh the vertexData is applied to
  22271. * @param updatable when used and having the value true allows new data to update the vertexData
  22272. * @returns the VertexData
  22273. */
  22274. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22275. /**
  22276. * Associates the vertexData to the passed Geometry.
  22277. * Sets it as updatable or not (default `false`)
  22278. * @param geometry the geometry the vertexData is applied to
  22279. * @param updatable when used and having the value true allows new data to update the vertexData
  22280. * @returns VertexData
  22281. */
  22282. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22283. /**
  22284. * Updates the associated mesh
  22285. * @param mesh the mesh to be updated
  22286. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22287. * @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
  22288. * @returns VertexData
  22289. */
  22290. updateMesh(mesh: Mesh): VertexData;
  22291. /**
  22292. * Updates the associated geometry
  22293. * @param geometry the geometry to be updated
  22294. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22295. * @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
  22296. * @returns VertexData.
  22297. */
  22298. updateGeometry(geometry: Geometry): VertexData;
  22299. private _applyTo;
  22300. private _update;
  22301. /**
  22302. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22303. * @param matrix the transforming matrix
  22304. * @returns the VertexData
  22305. */
  22306. transform(matrix: Matrix): VertexData;
  22307. /**
  22308. * Merges the passed VertexData into the current one
  22309. * @param other the VertexData to be merged into the current one
  22310. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22311. * @returns the modified VertexData
  22312. */
  22313. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22314. private _mergeElement;
  22315. private _validate;
  22316. /**
  22317. * Serializes the VertexData
  22318. * @returns a serialized object
  22319. */
  22320. serialize(): any;
  22321. /**
  22322. * Extracts the vertexData from a mesh
  22323. * @param mesh the mesh from which to extract the VertexData
  22324. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22325. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22326. * @returns the object VertexData associated to the passed mesh
  22327. */
  22328. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22329. /**
  22330. * Extracts the vertexData from the geometry
  22331. * @param geometry the geometry from which to extract the VertexData
  22332. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22333. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22334. * @returns the object VertexData associated to the passed mesh
  22335. */
  22336. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22337. private static _ExtractFrom;
  22338. /**
  22339. * Creates the VertexData for a Ribbon
  22340. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22341. * * pathArray array of paths, each of which an array of successive Vector3
  22342. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22343. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22344. * * 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
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22349. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22350. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22351. * @returns the VertexData of the ribbon
  22352. */
  22353. static CreateRibbon(options: {
  22354. pathArray: Vector3[][];
  22355. closeArray?: boolean;
  22356. closePath?: boolean;
  22357. offset?: number;
  22358. sideOrientation?: number;
  22359. frontUVs?: Vector4;
  22360. backUVs?: Vector4;
  22361. invertUV?: boolean;
  22362. uvs?: Vector2[];
  22363. colors?: Color4[];
  22364. }): VertexData;
  22365. /**
  22366. * Creates the VertexData for a box
  22367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22368. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22369. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22370. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22371. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22372. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22373. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22375. * * 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)
  22376. * * 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)
  22377. * @returns the VertexData of the box
  22378. */
  22379. static CreateBox(options: {
  22380. size?: number;
  22381. width?: number;
  22382. height?: number;
  22383. depth?: number;
  22384. faceUV?: Vector4[];
  22385. faceColors?: Color4[];
  22386. sideOrientation?: number;
  22387. frontUVs?: Vector4;
  22388. backUVs?: Vector4;
  22389. }): VertexData;
  22390. /**
  22391. * Creates the VertexData for a tiled box
  22392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22393. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22394. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22395. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22397. * @returns the VertexData of the box
  22398. */
  22399. static CreateTiledBox(options: {
  22400. pattern?: number;
  22401. width?: number;
  22402. height?: number;
  22403. depth?: number;
  22404. tileSize?: number;
  22405. tileWidth?: number;
  22406. tileHeight?: number;
  22407. alignHorizontal?: number;
  22408. alignVertical?: number;
  22409. faceUV?: Vector4[];
  22410. faceColors?: Color4[];
  22411. sideOrientation?: number;
  22412. }): VertexData;
  22413. /**
  22414. * Creates the VertexData for a tiled plane
  22415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22416. * * pattern a limited pattern arrangement depending on the number
  22417. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22418. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22419. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * * 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)
  22422. * * 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)
  22423. * @returns the VertexData of the tiled plane
  22424. */
  22425. static CreateTiledPlane(options: {
  22426. pattern?: number;
  22427. tileSize?: number;
  22428. tileWidth?: number;
  22429. tileHeight?: number;
  22430. size?: number;
  22431. width?: number;
  22432. height?: number;
  22433. alignHorizontal?: number;
  22434. alignVertical?: number;
  22435. sideOrientation?: number;
  22436. frontUVs?: Vector4;
  22437. backUVs?: Vector4;
  22438. }): VertexData;
  22439. /**
  22440. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22441. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22442. * * segments sets the number of horizontal strips optional, default 32
  22443. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22444. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22445. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22446. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22447. * * 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
  22448. * * 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
  22449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * * 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)
  22451. * * 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)
  22452. * @returns the VertexData of the ellipsoid
  22453. */
  22454. static CreateSphere(options: {
  22455. segments?: number;
  22456. diameter?: number;
  22457. diameterX?: number;
  22458. diameterY?: number;
  22459. diameterZ?: number;
  22460. arc?: number;
  22461. slice?: number;
  22462. sideOrientation?: number;
  22463. frontUVs?: Vector4;
  22464. backUVs?: Vector4;
  22465. }): VertexData;
  22466. /**
  22467. * Creates the VertexData for a cylinder, cone or prism
  22468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22469. * * height sets the height (y direction) of the cylinder, optional, default 2
  22470. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22471. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22472. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22473. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22474. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22475. * * 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
  22476. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22477. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22478. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22479. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22481. * * 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)
  22482. * * 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)
  22483. * @returns the VertexData of the cylinder, cone or prism
  22484. */
  22485. static CreateCylinder(options: {
  22486. height?: number;
  22487. diameterTop?: number;
  22488. diameterBottom?: number;
  22489. diameter?: number;
  22490. tessellation?: number;
  22491. subdivisions?: number;
  22492. arc?: number;
  22493. faceColors?: Color4[];
  22494. faceUV?: Vector4[];
  22495. hasRings?: boolean;
  22496. enclose?: boolean;
  22497. sideOrientation?: number;
  22498. frontUVs?: Vector4;
  22499. backUVs?: Vector4;
  22500. }): VertexData;
  22501. /**
  22502. * Creates the VertexData for a torus
  22503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22504. * * diameter the diameter of the torus, optional default 1
  22505. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22506. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22508. * * 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)
  22509. * * 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)
  22510. * @returns the VertexData of the torus
  22511. */
  22512. static CreateTorus(options: {
  22513. diameter?: number;
  22514. thickness?: number;
  22515. tessellation?: number;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData of the LineSystem
  22522. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22523. * - lines an array of lines, each line being an array of successive Vector3
  22524. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22525. * @returns the VertexData of the LineSystem
  22526. */
  22527. static CreateLineSystem(options: {
  22528. lines: Vector3[][];
  22529. colors?: Nullable<Color4[][]>;
  22530. }): VertexData;
  22531. /**
  22532. * Create the VertexData for a DashedLines
  22533. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22534. * - points an array successive Vector3
  22535. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22536. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22537. * - dashNb the intended total number of dashes, optional, default 200
  22538. * @returns the VertexData for the DashedLines
  22539. */
  22540. static CreateDashedLines(options: {
  22541. points: Vector3[];
  22542. dashSize?: number;
  22543. gapSize?: number;
  22544. dashNb?: number;
  22545. }): VertexData;
  22546. /**
  22547. * Creates the VertexData for a Ground
  22548. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22549. * - width the width (x direction) of the ground, optional, default 1
  22550. * - height the height (z direction) of the ground, optional, default 1
  22551. * - subdivisions the number of subdivisions per side, optional, default 1
  22552. * @returns the VertexData of the Ground
  22553. */
  22554. static CreateGround(options: {
  22555. width?: number;
  22556. height?: number;
  22557. subdivisions?: number;
  22558. subdivisionsX?: number;
  22559. subdivisionsY?: number;
  22560. }): VertexData;
  22561. /**
  22562. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22563. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22564. * * xmin the ground minimum X coordinate, optional, default -1
  22565. * * zmin the ground minimum Z coordinate, optional, default -1
  22566. * * xmax the ground maximum X coordinate, optional, default 1
  22567. * * zmax the ground maximum Z coordinate, optional, default 1
  22568. * * 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}
  22569. * * 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}
  22570. * @returns the VertexData of the TiledGround
  22571. */
  22572. static CreateTiledGround(options: {
  22573. xmin: number;
  22574. zmin: number;
  22575. xmax: number;
  22576. zmax: number;
  22577. subdivisions?: {
  22578. w: number;
  22579. h: number;
  22580. };
  22581. precision?: {
  22582. w: number;
  22583. h: number;
  22584. };
  22585. }): VertexData;
  22586. /**
  22587. * Creates the VertexData of the Ground designed from a heightmap
  22588. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22589. * * width the width (x direction) of the ground
  22590. * * height the height (z direction) of the ground
  22591. * * subdivisions the number of subdivisions per side
  22592. * * minHeight the minimum altitude on the ground, optional, default 0
  22593. * * maxHeight the maximum altitude on the ground, optional default 1
  22594. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22595. * * buffer the array holding the image color data
  22596. * * bufferWidth the width of image
  22597. * * bufferHeight the height of image
  22598. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22599. * @returns the VertexData of the Ground designed from a heightmap
  22600. */
  22601. static CreateGroundFromHeightMap(options: {
  22602. width: number;
  22603. height: number;
  22604. subdivisions: number;
  22605. minHeight: number;
  22606. maxHeight: number;
  22607. colorFilter: Color3;
  22608. buffer: Uint8Array;
  22609. bufferWidth: number;
  22610. bufferHeight: number;
  22611. alphaFilter: number;
  22612. }): VertexData;
  22613. /**
  22614. * Creates the VertexData for a Plane
  22615. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22616. * * size sets the width and height of the plane to the value of size, optional default 1
  22617. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22618. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22620. * * 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)
  22621. * * 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)
  22622. * @returns the VertexData of the box
  22623. */
  22624. static CreatePlane(options: {
  22625. size?: number;
  22626. width?: number;
  22627. height?: number;
  22628. sideOrientation?: number;
  22629. frontUVs?: Vector4;
  22630. backUVs?: Vector4;
  22631. }): VertexData;
  22632. /**
  22633. * Creates the VertexData of the Disc or regular Polygon
  22634. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22635. * * radius the radius of the disc, optional default 0.5
  22636. * * tessellation the number of polygon sides, optional, default 64
  22637. * * 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
  22638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22639. * * 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)
  22640. * * 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)
  22641. * @returns the VertexData of the box
  22642. */
  22643. static CreateDisc(options: {
  22644. radius?: number;
  22645. tessellation?: number;
  22646. arc?: number;
  22647. sideOrientation?: number;
  22648. frontUVs?: Vector4;
  22649. backUVs?: Vector4;
  22650. }): VertexData;
  22651. /**
  22652. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22653. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22654. * @param polygon a mesh built from polygonTriangulation.build()
  22655. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22656. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22657. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22658. * @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)
  22659. * @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)
  22660. * @returns the VertexData of the Polygon
  22661. */
  22662. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22663. /**
  22664. * Creates the VertexData of the IcoSphere
  22665. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22666. * * radius the radius of the IcoSphere, optional default 1
  22667. * * radiusX allows stretching in the x direction, optional, default radius
  22668. * * radiusY allows stretching in the y direction, optional, default radius
  22669. * * radiusZ allows stretching in the z direction, optional, default radius
  22670. * * flat when true creates a flat shaded mesh, optional, default true
  22671. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22673. * * 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)
  22674. * * 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)
  22675. * @returns the VertexData of the IcoSphere
  22676. */
  22677. static CreateIcoSphere(options: {
  22678. radius?: number;
  22679. radiusX?: number;
  22680. radiusY?: number;
  22681. radiusZ?: number;
  22682. flat?: boolean;
  22683. subdivisions?: number;
  22684. sideOrientation?: number;
  22685. frontUVs?: Vector4;
  22686. backUVs?: Vector4;
  22687. }): VertexData;
  22688. /**
  22689. * Creates the VertexData for a Polyhedron
  22690. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22691. * * type provided types are:
  22692. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22693. * * 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)
  22694. * * size the size of the IcoSphere, optional default 1
  22695. * * sizeX allows stretching in the x direction, optional, default size
  22696. * * sizeY allows stretching in the y direction, optional, default size
  22697. * * sizeZ allows stretching in the z direction, optional, default size
  22698. * * 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
  22699. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22700. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22701. * * flat when true creates a flat shaded mesh, optional, default true
  22702. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22704. * * 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)
  22705. * * 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)
  22706. * @returns the VertexData of the Polyhedron
  22707. */
  22708. static CreatePolyhedron(options: {
  22709. type?: number;
  22710. size?: number;
  22711. sizeX?: number;
  22712. sizeY?: number;
  22713. sizeZ?: number;
  22714. custom?: any;
  22715. faceUV?: Vector4[];
  22716. faceColors?: Color4[];
  22717. flat?: boolean;
  22718. sideOrientation?: number;
  22719. frontUVs?: Vector4;
  22720. backUVs?: Vector4;
  22721. }): VertexData;
  22722. /**
  22723. * Creates the VertexData for a TorusKnot
  22724. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22725. * * radius the radius of the torus knot, optional, default 2
  22726. * * tube the thickness of the tube, optional, default 0.5
  22727. * * radialSegments the number of sides on each tube segments, optional, default 32
  22728. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22729. * * p the number of windings around the z axis, optional, default 2
  22730. * * q the number of windings around the x axis, optional, default 3
  22731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22732. * * 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)
  22733. * * 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)
  22734. * @returns the VertexData of the Torus Knot
  22735. */
  22736. static CreateTorusKnot(options: {
  22737. radius?: number;
  22738. tube?: number;
  22739. radialSegments?: number;
  22740. tubularSegments?: number;
  22741. p?: number;
  22742. q?: number;
  22743. sideOrientation?: number;
  22744. frontUVs?: Vector4;
  22745. backUVs?: Vector4;
  22746. }): VertexData;
  22747. /**
  22748. * Compute normals for given positions and indices
  22749. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22750. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22751. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22752. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22753. * * facetNormals : optional array of facet normals (vector3)
  22754. * * facetPositions : optional array of facet positions (vector3)
  22755. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22756. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22757. * * bInfo : optional bounding info, required for facetPartitioning computation
  22758. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22759. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22760. * * useRightHandedSystem: optional boolean to for right handed system computation
  22761. * * depthSort : optional boolean to enable the facet depth sort computation
  22762. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22763. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22764. */
  22765. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22766. facetNormals?: any;
  22767. facetPositions?: any;
  22768. facetPartitioning?: any;
  22769. ratio?: number;
  22770. bInfo?: any;
  22771. bbSize?: Vector3;
  22772. subDiv?: any;
  22773. useRightHandedSystem?: boolean;
  22774. depthSort?: boolean;
  22775. distanceTo?: Vector3;
  22776. depthSortedFacets?: any;
  22777. }): void;
  22778. /** @hidden */
  22779. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22780. /**
  22781. * Applies VertexData created from the imported parameters to the geometry
  22782. * @param parsedVertexData the parsed data from an imported file
  22783. * @param geometry the geometry to apply the VertexData to
  22784. */
  22785. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22786. }
  22787. }
  22788. declare module "babylonjs/Morph/morphTarget" {
  22789. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22790. import { Observable } from "babylonjs/Misc/observable";
  22791. import { Nullable, FloatArray } from "babylonjs/types";
  22792. import { Scene } from "babylonjs/scene";
  22793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22794. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22795. /**
  22796. * Defines a target to use with MorphTargetManager
  22797. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22798. */
  22799. export class MorphTarget implements IAnimatable {
  22800. /** defines the name of the target */
  22801. name: string;
  22802. /**
  22803. * Gets or sets the list of animations
  22804. */
  22805. animations: import("babylonjs/Animations/animation").Animation[];
  22806. private _scene;
  22807. private _positions;
  22808. private _normals;
  22809. private _tangents;
  22810. private _uvs;
  22811. private _influence;
  22812. private _uniqueId;
  22813. /**
  22814. * Observable raised when the influence changes
  22815. */
  22816. onInfluenceChanged: Observable<boolean>;
  22817. /** @hidden */
  22818. _onDataLayoutChanged: Observable<void>;
  22819. /**
  22820. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22821. */
  22822. influence: number;
  22823. /**
  22824. * Gets or sets the id of the morph Target
  22825. */
  22826. id: string;
  22827. private _animationPropertiesOverride;
  22828. /**
  22829. * Gets or sets the animation properties override
  22830. */
  22831. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22832. /**
  22833. * Creates a new MorphTarget
  22834. * @param name defines the name of the target
  22835. * @param influence defines the influence to use
  22836. * @param scene defines the scene the morphtarget belongs to
  22837. */
  22838. constructor(
  22839. /** defines the name of the target */
  22840. name: string, influence?: number, scene?: Nullable<Scene>);
  22841. /**
  22842. * Gets the unique ID of this manager
  22843. */
  22844. readonly uniqueId: number;
  22845. /**
  22846. * Gets a boolean defining if the target contains position data
  22847. */
  22848. readonly hasPositions: boolean;
  22849. /**
  22850. * Gets a boolean defining if the target contains normal data
  22851. */
  22852. readonly hasNormals: boolean;
  22853. /**
  22854. * Gets a boolean defining if the target contains tangent data
  22855. */
  22856. readonly hasTangents: boolean;
  22857. /**
  22858. * Gets a boolean defining if the target contains texture coordinates data
  22859. */
  22860. readonly hasUVs: boolean;
  22861. /**
  22862. * Affects position data to this target
  22863. * @param data defines the position data to use
  22864. */
  22865. setPositions(data: Nullable<FloatArray>): void;
  22866. /**
  22867. * Gets the position data stored in this target
  22868. * @returns a FloatArray containing the position data (or null if not present)
  22869. */
  22870. getPositions(): Nullable<FloatArray>;
  22871. /**
  22872. * Affects normal data to this target
  22873. * @param data defines the normal data to use
  22874. */
  22875. setNormals(data: Nullable<FloatArray>): void;
  22876. /**
  22877. * Gets the normal data stored in this target
  22878. * @returns a FloatArray containing the normal data (or null if not present)
  22879. */
  22880. getNormals(): Nullable<FloatArray>;
  22881. /**
  22882. * Affects tangent data to this target
  22883. * @param data defines the tangent data to use
  22884. */
  22885. setTangents(data: Nullable<FloatArray>): void;
  22886. /**
  22887. * Gets the tangent data stored in this target
  22888. * @returns a FloatArray containing the tangent data (or null if not present)
  22889. */
  22890. getTangents(): Nullable<FloatArray>;
  22891. /**
  22892. * Affects texture coordinates data to this target
  22893. * @param data defines the texture coordinates data to use
  22894. */
  22895. setUVs(data: Nullable<FloatArray>): void;
  22896. /**
  22897. * Gets the texture coordinates data stored in this target
  22898. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22899. */
  22900. getUVs(): Nullable<FloatArray>;
  22901. /**
  22902. * Clone the current target
  22903. * @returns a new MorphTarget
  22904. */
  22905. clone(): MorphTarget;
  22906. /**
  22907. * Serializes the current target into a Serialization object
  22908. * @returns the serialized object
  22909. */
  22910. serialize(): any;
  22911. /**
  22912. * Returns the string "MorphTarget"
  22913. * @returns "MorphTarget"
  22914. */
  22915. getClassName(): string;
  22916. /**
  22917. * Creates a new target from serialized data
  22918. * @param serializationObject defines the serialized data to use
  22919. * @returns a new MorphTarget
  22920. */
  22921. static Parse(serializationObject: any): MorphTarget;
  22922. /**
  22923. * Creates a MorphTarget from mesh data
  22924. * @param mesh defines the source mesh
  22925. * @param name defines the name to use for the new target
  22926. * @param influence defines the influence to attach to the target
  22927. * @returns a new MorphTarget
  22928. */
  22929. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22930. }
  22931. }
  22932. declare module "babylonjs/Morph/morphTargetManager" {
  22933. import { Nullable } from "babylonjs/types";
  22934. import { Scene } from "babylonjs/scene";
  22935. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22936. /**
  22937. * This class is used to deform meshes using morphing between different targets
  22938. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22939. */
  22940. export class MorphTargetManager {
  22941. private _targets;
  22942. private _targetInfluenceChangedObservers;
  22943. private _targetDataLayoutChangedObservers;
  22944. private _activeTargets;
  22945. private _scene;
  22946. private _influences;
  22947. private _supportsNormals;
  22948. private _supportsTangents;
  22949. private _supportsUVs;
  22950. private _vertexCount;
  22951. private _uniqueId;
  22952. private _tempInfluences;
  22953. /**
  22954. * Gets or sets a boolean indicating if normals must be morphed
  22955. */
  22956. enableNormalMorphing: boolean;
  22957. /**
  22958. * Gets or sets a boolean indicating if tangents must be morphed
  22959. */
  22960. enableTangentMorphing: boolean;
  22961. /**
  22962. * Gets or sets a boolean indicating if UV must be morphed
  22963. */
  22964. enableUVMorphing: boolean;
  22965. /**
  22966. * Creates a new MorphTargetManager
  22967. * @param scene defines the current scene
  22968. */
  22969. constructor(scene?: Nullable<Scene>);
  22970. /**
  22971. * Gets the unique ID of this manager
  22972. */
  22973. readonly uniqueId: number;
  22974. /**
  22975. * Gets the number of vertices handled by this manager
  22976. */
  22977. readonly vertexCount: number;
  22978. /**
  22979. * Gets a boolean indicating if this manager supports morphing of normals
  22980. */
  22981. readonly supportsNormals: boolean;
  22982. /**
  22983. * Gets a boolean indicating if this manager supports morphing of tangents
  22984. */
  22985. readonly supportsTangents: boolean;
  22986. /**
  22987. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22988. */
  22989. readonly supportsUVs: boolean;
  22990. /**
  22991. * Gets the number of targets stored in this manager
  22992. */
  22993. readonly numTargets: number;
  22994. /**
  22995. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22996. */
  22997. readonly numInfluencers: number;
  22998. /**
  22999. * Gets the list of influences (one per target)
  23000. */
  23001. readonly influences: Float32Array;
  23002. /**
  23003. * Gets the active target at specified index. An active target is a target with an influence > 0
  23004. * @param index defines the index to check
  23005. * @returns the requested target
  23006. */
  23007. getActiveTarget(index: number): MorphTarget;
  23008. /**
  23009. * Gets the target at specified index
  23010. * @param index defines the index to check
  23011. * @returns the requested target
  23012. */
  23013. getTarget(index: number): MorphTarget;
  23014. /**
  23015. * Add a new target to this manager
  23016. * @param target defines the target to add
  23017. */
  23018. addTarget(target: MorphTarget): void;
  23019. /**
  23020. * Removes a target from the manager
  23021. * @param target defines the target to remove
  23022. */
  23023. removeTarget(target: MorphTarget): void;
  23024. /**
  23025. * Clone the current manager
  23026. * @returns a new MorphTargetManager
  23027. */
  23028. clone(): MorphTargetManager;
  23029. /**
  23030. * Serializes the current manager into a Serialization object
  23031. * @returns the serialized object
  23032. */
  23033. serialize(): any;
  23034. private _syncActiveTargets;
  23035. /**
  23036. * Syncrhonize the targets with all the meshes using this morph target manager
  23037. */
  23038. synchronize(): void;
  23039. /**
  23040. * Creates a new MorphTargetManager from serialized data
  23041. * @param serializationObject defines the serialized data
  23042. * @param scene defines the hosting scene
  23043. * @returns the new MorphTargetManager
  23044. */
  23045. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23046. }
  23047. }
  23048. declare module "babylonjs/Meshes/meshLODLevel" {
  23049. import { Mesh } from "babylonjs/Meshes/mesh";
  23050. import { Nullable } from "babylonjs/types";
  23051. /**
  23052. * Class used to represent a specific level of detail of a mesh
  23053. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23054. */
  23055. export class MeshLODLevel {
  23056. /** Defines the distance where this level should start being displayed */
  23057. distance: number;
  23058. /** Defines the mesh to use to render this level */
  23059. mesh: Nullable<Mesh>;
  23060. /**
  23061. * Creates a new LOD level
  23062. * @param distance defines the distance where this level should star being displayed
  23063. * @param mesh defines the mesh to use to render this level
  23064. */
  23065. constructor(
  23066. /** Defines the distance where this level should start being displayed */
  23067. distance: number,
  23068. /** Defines the mesh to use to render this level */
  23069. mesh: Nullable<Mesh>);
  23070. }
  23071. }
  23072. declare module "babylonjs/Meshes/groundMesh" {
  23073. import { Scene } from "babylonjs/scene";
  23074. import { Vector3 } from "babylonjs/Maths/math.vector";
  23075. import { Mesh } from "babylonjs/Meshes/mesh";
  23076. /**
  23077. * Mesh representing the gorund
  23078. */
  23079. export class GroundMesh extends Mesh {
  23080. /** If octree should be generated */
  23081. generateOctree: boolean;
  23082. private _heightQuads;
  23083. /** @hidden */
  23084. _subdivisionsX: number;
  23085. /** @hidden */
  23086. _subdivisionsY: number;
  23087. /** @hidden */
  23088. _width: number;
  23089. /** @hidden */
  23090. _height: number;
  23091. /** @hidden */
  23092. _minX: number;
  23093. /** @hidden */
  23094. _maxX: number;
  23095. /** @hidden */
  23096. _minZ: number;
  23097. /** @hidden */
  23098. _maxZ: number;
  23099. constructor(name: string, scene: Scene);
  23100. /**
  23101. * "GroundMesh"
  23102. * @returns "GroundMesh"
  23103. */
  23104. getClassName(): string;
  23105. /**
  23106. * The minimum of x and y subdivisions
  23107. */
  23108. readonly subdivisions: number;
  23109. /**
  23110. * X subdivisions
  23111. */
  23112. readonly subdivisionsX: number;
  23113. /**
  23114. * Y subdivisions
  23115. */
  23116. readonly subdivisionsY: number;
  23117. /**
  23118. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23119. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23120. * @param chunksCount the number of subdivisions for x and y
  23121. * @param octreeBlocksSize (Default: 32)
  23122. */
  23123. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23124. /**
  23125. * Returns a height (y) value in the Worl system :
  23126. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23127. * @param x x coordinate
  23128. * @param z z coordinate
  23129. * @returns the ground y position if (x, z) are outside the ground surface.
  23130. */
  23131. getHeightAtCoordinates(x: number, z: number): number;
  23132. /**
  23133. * Returns a normalized vector (Vector3) orthogonal to the ground
  23134. * at the ground coordinates (x, z) expressed in the World system.
  23135. * @param x x coordinate
  23136. * @param z z coordinate
  23137. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23138. */
  23139. getNormalAtCoordinates(x: number, z: number): Vector3;
  23140. /**
  23141. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23142. * at the ground coordinates (x, z) expressed in the World system.
  23143. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23144. * @param x x coordinate
  23145. * @param z z coordinate
  23146. * @param ref vector to store the result
  23147. * @returns the GroundMesh.
  23148. */
  23149. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23150. /**
  23151. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23152. * if the ground has been updated.
  23153. * This can be used in the render loop.
  23154. * @returns the GroundMesh.
  23155. */
  23156. updateCoordinateHeights(): GroundMesh;
  23157. private _getFacetAt;
  23158. private _initHeightQuads;
  23159. private _computeHeightQuads;
  23160. /**
  23161. * Serializes this ground mesh
  23162. * @param serializationObject object to write serialization to
  23163. */
  23164. serialize(serializationObject: any): void;
  23165. /**
  23166. * Parses a serialized ground mesh
  23167. * @param parsedMesh the serialized mesh
  23168. * @param scene the scene to create the ground mesh in
  23169. * @returns the created ground mesh
  23170. */
  23171. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23172. }
  23173. }
  23174. declare module "babylonjs/Physics/physicsJoint" {
  23175. import { Vector3 } from "babylonjs/Maths/math.vector";
  23176. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23177. /**
  23178. * Interface for Physics-Joint data
  23179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23180. */
  23181. export interface PhysicsJointData {
  23182. /**
  23183. * The main pivot of the joint
  23184. */
  23185. mainPivot?: Vector3;
  23186. /**
  23187. * The connected pivot of the joint
  23188. */
  23189. connectedPivot?: Vector3;
  23190. /**
  23191. * The main axis of the joint
  23192. */
  23193. mainAxis?: Vector3;
  23194. /**
  23195. * The connected axis of the joint
  23196. */
  23197. connectedAxis?: Vector3;
  23198. /**
  23199. * The collision of the joint
  23200. */
  23201. collision?: boolean;
  23202. /**
  23203. * Native Oimo/Cannon/Energy data
  23204. */
  23205. nativeParams?: any;
  23206. }
  23207. /**
  23208. * This is a holder class for the physics joint created by the physics plugin
  23209. * It holds a set of functions to control the underlying joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export class PhysicsJoint {
  23213. /**
  23214. * The type of the physics joint
  23215. */
  23216. type: number;
  23217. /**
  23218. * The data for the physics joint
  23219. */
  23220. jointData: PhysicsJointData;
  23221. private _physicsJoint;
  23222. protected _physicsPlugin: IPhysicsEnginePlugin;
  23223. /**
  23224. * Initializes the physics joint
  23225. * @param type The type of the physics joint
  23226. * @param jointData The data for the physics joint
  23227. */
  23228. constructor(
  23229. /**
  23230. * The type of the physics joint
  23231. */
  23232. type: number,
  23233. /**
  23234. * The data for the physics joint
  23235. */
  23236. jointData: PhysicsJointData);
  23237. /**
  23238. * Gets the physics joint
  23239. */
  23240. /**
  23241. * Sets the physics joint
  23242. */
  23243. physicsJoint: any;
  23244. /**
  23245. * Sets the physics plugin
  23246. */
  23247. physicsPlugin: IPhysicsEnginePlugin;
  23248. /**
  23249. * Execute a function that is physics-plugin specific.
  23250. * @param {Function} func the function that will be executed.
  23251. * It accepts two parameters: the physics world and the physics joint
  23252. */
  23253. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23254. /**
  23255. * Distance-Joint type
  23256. */
  23257. static DistanceJoint: number;
  23258. /**
  23259. * Hinge-Joint type
  23260. */
  23261. static HingeJoint: number;
  23262. /**
  23263. * Ball-and-Socket joint type
  23264. */
  23265. static BallAndSocketJoint: number;
  23266. /**
  23267. * Wheel-Joint type
  23268. */
  23269. static WheelJoint: number;
  23270. /**
  23271. * Slider-Joint type
  23272. */
  23273. static SliderJoint: number;
  23274. /**
  23275. * Prismatic-Joint type
  23276. */
  23277. static PrismaticJoint: number;
  23278. /**
  23279. * Universal-Joint type
  23280. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23281. */
  23282. static UniversalJoint: number;
  23283. /**
  23284. * Hinge-Joint 2 type
  23285. */
  23286. static Hinge2Joint: number;
  23287. /**
  23288. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23289. */
  23290. static PointToPointJoint: number;
  23291. /**
  23292. * Spring-Joint type
  23293. */
  23294. static SpringJoint: number;
  23295. /**
  23296. * Lock-Joint type
  23297. */
  23298. static LockJoint: number;
  23299. }
  23300. /**
  23301. * A class representing a physics distance joint
  23302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23303. */
  23304. export class DistanceJoint extends PhysicsJoint {
  23305. /**
  23306. *
  23307. * @param jointData The data for the Distance-Joint
  23308. */
  23309. constructor(jointData: DistanceJointData);
  23310. /**
  23311. * Update the predefined distance.
  23312. * @param maxDistance The maximum preferred distance
  23313. * @param minDistance The minimum preferred distance
  23314. */
  23315. updateDistance(maxDistance: number, minDistance?: number): void;
  23316. }
  23317. /**
  23318. * Represents a Motor-Enabled Joint
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23322. /**
  23323. * Initializes the Motor-Enabled Joint
  23324. * @param type The type of the joint
  23325. * @param jointData The physica joint data for the joint
  23326. */
  23327. constructor(type: number, jointData: PhysicsJointData);
  23328. /**
  23329. * Set the motor values.
  23330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23331. * @param force the force to apply
  23332. * @param maxForce max force for this motor.
  23333. */
  23334. setMotor(force?: number, maxForce?: number): void;
  23335. /**
  23336. * Set the motor's limits.
  23337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23338. * @param upperLimit The upper limit of the motor
  23339. * @param lowerLimit The lower limit of the motor
  23340. */
  23341. setLimit(upperLimit: number, lowerLimit?: number): void;
  23342. }
  23343. /**
  23344. * This class represents a single physics Hinge-Joint
  23345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23346. */
  23347. export class HingeJoint extends MotorEnabledJoint {
  23348. /**
  23349. * Initializes the Hinge-Joint
  23350. * @param jointData The joint data for the Hinge-Joint
  23351. */
  23352. constructor(jointData: PhysicsJointData);
  23353. /**
  23354. * Set the motor values.
  23355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23356. * @param {number} force the force to apply
  23357. * @param {number} maxForce max force for this motor.
  23358. */
  23359. setMotor(force?: number, maxForce?: number): void;
  23360. /**
  23361. * Set the motor's limits.
  23362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23363. * @param upperLimit The upper limit of the motor
  23364. * @param lowerLimit The lower limit of the motor
  23365. */
  23366. setLimit(upperLimit: number, lowerLimit?: number): void;
  23367. }
  23368. /**
  23369. * This class represents a dual hinge physics joint (same as wheel joint)
  23370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23371. */
  23372. export class Hinge2Joint extends MotorEnabledJoint {
  23373. /**
  23374. * Initializes the Hinge2-Joint
  23375. * @param jointData The joint data for the Hinge2-Joint
  23376. */
  23377. constructor(jointData: PhysicsJointData);
  23378. /**
  23379. * Set the motor values.
  23380. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23381. * @param {number} targetSpeed the speed the motor is to reach
  23382. * @param {number} maxForce max force for this motor.
  23383. * @param {motorIndex} the motor's index, 0 or 1.
  23384. */
  23385. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23386. /**
  23387. * Set the motor limits.
  23388. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23389. * @param {number} upperLimit the upper limit
  23390. * @param {number} lowerLimit lower limit
  23391. * @param {motorIndex} the motor's index, 0 or 1.
  23392. */
  23393. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23394. }
  23395. /**
  23396. * Interface for a motor enabled joint
  23397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23398. */
  23399. export interface IMotorEnabledJoint {
  23400. /**
  23401. * Physics joint
  23402. */
  23403. physicsJoint: any;
  23404. /**
  23405. * Sets the motor of the motor-enabled joint
  23406. * @param force The force of the motor
  23407. * @param maxForce The maximum force of the motor
  23408. * @param motorIndex The index of the motor
  23409. */
  23410. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23411. /**
  23412. * Sets the limit of the motor
  23413. * @param upperLimit The upper limit of the motor
  23414. * @param lowerLimit The lower limit of the motor
  23415. * @param motorIndex The index of the motor
  23416. */
  23417. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23418. }
  23419. /**
  23420. * Joint data for a Distance-Joint
  23421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23422. */
  23423. export interface DistanceJointData extends PhysicsJointData {
  23424. /**
  23425. * Max distance the 2 joint objects can be apart
  23426. */
  23427. maxDistance: number;
  23428. }
  23429. /**
  23430. * Joint data from a spring joint
  23431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23432. */
  23433. export interface SpringJointData extends PhysicsJointData {
  23434. /**
  23435. * Length of the spring
  23436. */
  23437. length: number;
  23438. /**
  23439. * Stiffness of the spring
  23440. */
  23441. stiffness: number;
  23442. /**
  23443. * Damping of the spring
  23444. */
  23445. damping: number;
  23446. /** this callback will be called when applying the force to the impostors. */
  23447. forceApplicationCallback: () => void;
  23448. }
  23449. }
  23450. declare module "babylonjs/Physics/physicsRaycastResult" {
  23451. import { Vector3 } from "babylonjs/Maths/math.vector";
  23452. /**
  23453. * Holds the data for the raycast result
  23454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23455. */
  23456. export class PhysicsRaycastResult {
  23457. private _hasHit;
  23458. private _hitDistance;
  23459. private _hitNormalWorld;
  23460. private _hitPointWorld;
  23461. private _rayFromWorld;
  23462. private _rayToWorld;
  23463. /**
  23464. * Gets if there was a hit
  23465. */
  23466. readonly hasHit: boolean;
  23467. /**
  23468. * Gets the distance from the hit
  23469. */
  23470. readonly hitDistance: number;
  23471. /**
  23472. * Gets the hit normal/direction in the world
  23473. */
  23474. readonly hitNormalWorld: Vector3;
  23475. /**
  23476. * Gets the hit point in the world
  23477. */
  23478. readonly hitPointWorld: Vector3;
  23479. /**
  23480. * Gets the ray "start point" of the ray in the world
  23481. */
  23482. readonly rayFromWorld: Vector3;
  23483. /**
  23484. * Gets the ray "end point" of the ray in the world
  23485. */
  23486. readonly rayToWorld: Vector3;
  23487. /**
  23488. * Sets the hit data (normal & point in world space)
  23489. * @param hitNormalWorld defines the normal in world space
  23490. * @param hitPointWorld defines the point in world space
  23491. */
  23492. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23493. /**
  23494. * Sets the distance from the start point to the hit point
  23495. * @param distance
  23496. */
  23497. setHitDistance(distance: number): void;
  23498. /**
  23499. * Calculates the distance manually
  23500. */
  23501. calculateHitDistance(): void;
  23502. /**
  23503. * Resets all the values to default
  23504. * @param from The from point on world space
  23505. * @param to The to point on world space
  23506. */
  23507. reset(from?: Vector3, to?: Vector3): void;
  23508. }
  23509. /**
  23510. * Interface for the size containing width and height
  23511. */
  23512. interface IXYZ {
  23513. /**
  23514. * X
  23515. */
  23516. x: number;
  23517. /**
  23518. * Y
  23519. */
  23520. y: number;
  23521. /**
  23522. * Z
  23523. */
  23524. z: number;
  23525. }
  23526. }
  23527. declare module "babylonjs/Physics/IPhysicsEngine" {
  23528. import { Nullable } from "babylonjs/types";
  23529. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23531. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23532. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23533. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23534. /**
  23535. * Interface used to describe a physics joint
  23536. */
  23537. export interface PhysicsImpostorJoint {
  23538. /** Defines the main impostor to which the joint is linked */
  23539. mainImpostor: PhysicsImpostor;
  23540. /** Defines the impostor that is connected to the main impostor using this joint */
  23541. connectedImpostor: PhysicsImpostor;
  23542. /** Defines the joint itself */
  23543. joint: PhysicsJoint;
  23544. }
  23545. /** @hidden */
  23546. export interface IPhysicsEnginePlugin {
  23547. world: any;
  23548. name: string;
  23549. setGravity(gravity: Vector3): void;
  23550. setTimeStep(timeStep: number): void;
  23551. getTimeStep(): number;
  23552. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23553. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23554. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23555. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23556. removePhysicsBody(impostor: PhysicsImpostor): void;
  23557. generateJoint(joint: PhysicsImpostorJoint): void;
  23558. removeJoint(joint: PhysicsImpostorJoint): void;
  23559. isSupported(): boolean;
  23560. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23561. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23562. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23563. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23564. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23565. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23566. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23567. getBodyMass(impostor: PhysicsImpostor): number;
  23568. getBodyFriction(impostor: PhysicsImpostor): number;
  23569. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23570. getBodyRestitution(impostor: PhysicsImpostor): number;
  23571. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23572. getBodyPressure?(impostor: PhysicsImpostor): number;
  23573. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23574. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23575. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23576. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23577. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23578. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23579. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23580. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23581. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23582. sleepBody(impostor: PhysicsImpostor): void;
  23583. wakeUpBody(impostor: PhysicsImpostor): void;
  23584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23585. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23586. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23587. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23588. getRadius(impostor: PhysicsImpostor): number;
  23589. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23590. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23591. dispose(): void;
  23592. }
  23593. /**
  23594. * Interface used to define a physics engine
  23595. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23596. */
  23597. export interface IPhysicsEngine {
  23598. /**
  23599. * Gets the gravity vector used by the simulation
  23600. */
  23601. gravity: Vector3;
  23602. /**
  23603. * Sets the gravity vector used by the simulation
  23604. * @param gravity defines the gravity vector to use
  23605. */
  23606. setGravity(gravity: Vector3): void;
  23607. /**
  23608. * Set the time step of the physics engine.
  23609. * Default is 1/60.
  23610. * To slow it down, enter 1/600 for example.
  23611. * To speed it up, 1/30
  23612. * @param newTimeStep the new timestep to apply to this world.
  23613. */
  23614. setTimeStep(newTimeStep: number): void;
  23615. /**
  23616. * Get the time step of the physics engine.
  23617. * @returns the current time step
  23618. */
  23619. getTimeStep(): number;
  23620. /**
  23621. * Release all resources
  23622. */
  23623. dispose(): void;
  23624. /**
  23625. * Gets the name of the current physics plugin
  23626. * @returns the name of the plugin
  23627. */
  23628. getPhysicsPluginName(): string;
  23629. /**
  23630. * Adding a new impostor for the impostor tracking.
  23631. * This will be done by the impostor itself.
  23632. * @param impostor the impostor to add
  23633. */
  23634. addImpostor(impostor: PhysicsImpostor): void;
  23635. /**
  23636. * Remove an impostor from the engine.
  23637. * This impostor and its mesh will not longer be updated by the physics engine.
  23638. * @param impostor the impostor to remove
  23639. */
  23640. removeImpostor(impostor: PhysicsImpostor): void;
  23641. /**
  23642. * Add a joint to the physics engine
  23643. * @param mainImpostor defines the main impostor to which the joint is added.
  23644. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23645. * @param joint defines the joint that will connect both impostors.
  23646. */
  23647. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23648. /**
  23649. * Removes a joint from the simulation
  23650. * @param mainImpostor defines the impostor used with the joint
  23651. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23652. * @param joint defines the joint to remove
  23653. */
  23654. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23655. /**
  23656. * Gets the current plugin used to run the simulation
  23657. * @returns current plugin
  23658. */
  23659. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23660. /**
  23661. * Gets the list of physic impostors
  23662. * @returns an array of PhysicsImpostor
  23663. */
  23664. getImpostors(): Array<PhysicsImpostor>;
  23665. /**
  23666. * Gets the impostor for a physics enabled object
  23667. * @param object defines the object impersonated by the impostor
  23668. * @returns the PhysicsImpostor or null if not found
  23669. */
  23670. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23671. /**
  23672. * Gets the impostor for a physics body object
  23673. * @param body defines physics body used by the impostor
  23674. * @returns the PhysicsImpostor or null if not found
  23675. */
  23676. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23677. /**
  23678. * Does a raycast in the physics world
  23679. * @param from when should the ray start?
  23680. * @param to when should the ray end?
  23681. * @returns PhysicsRaycastResult
  23682. */
  23683. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23684. /**
  23685. * Called by the scene. No need to call it.
  23686. * @param delta defines the timespam between frames
  23687. */
  23688. _step(delta: number): void;
  23689. }
  23690. }
  23691. declare module "babylonjs/Physics/physicsImpostor" {
  23692. import { Nullable, IndicesArray } from "babylonjs/types";
  23693. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23694. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23696. import { Scene } from "babylonjs/scene";
  23697. import { Bone } from "babylonjs/Bones/bone";
  23698. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23699. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23700. import { Space } from "babylonjs/Maths/math.axis";
  23701. /**
  23702. * The interface for the physics imposter parameters
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export interface PhysicsImpostorParameters {
  23706. /**
  23707. * The mass of the physics imposter
  23708. */
  23709. mass: number;
  23710. /**
  23711. * The friction of the physics imposter
  23712. */
  23713. friction?: number;
  23714. /**
  23715. * The coefficient of restitution of the physics imposter
  23716. */
  23717. restitution?: number;
  23718. /**
  23719. * The native options of the physics imposter
  23720. */
  23721. nativeOptions?: any;
  23722. /**
  23723. * Specifies if the parent should be ignored
  23724. */
  23725. ignoreParent?: boolean;
  23726. /**
  23727. * Specifies if bi-directional transformations should be disabled
  23728. */
  23729. disableBidirectionalTransformation?: boolean;
  23730. /**
  23731. * The pressure inside the physics imposter, soft object only
  23732. */
  23733. pressure?: number;
  23734. /**
  23735. * The stiffness the physics imposter, soft object only
  23736. */
  23737. stiffness?: number;
  23738. /**
  23739. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23740. */
  23741. velocityIterations?: number;
  23742. /**
  23743. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23744. */
  23745. positionIterations?: number;
  23746. /**
  23747. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23748. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23749. * Add to fix multiple points
  23750. */
  23751. fixedPoints?: number;
  23752. /**
  23753. * The collision margin around a soft object
  23754. */
  23755. margin?: number;
  23756. /**
  23757. * The collision margin around a soft object
  23758. */
  23759. damping?: number;
  23760. /**
  23761. * The path for a rope based on an extrusion
  23762. */
  23763. path?: any;
  23764. /**
  23765. * The shape of an extrusion used for a rope based on an extrusion
  23766. */
  23767. shape?: any;
  23768. }
  23769. /**
  23770. * Interface for a physics-enabled object
  23771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23772. */
  23773. export interface IPhysicsEnabledObject {
  23774. /**
  23775. * The position of the physics-enabled object
  23776. */
  23777. position: Vector3;
  23778. /**
  23779. * The rotation of the physics-enabled object
  23780. */
  23781. rotationQuaternion: Nullable<Quaternion>;
  23782. /**
  23783. * The scale of the physics-enabled object
  23784. */
  23785. scaling: Vector3;
  23786. /**
  23787. * The rotation of the physics-enabled object
  23788. */
  23789. rotation?: Vector3;
  23790. /**
  23791. * The parent of the physics-enabled object
  23792. */
  23793. parent?: any;
  23794. /**
  23795. * The bounding info of the physics-enabled object
  23796. * @returns The bounding info of the physics-enabled object
  23797. */
  23798. getBoundingInfo(): BoundingInfo;
  23799. /**
  23800. * Computes the world matrix
  23801. * @param force Specifies if the world matrix should be computed by force
  23802. * @returns A world matrix
  23803. */
  23804. computeWorldMatrix(force: boolean): Matrix;
  23805. /**
  23806. * Gets the world matrix
  23807. * @returns A world matrix
  23808. */
  23809. getWorldMatrix?(): Matrix;
  23810. /**
  23811. * Gets the child meshes
  23812. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23813. * @returns An array of abstract meshes
  23814. */
  23815. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23816. /**
  23817. * Gets the vertex data
  23818. * @param kind The type of vertex data
  23819. * @returns A nullable array of numbers, or a float32 array
  23820. */
  23821. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23822. /**
  23823. * Gets the indices from the mesh
  23824. * @returns A nullable array of index arrays
  23825. */
  23826. getIndices?(): Nullable<IndicesArray>;
  23827. /**
  23828. * Gets the scene from the mesh
  23829. * @returns the indices array or null
  23830. */
  23831. getScene?(): Scene;
  23832. /**
  23833. * Gets the absolute position from the mesh
  23834. * @returns the absolute position
  23835. */
  23836. getAbsolutePosition(): Vector3;
  23837. /**
  23838. * Gets the absolute pivot point from the mesh
  23839. * @returns the absolute pivot point
  23840. */
  23841. getAbsolutePivotPoint(): Vector3;
  23842. /**
  23843. * Rotates the mesh
  23844. * @param axis The axis of rotation
  23845. * @param amount The amount of rotation
  23846. * @param space The space of the rotation
  23847. * @returns The rotation transform node
  23848. */
  23849. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23850. /**
  23851. * Translates the mesh
  23852. * @param axis The axis of translation
  23853. * @param distance The distance of translation
  23854. * @param space The space of the translation
  23855. * @returns The transform node
  23856. */
  23857. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23858. /**
  23859. * Sets the absolute position of the mesh
  23860. * @param absolutePosition The absolute position of the mesh
  23861. * @returns The transform node
  23862. */
  23863. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23864. /**
  23865. * Gets the class name of the mesh
  23866. * @returns The class name
  23867. */
  23868. getClassName(): string;
  23869. }
  23870. /**
  23871. * Represents a physics imposter
  23872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23873. */
  23874. export class PhysicsImpostor {
  23875. /**
  23876. * The physics-enabled object used as the physics imposter
  23877. */
  23878. object: IPhysicsEnabledObject;
  23879. /**
  23880. * The type of the physics imposter
  23881. */
  23882. type: number;
  23883. private _options;
  23884. private _scene?;
  23885. /**
  23886. * The default object size of the imposter
  23887. */
  23888. static DEFAULT_OBJECT_SIZE: Vector3;
  23889. /**
  23890. * The identity quaternion of the imposter
  23891. */
  23892. static IDENTITY_QUATERNION: Quaternion;
  23893. /** @hidden */
  23894. _pluginData: any;
  23895. private _physicsEngine;
  23896. private _physicsBody;
  23897. private _bodyUpdateRequired;
  23898. private _onBeforePhysicsStepCallbacks;
  23899. private _onAfterPhysicsStepCallbacks;
  23900. /** @hidden */
  23901. _onPhysicsCollideCallbacks: Array<{
  23902. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23903. otherImpostors: Array<PhysicsImpostor>;
  23904. }>;
  23905. private _deltaPosition;
  23906. private _deltaRotation;
  23907. private _deltaRotationConjugated;
  23908. /** @hidden */
  23909. _isFromLine: boolean;
  23910. private _parent;
  23911. private _isDisposed;
  23912. private static _tmpVecs;
  23913. private static _tmpQuat;
  23914. /**
  23915. * Specifies if the physics imposter is disposed
  23916. */
  23917. readonly isDisposed: boolean;
  23918. /**
  23919. * Gets the mass of the physics imposter
  23920. */
  23921. mass: number;
  23922. /**
  23923. * Gets the coefficient of friction
  23924. */
  23925. /**
  23926. * Sets the coefficient of friction
  23927. */
  23928. friction: number;
  23929. /**
  23930. * Gets the coefficient of restitution
  23931. */
  23932. /**
  23933. * Sets the coefficient of restitution
  23934. */
  23935. restitution: number;
  23936. /**
  23937. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23938. */
  23939. /**
  23940. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23941. */
  23942. pressure: number;
  23943. /**
  23944. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23945. */
  23946. /**
  23947. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23948. */
  23949. stiffness: number;
  23950. /**
  23951. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23952. */
  23953. /**
  23954. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23955. */
  23956. velocityIterations: number;
  23957. /**
  23958. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23959. */
  23960. /**
  23961. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23962. */
  23963. positionIterations: number;
  23964. /**
  23965. * The unique id of the physics imposter
  23966. * set by the physics engine when adding this impostor to the array
  23967. */
  23968. uniqueId: number;
  23969. /**
  23970. * @hidden
  23971. */
  23972. soft: boolean;
  23973. /**
  23974. * @hidden
  23975. */
  23976. segments: number;
  23977. private _joints;
  23978. /**
  23979. * Initializes the physics imposter
  23980. * @param object The physics-enabled object used as the physics imposter
  23981. * @param type The type of the physics imposter
  23982. * @param _options The options for the physics imposter
  23983. * @param _scene The Babylon scene
  23984. */
  23985. constructor(
  23986. /**
  23987. * The physics-enabled object used as the physics imposter
  23988. */
  23989. object: IPhysicsEnabledObject,
  23990. /**
  23991. * The type of the physics imposter
  23992. */
  23993. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23994. /**
  23995. * This function will completly initialize this impostor.
  23996. * It will create a new body - but only if this mesh has no parent.
  23997. * If it has, this impostor will not be used other than to define the impostor
  23998. * of the child mesh.
  23999. * @hidden
  24000. */
  24001. _init(): void;
  24002. private _getPhysicsParent;
  24003. /**
  24004. * Should a new body be generated.
  24005. * @returns boolean specifying if body initialization is required
  24006. */
  24007. isBodyInitRequired(): boolean;
  24008. /**
  24009. * Sets the updated scaling
  24010. * @param updated Specifies if the scaling is updated
  24011. */
  24012. setScalingUpdated(): void;
  24013. /**
  24014. * Force a regeneration of this or the parent's impostor's body.
  24015. * Use under cautious - This will remove all joints already implemented.
  24016. */
  24017. forceUpdate(): void;
  24018. /**
  24019. * Gets the body that holds this impostor. Either its own, or its parent.
  24020. */
  24021. /**
  24022. * Set the physics body. Used mainly by the physics engine/plugin
  24023. */
  24024. physicsBody: any;
  24025. /**
  24026. * Get the parent of the physics imposter
  24027. * @returns Physics imposter or null
  24028. */
  24029. /**
  24030. * Sets the parent of the physics imposter
  24031. */
  24032. parent: Nullable<PhysicsImpostor>;
  24033. /**
  24034. * Resets the update flags
  24035. */
  24036. resetUpdateFlags(): void;
  24037. /**
  24038. * Gets the object extend size
  24039. * @returns the object extend size
  24040. */
  24041. getObjectExtendSize(): Vector3;
  24042. /**
  24043. * Gets the object center
  24044. * @returns The object center
  24045. */
  24046. getObjectCenter(): Vector3;
  24047. /**
  24048. * Get a specific parametes from the options parameter
  24049. * @param paramName The object parameter name
  24050. * @returns The object parameter
  24051. */
  24052. getParam(paramName: string): any;
  24053. /**
  24054. * Sets a specific parameter in the options given to the physics plugin
  24055. * @param paramName The parameter name
  24056. * @param value The value of the parameter
  24057. */
  24058. setParam(paramName: string, value: number): void;
  24059. /**
  24060. * Specifically change the body's mass option. Won't recreate the physics body object
  24061. * @param mass The mass of the physics imposter
  24062. */
  24063. setMass(mass: number): void;
  24064. /**
  24065. * Gets the linear velocity
  24066. * @returns linear velocity or null
  24067. */
  24068. getLinearVelocity(): Nullable<Vector3>;
  24069. /**
  24070. * Sets the linear velocity
  24071. * @param velocity linear velocity or null
  24072. */
  24073. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24074. /**
  24075. * Gets the angular velocity
  24076. * @returns angular velocity or null
  24077. */
  24078. getAngularVelocity(): Nullable<Vector3>;
  24079. /**
  24080. * Sets the angular velocity
  24081. * @param velocity The velocity or null
  24082. */
  24083. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24084. /**
  24085. * Execute a function with the physics plugin native code
  24086. * Provide a function the will have two variables - the world object and the physics body object
  24087. * @param func The function to execute with the physics plugin native code
  24088. */
  24089. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24090. /**
  24091. * Register a function that will be executed before the physics world is stepping forward
  24092. * @param func The function to execute before the physics world is stepped forward
  24093. */
  24094. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24095. /**
  24096. * Unregister a function that will be executed before the physics world is stepping forward
  24097. * @param func The function to execute before the physics world is stepped forward
  24098. */
  24099. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24100. /**
  24101. * Register a function that will be executed after the physics step
  24102. * @param func The function to execute after physics step
  24103. */
  24104. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24105. /**
  24106. * Unregisters a function that will be executed after the physics step
  24107. * @param func The function to execute after physics step
  24108. */
  24109. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24110. /**
  24111. * register a function that will be executed when this impostor collides against a different body
  24112. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24113. * @param func Callback that is executed on collision
  24114. */
  24115. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24116. /**
  24117. * Unregisters the physics imposter on contact
  24118. * @param collideAgainst The physics object to collide against
  24119. * @param func Callback to execute on collision
  24120. */
  24121. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24122. private _tmpQuat;
  24123. private _tmpQuat2;
  24124. /**
  24125. * Get the parent rotation
  24126. * @returns The parent rotation
  24127. */
  24128. getParentsRotation(): Quaternion;
  24129. /**
  24130. * this function is executed by the physics engine.
  24131. */
  24132. beforeStep: () => void;
  24133. /**
  24134. * this function is executed by the physics engine
  24135. */
  24136. afterStep: () => void;
  24137. /**
  24138. * Legacy collision detection event support
  24139. */
  24140. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24141. /**
  24142. * event and body object due to cannon's event-based architecture.
  24143. */
  24144. onCollide: (e: {
  24145. body: any;
  24146. }) => void;
  24147. /**
  24148. * Apply a force
  24149. * @param force The force to apply
  24150. * @param contactPoint The contact point for the force
  24151. * @returns The physics imposter
  24152. */
  24153. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24154. /**
  24155. * Apply an impulse
  24156. * @param force The impulse force
  24157. * @param contactPoint The contact point for the impulse force
  24158. * @returns The physics imposter
  24159. */
  24160. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24161. /**
  24162. * A help function to create a joint
  24163. * @param otherImpostor A physics imposter used to create a joint
  24164. * @param jointType The type of joint
  24165. * @param jointData The data for the joint
  24166. * @returns The physics imposter
  24167. */
  24168. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24169. /**
  24170. * Add a joint to this impostor with a different impostor
  24171. * @param otherImpostor A physics imposter used to add a joint
  24172. * @param joint The joint to add
  24173. * @returns The physics imposter
  24174. */
  24175. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24176. /**
  24177. * Add an anchor to a cloth impostor
  24178. * @param otherImpostor rigid impostor to anchor to
  24179. * @param width ratio across width from 0 to 1
  24180. * @param height ratio up height from 0 to 1
  24181. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24182. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24183. * @returns impostor the soft imposter
  24184. */
  24185. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24186. /**
  24187. * Add a hook to a rope impostor
  24188. * @param otherImpostor rigid impostor to anchor to
  24189. * @param length ratio across rope from 0 to 1
  24190. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24191. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24192. * @returns impostor the rope imposter
  24193. */
  24194. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24195. /**
  24196. * Will keep this body still, in a sleep mode.
  24197. * @returns the physics imposter
  24198. */
  24199. sleep(): PhysicsImpostor;
  24200. /**
  24201. * Wake the body up.
  24202. * @returns The physics imposter
  24203. */
  24204. wakeUp(): PhysicsImpostor;
  24205. /**
  24206. * Clones the physics imposter
  24207. * @param newObject The physics imposter clones to this physics-enabled object
  24208. * @returns A nullable physics imposter
  24209. */
  24210. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24211. /**
  24212. * Disposes the physics imposter
  24213. */
  24214. dispose(): void;
  24215. /**
  24216. * Sets the delta position
  24217. * @param position The delta position amount
  24218. */
  24219. setDeltaPosition(position: Vector3): void;
  24220. /**
  24221. * Sets the delta rotation
  24222. * @param rotation The delta rotation amount
  24223. */
  24224. setDeltaRotation(rotation: Quaternion): void;
  24225. /**
  24226. * Gets the box size of the physics imposter and stores the result in the input parameter
  24227. * @param result Stores the box size
  24228. * @returns The physics imposter
  24229. */
  24230. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24231. /**
  24232. * Gets the radius of the physics imposter
  24233. * @returns Radius of the physics imposter
  24234. */
  24235. getRadius(): number;
  24236. /**
  24237. * Sync a bone with this impostor
  24238. * @param bone The bone to sync to the impostor.
  24239. * @param boneMesh The mesh that the bone is influencing.
  24240. * @param jointPivot The pivot of the joint / bone in local space.
  24241. * @param distToJoint Optional distance from the impostor to the joint.
  24242. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24243. */
  24244. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24245. /**
  24246. * Sync impostor to a bone
  24247. * @param bone The bone that the impostor will be synced to.
  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. * @param boneAxis Optional vector3 axis the bone is aligned with
  24253. */
  24254. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24255. /**
  24256. * No-Imposter type
  24257. */
  24258. static NoImpostor: number;
  24259. /**
  24260. * Sphere-Imposter type
  24261. */
  24262. static SphereImpostor: number;
  24263. /**
  24264. * Box-Imposter type
  24265. */
  24266. static BoxImpostor: number;
  24267. /**
  24268. * Plane-Imposter type
  24269. */
  24270. static PlaneImpostor: number;
  24271. /**
  24272. * Mesh-imposter type
  24273. */
  24274. static MeshImpostor: number;
  24275. /**
  24276. * Capsule-Impostor type (Ammo.js plugin only)
  24277. */
  24278. static CapsuleImpostor: number;
  24279. /**
  24280. * Cylinder-Imposter type
  24281. */
  24282. static CylinderImpostor: number;
  24283. /**
  24284. * Particle-Imposter type
  24285. */
  24286. static ParticleImpostor: number;
  24287. /**
  24288. * Heightmap-Imposter type
  24289. */
  24290. static HeightmapImpostor: number;
  24291. /**
  24292. * ConvexHull-Impostor type (Ammo.js plugin only)
  24293. */
  24294. static ConvexHullImpostor: number;
  24295. /**
  24296. * Rope-Imposter type
  24297. */
  24298. static RopeImpostor: number;
  24299. /**
  24300. * Cloth-Imposter type
  24301. */
  24302. static ClothImpostor: number;
  24303. /**
  24304. * Softbody-Imposter type
  24305. */
  24306. static SoftbodyImpostor: number;
  24307. }
  24308. }
  24309. declare module "babylonjs/Meshes/mesh" {
  24310. import { Observable } from "babylonjs/Misc/observable";
  24311. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24312. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24313. import { Camera } from "babylonjs/Cameras/camera";
  24314. import { Scene } from "babylonjs/scene";
  24315. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24316. import { Color4 } from "babylonjs/Maths/math.color";
  24317. import { Engine } from "babylonjs/Engines/engine";
  24318. import { Node } from "babylonjs/node";
  24319. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24320. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24321. import { Buffer } from "babylonjs/Meshes/buffer";
  24322. import { Geometry } from "babylonjs/Meshes/geometry";
  24323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24325. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24326. import { Effect } from "babylonjs/Materials/effect";
  24327. import { Material } from "babylonjs/Materials/material";
  24328. import { Skeleton } from "babylonjs/Bones/skeleton";
  24329. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24330. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24331. import { Path3D } from "babylonjs/Maths/math.path";
  24332. import { Plane } from "babylonjs/Maths/math.plane";
  24333. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24334. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24335. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24336. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24337. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24338. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24339. /**
  24340. * @hidden
  24341. **/
  24342. export class _CreationDataStorage {
  24343. closePath?: boolean;
  24344. closeArray?: boolean;
  24345. idx: number[];
  24346. dashSize: number;
  24347. gapSize: number;
  24348. path3D: Path3D;
  24349. pathArray: Vector3[][];
  24350. arc: number;
  24351. radius: number;
  24352. cap: number;
  24353. tessellation: number;
  24354. }
  24355. /**
  24356. * @hidden
  24357. **/
  24358. class _InstanceDataStorage {
  24359. visibleInstances: any;
  24360. batchCache: _InstancesBatch;
  24361. instancesBufferSize: number;
  24362. instancesBuffer: Nullable<Buffer>;
  24363. instancesData: Float32Array;
  24364. overridenInstanceCount: number;
  24365. isFrozen: boolean;
  24366. previousBatch: Nullable<_InstancesBatch>;
  24367. hardwareInstancedRendering: boolean;
  24368. sideOrientation: number;
  24369. }
  24370. /**
  24371. * @hidden
  24372. **/
  24373. export class _InstancesBatch {
  24374. mustReturn: boolean;
  24375. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24376. renderSelf: boolean[];
  24377. hardwareInstancedRendering: boolean[];
  24378. }
  24379. /**
  24380. * Class used to represent renderable models
  24381. */
  24382. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24383. /**
  24384. * Mesh side orientation : usually the external or front surface
  24385. */
  24386. static readonly FRONTSIDE: number;
  24387. /**
  24388. * Mesh side orientation : usually the internal or back surface
  24389. */
  24390. static readonly BACKSIDE: number;
  24391. /**
  24392. * Mesh side orientation : both internal and external or front and back surfaces
  24393. */
  24394. static readonly DOUBLESIDE: number;
  24395. /**
  24396. * Mesh side orientation : by default, `FRONTSIDE`
  24397. */
  24398. static readonly DEFAULTSIDE: number;
  24399. /**
  24400. * Mesh cap setting : no cap
  24401. */
  24402. static readonly NO_CAP: number;
  24403. /**
  24404. * Mesh cap setting : one cap at the beginning of the mesh
  24405. */
  24406. static readonly CAP_START: number;
  24407. /**
  24408. * Mesh cap setting : one cap at the end of the mesh
  24409. */
  24410. static readonly CAP_END: number;
  24411. /**
  24412. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24413. */
  24414. static readonly CAP_ALL: number;
  24415. /**
  24416. * Mesh pattern setting : no flip or rotate
  24417. */
  24418. static readonly NO_FLIP: number;
  24419. /**
  24420. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24421. */
  24422. static readonly FLIP_TILE: number;
  24423. /**
  24424. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24425. */
  24426. static readonly ROTATE_TILE: number;
  24427. /**
  24428. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24429. */
  24430. static readonly FLIP_ROW: number;
  24431. /**
  24432. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24433. */
  24434. static readonly ROTATE_ROW: number;
  24435. /**
  24436. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24437. */
  24438. static readonly FLIP_N_ROTATE_TILE: number;
  24439. /**
  24440. * Mesh pattern setting : rotate pattern and rotate
  24441. */
  24442. static readonly FLIP_N_ROTATE_ROW: number;
  24443. /**
  24444. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24445. */
  24446. static readonly CENTER: number;
  24447. /**
  24448. * Mesh tile positioning : part tiles on left
  24449. */
  24450. static readonly LEFT: number;
  24451. /**
  24452. * Mesh tile positioning : part tiles on right
  24453. */
  24454. static readonly RIGHT: number;
  24455. /**
  24456. * Mesh tile positioning : part tiles on top
  24457. */
  24458. static readonly TOP: number;
  24459. /**
  24460. * Mesh tile positioning : part tiles on bottom
  24461. */
  24462. static readonly BOTTOM: number;
  24463. /**
  24464. * Gets the default side orientation.
  24465. * @param orientation the orientation to value to attempt to get
  24466. * @returns the default orientation
  24467. * @hidden
  24468. */
  24469. static _GetDefaultSideOrientation(orientation?: number): number;
  24470. private _internalMeshDataInfo;
  24471. /**
  24472. * An event triggered before rendering the mesh
  24473. */
  24474. readonly onBeforeRenderObservable: Observable<Mesh>;
  24475. /**
  24476. * An event triggered before binding the mesh
  24477. */
  24478. readonly onBeforeBindObservable: Observable<Mesh>;
  24479. /**
  24480. * An event triggered after rendering the mesh
  24481. */
  24482. readonly onAfterRenderObservable: Observable<Mesh>;
  24483. /**
  24484. * An event triggered before drawing the mesh
  24485. */
  24486. readonly onBeforeDrawObservable: Observable<Mesh>;
  24487. private _onBeforeDrawObserver;
  24488. /**
  24489. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24490. */
  24491. onBeforeDraw: () => void;
  24492. readonly hasInstances: boolean;
  24493. /**
  24494. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24495. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24496. */
  24497. delayLoadState: number;
  24498. /**
  24499. * Gets the list of instances created from this mesh
  24500. * it is not supposed to be modified manually.
  24501. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24502. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24503. */
  24504. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24505. /**
  24506. * Gets the file containing delay loading data for this mesh
  24507. */
  24508. delayLoadingFile: string;
  24509. /** @hidden */
  24510. _binaryInfo: any;
  24511. /**
  24512. * User defined function used to change how LOD level selection is done
  24513. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24514. */
  24515. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24516. /**
  24517. * Gets or sets the morph target manager
  24518. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24519. */
  24520. morphTargetManager: Nullable<MorphTargetManager>;
  24521. /** @hidden */
  24522. _creationDataStorage: Nullable<_CreationDataStorage>;
  24523. /** @hidden */
  24524. _geometry: Nullable<Geometry>;
  24525. /** @hidden */
  24526. _delayInfo: Array<string>;
  24527. /** @hidden */
  24528. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24529. /** @hidden */
  24530. _instanceDataStorage: _InstanceDataStorage;
  24531. private _effectiveMaterial;
  24532. /** @hidden */
  24533. _shouldGenerateFlatShading: boolean;
  24534. /** @hidden */
  24535. _originalBuilderSideOrientation: number;
  24536. /**
  24537. * Use this property to change the original side orientation defined at construction time
  24538. */
  24539. overrideMaterialSideOrientation: Nullable<number>;
  24540. /**
  24541. * Gets the source mesh (the one used to clone this one from)
  24542. */
  24543. readonly source: Nullable<Mesh>;
  24544. /**
  24545. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24546. */
  24547. isUnIndexed: boolean;
  24548. /**
  24549. * @constructor
  24550. * @param name The value used by scene.getMeshByName() to do a lookup.
  24551. * @param scene The scene to add this mesh to.
  24552. * @param parent The parent of this mesh, if it has one
  24553. * @param source An optional Mesh from which geometry is shared, cloned.
  24554. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24555. * When false, achieved by calling a clone(), also passing False.
  24556. * This will make creation of children, recursive.
  24557. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24558. */
  24559. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24560. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24561. doNotInstantiate: boolean;
  24562. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24563. /**
  24564. * Gets the class name
  24565. * @returns the string "Mesh".
  24566. */
  24567. getClassName(): string;
  24568. /** @hidden */
  24569. readonly _isMesh: boolean;
  24570. /**
  24571. * Returns a description of this mesh
  24572. * @param fullDetails define if full details about this mesh must be used
  24573. * @returns a descriptive string representing this mesh
  24574. */
  24575. toString(fullDetails?: boolean): string;
  24576. /** @hidden */
  24577. _unBindEffect(): void;
  24578. /**
  24579. * Gets a boolean indicating if this mesh has LOD
  24580. */
  24581. readonly hasLODLevels: boolean;
  24582. /**
  24583. * Gets the list of MeshLODLevel associated with the current mesh
  24584. * @returns an array of MeshLODLevel
  24585. */
  24586. getLODLevels(): MeshLODLevel[];
  24587. private _sortLODLevels;
  24588. /**
  24589. * Add a mesh as LOD level triggered at the given distance.
  24590. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24591. * @param distance The distance from the center of the object to show this level
  24592. * @param mesh The mesh to be added as LOD level (can be null)
  24593. * @return This mesh (for chaining)
  24594. */
  24595. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24596. /**
  24597. * Returns the LOD level mesh at the passed distance or null if not found.
  24598. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24599. * @param distance The distance from the center of the object to show this level
  24600. * @returns a Mesh or `null`
  24601. */
  24602. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24603. /**
  24604. * Remove a mesh from the LOD array
  24605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24606. * @param mesh defines the mesh to be removed
  24607. * @return This mesh (for chaining)
  24608. */
  24609. removeLODLevel(mesh: Mesh): Mesh;
  24610. /**
  24611. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24613. * @param camera defines the camera to use to compute distance
  24614. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24615. * @return This mesh (for chaining)
  24616. */
  24617. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24618. /**
  24619. * Gets the mesh internal Geometry object
  24620. */
  24621. readonly geometry: Nullable<Geometry>;
  24622. /**
  24623. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24624. * @returns the total number of vertices
  24625. */
  24626. getTotalVertices(): number;
  24627. /**
  24628. * Returns the content of an associated vertex buffer
  24629. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24630. * - VertexBuffer.PositionKind
  24631. * - VertexBuffer.UVKind
  24632. * - VertexBuffer.UV2Kind
  24633. * - VertexBuffer.UV3Kind
  24634. * - VertexBuffer.UV4Kind
  24635. * - VertexBuffer.UV5Kind
  24636. * - VertexBuffer.UV6Kind
  24637. * - VertexBuffer.ColorKind
  24638. * - VertexBuffer.MatricesIndicesKind
  24639. * - VertexBuffer.MatricesIndicesExtraKind
  24640. * - VertexBuffer.MatricesWeightsKind
  24641. * - VertexBuffer.MatricesWeightsExtraKind
  24642. * @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
  24643. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24644. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24645. */
  24646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24647. /**
  24648. * Returns the mesh VertexBuffer object from the requested `kind`
  24649. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24650. * - VertexBuffer.PositionKind
  24651. * - VertexBuffer.NormalKind
  24652. * - VertexBuffer.UVKind
  24653. * - VertexBuffer.UV2Kind
  24654. * - VertexBuffer.UV3Kind
  24655. * - VertexBuffer.UV4Kind
  24656. * - VertexBuffer.UV5Kind
  24657. * - VertexBuffer.UV6Kind
  24658. * - VertexBuffer.ColorKind
  24659. * - VertexBuffer.MatricesIndicesKind
  24660. * - VertexBuffer.MatricesIndicesExtraKind
  24661. * - VertexBuffer.MatricesWeightsKind
  24662. * - VertexBuffer.MatricesWeightsExtraKind
  24663. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24664. */
  24665. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24666. /**
  24667. * Tests if a specific vertex buffer is associated with this mesh
  24668. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24669. * - VertexBuffer.PositionKind
  24670. * - VertexBuffer.NormalKind
  24671. * - VertexBuffer.UVKind
  24672. * - VertexBuffer.UV2Kind
  24673. * - VertexBuffer.UV3Kind
  24674. * - VertexBuffer.UV4Kind
  24675. * - VertexBuffer.UV5Kind
  24676. * - VertexBuffer.UV6Kind
  24677. * - VertexBuffer.ColorKind
  24678. * - VertexBuffer.MatricesIndicesKind
  24679. * - VertexBuffer.MatricesIndicesExtraKind
  24680. * - VertexBuffer.MatricesWeightsKind
  24681. * - VertexBuffer.MatricesWeightsExtraKind
  24682. * @returns a boolean
  24683. */
  24684. isVerticesDataPresent(kind: string): boolean;
  24685. /**
  24686. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24687. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24688. * - VertexBuffer.PositionKind
  24689. * - VertexBuffer.UVKind
  24690. * - VertexBuffer.UV2Kind
  24691. * - VertexBuffer.UV3Kind
  24692. * - VertexBuffer.UV4Kind
  24693. * - VertexBuffer.UV5Kind
  24694. * - VertexBuffer.UV6Kind
  24695. * - VertexBuffer.ColorKind
  24696. * - VertexBuffer.MatricesIndicesKind
  24697. * - VertexBuffer.MatricesIndicesExtraKind
  24698. * - VertexBuffer.MatricesWeightsKind
  24699. * - VertexBuffer.MatricesWeightsExtraKind
  24700. * @returns a boolean
  24701. */
  24702. isVertexBufferUpdatable(kind: string): boolean;
  24703. /**
  24704. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24705. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24706. * - VertexBuffer.PositionKind
  24707. * - VertexBuffer.NormalKind
  24708. * - VertexBuffer.UVKind
  24709. * - VertexBuffer.UV2Kind
  24710. * - VertexBuffer.UV3Kind
  24711. * - VertexBuffer.UV4Kind
  24712. * - VertexBuffer.UV5Kind
  24713. * - VertexBuffer.UV6Kind
  24714. * - VertexBuffer.ColorKind
  24715. * - VertexBuffer.MatricesIndicesKind
  24716. * - VertexBuffer.MatricesIndicesExtraKind
  24717. * - VertexBuffer.MatricesWeightsKind
  24718. * - VertexBuffer.MatricesWeightsExtraKind
  24719. * @returns an array of strings
  24720. */
  24721. getVerticesDataKinds(): string[];
  24722. /**
  24723. * Returns a positive integer : the total number of indices in this mesh geometry.
  24724. * @returns the numner of indices or zero if the mesh has no geometry.
  24725. */
  24726. getTotalIndices(): number;
  24727. /**
  24728. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24729. * @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.
  24730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24731. * @returns the indices array or an empty array if the mesh has no geometry
  24732. */
  24733. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24734. readonly isBlocked: boolean;
  24735. /**
  24736. * Determine if the current mesh is ready to be rendered
  24737. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24738. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24739. * @returns true if all associated assets are ready (material, textures, shaders)
  24740. */
  24741. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24742. /**
  24743. * 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.
  24744. */
  24745. readonly areNormalsFrozen: boolean;
  24746. /**
  24747. * 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.
  24748. * @returns the current mesh
  24749. */
  24750. freezeNormals(): Mesh;
  24751. /**
  24752. * 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
  24753. * @returns the current mesh
  24754. */
  24755. unfreezeNormals(): Mesh;
  24756. /**
  24757. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24758. */
  24759. overridenInstanceCount: number;
  24760. /** @hidden */
  24761. _preActivate(): Mesh;
  24762. /** @hidden */
  24763. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24764. /** @hidden */
  24765. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24766. /**
  24767. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24768. * This means the mesh underlying bounding box and sphere are recomputed.
  24769. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24770. * @returns the current mesh
  24771. */
  24772. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24773. /** @hidden */
  24774. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24775. /**
  24776. * This function will subdivide the mesh into multiple submeshes
  24777. * @param count defines the expected number of submeshes
  24778. */
  24779. subdivide(count: number): void;
  24780. /**
  24781. * Copy a FloatArray into a specific associated vertex buffer
  24782. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24783. * - VertexBuffer.PositionKind
  24784. * - VertexBuffer.UVKind
  24785. * - VertexBuffer.UV2Kind
  24786. * - VertexBuffer.UV3Kind
  24787. * - VertexBuffer.UV4Kind
  24788. * - VertexBuffer.UV5Kind
  24789. * - VertexBuffer.UV6Kind
  24790. * - VertexBuffer.ColorKind
  24791. * - VertexBuffer.MatricesIndicesKind
  24792. * - VertexBuffer.MatricesIndicesExtraKind
  24793. * - VertexBuffer.MatricesWeightsKind
  24794. * - VertexBuffer.MatricesWeightsExtraKind
  24795. * @param data defines the data source
  24796. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24797. * @param stride defines the data stride size (can be null)
  24798. * @returns the current mesh
  24799. */
  24800. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24801. /**
  24802. * Delete a vertex buffer associated with this mesh
  24803. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. */
  24817. removeVerticesData(kind: string): void;
  24818. /**
  24819. * Flags an associated vertex buffer as updatable
  24820. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24821. * - VertexBuffer.PositionKind
  24822. * - VertexBuffer.UVKind
  24823. * - VertexBuffer.UV2Kind
  24824. * - VertexBuffer.UV3Kind
  24825. * - VertexBuffer.UV4Kind
  24826. * - VertexBuffer.UV5Kind
  24827. * - VertexBuffer.UV6Kind
  24828. * - VertexBuffer.ColorKind
  24829. * - VertexBuffer.MatricesIndicesKind
  24830. * - VertexBuffer.MatricesIndicesExtraKind
  24831. * - VertexBuffer.MatricesWeightsKind
  24832. * - VertexBuffer.MatricesWeightsExtraKind
  24833. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24834. */
  24835. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24836. /**
  24837. * Sets the mesh global Vertex Buffer
  24838. * @param buffer defines the buffer to use
  24839. * @returns the current mesh
  24840. */
  24841. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24842. /**
  24843. * Update a specific associated vertex buffer
  24844. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24845. * - VertexBuffer.PositionKind
  24846. * - VertexBuffer.UVKind
  24847. * - VertexBuffer.UV2Kind
  24848. * - VertexBuffer.UV3Kind
  24849. * - VertexBuffer.UV4Kind
  24850. * - VertexBuffer.UV5Kind
  24851. * - VertexBuffer.UV6Kind
  24852. * - VertexBuffer.ColorKind
  24853. * - VertexBuffer.MatricesIndicesKind
  24854. * - VertexBuffer.MatricesIndicesExtraKind
  24855. * - VertexBuffer.MatricesWeightsKind
  24856. * - VertexBuffer.MatricesWeightsExtraKind
  24857. * @param data defines the data source
  24858. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24859. * @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)
  24860. * @returns the current mesh
  24861. */
  24862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24863. /**
  24864. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24865. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24866. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24867. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24868. * @returns the current mesh
  24869. */
  24870. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24871. /**
  24872. * Creates a un-shared specific occurence of the geometry for the mesh.
  24873. * @returns the current mesh
  24874. */
  24875. makeGeometryUnique(): Mesh;
  24876. /**
  24877. * Set the index buffer of this mesh
  24878. * @param indices defines the source data
  24879. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24880. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24881. * @returns the current mesh
  24882. */
  24883. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24884. /**
  24885. * Update the current index buffer
  24886. * @param indices defines the source data
  24887. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24888. * @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)
  24889. * @returns the current mesh
  24890. */
  24891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24892. /**
  24893. * Invert the geometry to move from a right handed system to a left handed one.
  24894. * @returns the current mesh
  24895. */
  24896. toLeftHanded(): Mesh;
  24897. /** @hidden */
  24898. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24899. /** @hidden */
  24900. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24901. /**
  24902. * Registers for this mesh a javascript function called just before the rendering process
  24903. * @param func defines the function to call before rendering this mesh
  24904. * @returns the current mesh
  24905. */
  24906. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24907. /**
  24908. * Disposes a previously registered javascript function called before the rendering
  24909. * @param func defines the function to remove
  24910. * @returns the current mesh
  24911. */
  24912. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24913. /**
  24914. * Registers for this mesh a javascript function called just after the rendering is complete
  24915. * @param func defines the function to call after rendering this mesh
  24916. * @returns the current mesh
  24917. */
  24918. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24919. /**
  24920. * Disposes a previously registered javascript function called after the rendering.
  24921. * @param func defines the function to remove
  24922. * @returns the current mesh
  24923. */
  24924. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24925. /** @hidden */
  24926. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24927. /** @hidden */
  24928. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24929. /** @hidden */
  24930. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24931. /** @hidden */
  24932. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24933. /** @hidden */
  24934. _rebuild(): void;
  24935. /** @hidden */
  24936. _freeze(): void;
  24937. /** @hidden */
  24938. _unFreeze(): void;
  24939. /**
  24940. * 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
  24941. * @param subMesh defines the subMesh to render
  24942. * @param enableAlphaMode defines if alpha mode can be changed
  24943. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24944. * @returns the current mesh
  24945. */
  24946. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24947. private _onBeforeDraw;
  24948. /**
  24949. * Renormalize the mesh and patch it up if there are no weights
  24950. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24951. * However in the case of zero weights then we set just a single influence to 1.
  24952. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24953. */
  24954. cleanMatrixWeights(): void;
  24955. private normalizeSkinFourWeights;
  24956. private normalizeSkinWeightsAndExtra;
  24957. /**
  24958. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24959. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24960. * the user know there was an issue with importing the mesh
  24961. * @returns a validation object with skinned, valid and report string
  24962. */
  24963. validateSkinning(): {
  24964. skinned: boolean;
  24965. valid: boolean;
  24966. report: string;
  24967. };
  24968. /** @hidden */
  24969. _checkDelayState(): Mesh;
  24970. private _queueLoad;
  24971. /**
  24972. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24973. * A mesh is in the frustum if its bounding box intersects the frustum
  24974. * @param frustumPlanes defines the frustum to test
  24975. * @returns true if the mesh is in the frustum planes
  24976. */
  24977. isInFrustum(frustumPlanes: Plane[]): boolean;
  24978. /**
  24979. * Sets the mesh material by the material or multiMaterial `id` property
  24980. * @param id is a string identifying the material or the multiMaterial
  24981. * @returns the current mesh
  24982. */
  24983. setMaterialByID(id: string): Mesh;
  24984. /**
  24985. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24986. * @returns an array of IAnimatable
  24987. */
  24988. getAnimatables(): IAnimatable[];
  24989. /**
  24990. * Modifies the mesh geometry according to the passed transformation matrix.
  24991. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24992. * The mesh normals are modified using the same transformation.
  24993. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24994. * @param transform defines the transform matrix to use
  24995. * @see http://doc.babylonjs.com/resources/baking_transformations
  24996. * @returns the current mesh
  24997. */
  24998. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24999. /**
  25000. * Modifies the mesh geometry according to its own current World Matrix.
  25001. * The mesh World Matrix is then reset.
  25002. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25003. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25004. * @see http://doc.babylonjs.com/resources/baking_transformations
  25005. * @returns the current mesh
  25006. */
  25007. bakeCurrentTransformIntoVertices(): Mesh;
  25008. /** @hidden */
  25009. readonly _positions: Nullable<Vector3[]>;
  25010. /** @hidden */
  25011. _resetPointsArrayCache(): Mesh;
  25012. /** @hidden */
  25013. _generatePointsArray(): boolean;
  25014. /**
  25015. * Returns a new Mesh object generated from the current mesh properties.
  25016. * This method must not get confused with createInstance()
  25017. * @param name is a string, the name given to the new mesh
  25018. * @param newParent can be any Node object (default `null`)
  25019. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25020. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25021. * @returns a new mesh
  25022. */
  25023. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25024. /**
  25025. * Releases resources associated with this mesh.
  25026. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25027. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25028. */
  25029. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25030. /** @hidden */
  25031. _disposeInstanceSpecificData(): void;
  25032. /**
  25033. * Modifies the mesh geometry according to a displacement map.
  25034. * 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.
  25035. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25036. * @param url is a string, the URL from the image file is to be downloaded.
  25037. * @param minHeight is the lower limit of the displacement.
  25038. * @param maxHeight is the upper limit of the displacement.
  25039. * @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.
  25040. * @param uvOffset is an optional vector2 used to offset UV.
  25041. * @param uvScale is an optional vector2 used to scale UV.
  25042. * @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.
  25043. * @returns the Mesh.
  25044. */
  25045. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25046. /**
  25047. * Modifies the mesh geometry according to a displacementMap buffer.
  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 buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25051. * @param heightMapWidth is the width of the buffer image.
  25052. * @param heightMapHeight is the height of the buffer image.
  25053. * @param minHeight is the lower limit of the displacement.
  25054. * @param maxHeight is the upper limit of the displacement.
  25055. * @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.
  25056. * @param uvOffset is an optional vector2 used to offset UV.
  25057. * @param uvScale is an optional vector2 used to scale UV.
  25058. * @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.
  25059. * @returns the Mesh.
  25060. */
  25061. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25062. /**
  25063. * Modify the mesh to get a flat shading rendering.
  25064. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25065. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25066. * @returns current mesh
  25067. */
  25068. convertToFlatShadedMesh(): Mesh;
  25069. /**
  25070. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25071. * In other words, more vertices, no more indices and a single bigger VBO.
  25072. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25073. * @returns current mesh
  25074. */
  25075. convertToUnIndexedMesh(): Mesh;
  25076. /**
  25077. * Inverses facet orientations.
  25078. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25079. * @param flipNormals will also inverts the normals
  25080. * @returns current mesh
  25081. */
  25082. flipFaces(flipNormals?: boolean): Mesh;
  25083. /**
  25084. * Increase the number of facets and hence vertices in a mesh
  25085. * Vertex normals are interpolated from existing vertex normals
  25086. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25087. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25088. */
  25089. increaseVertices(numberPerEdge: number): void;
  25090. /**
  25091. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25092. * This will undo any application of covertToFlatShadedMesh
  25093. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25094. */
  25095. forceSharedVertices(): void;
  25096. /** @hidden */
  25097. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25098. /** @hidden */
  25099. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25100. /**
  25101. * Creates a new InstancedMesh object from the mesh model.
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25103. * @param name defines the name of the new instance
  25104. * @returns a new InstancedMesh
  25105. */
  25106. createInstance(name: string): InstancedMesh;
  25107. /**
  25108. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25109. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25110. * @returns the current mesh
  25111. */
  25112. synchronizeInstances(): Mesh;
  25113. /**
  25114. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25115. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25116. * This should be used together with the simplification to avoid disappearing triangles.
  25117. * @param successCallback an optional success callback to be called after the optimization finished.
  25118. * @returns the current mesh
  25119. */
  25120. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25121. /**
  25122. * Serialize current mesh
  25123. * @param serializationObject defines the object which will receive the serialization data
  25124. */
  25125. serialize(serializationObject: any): void;
  25126. /** @hidden */
  25127. _syncGeometryWithMorphTargetManager(): void;
  25128. /** @hidden */
  25129. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25130. /**
  25131. * Returns a new Mesh object parsed from the source provided.
  25132. * @param parsedMesh is the source
  25133. * @param scene defines the hosting scene
  25134. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25135. * @returns a new Mesh
  25136. */
  25137. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25138. /**
  25139. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25140. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25141. * @param name defines the name of the mesh to create
  25142. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25143. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25144. * @param closePath creates a seam between the first and the last points of each path of the path array
  25145. * @param offset is taken in account only if the `pathArray` is containing a single path
  25146. * @param scene defines the hosting scene
  25147. * @param updatable defines if the mesh must be flagged as updatable
  25148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25149. * @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)
  25150. * @returns a new Mesh
  25151. */
  25152. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25153. /**
  25154. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25155. * @param name defines the name of the mesh to create
  25156. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25157. * @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
  25158. * @param scene defines the hosting scene
  25159. * @param updatable defines if the mesh must be flagged as updatable
  25160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25161. * @returns a new Mesh
  25162. */
  25163. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25164. /**
  25165. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25166. * @param name defines the name of the mesh to create
  25167. * @param size sets the size (float) of each box side (default 1)
  25168. * @param scene defines the hosting scene
  25169. * @param updatable defines if the mesh must be flagged as updatable
  25170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25171. * @returns a new Mesh
  25172. */
  25173. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25174. /**
  25175. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25176. * @param name defines the name of the mesh to create
  25177. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25178. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25179. * @param scene defines the hosting scene
  25180. * @param updatable defines if the mesh must be flagged as updatable
  25181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25182. * @returns a new Mesh
  25183. */
  25184. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25185. /**
  25186. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25187. * @param name defines the name of the mesh to create
  25188. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25189. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25190. * @param scene defines the hosting scene
  25191. * @returns a new Mesh
  25192. */
  25193. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25194. /**
  25195. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25196. * @param name defines the name of the mesh to create
  25197. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25198. * @param diameterTop set the top cap diameter (floats, default 1)
  25199. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25200. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25201. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25202. * @param scene defines the hosting scene
  25203. * @param updatable defines if the mesh must be flagged as updatable
  25204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25205. * @returns a new Mesh
  25206. */
  25207. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25208. /**
  25209. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  25212. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25213. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25214. * @param scene defines the hosting scene
  25215. * @param updatable defines if the mesh must be flagged as updatable
  25216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25217. * @returns a new Mesh
  25218. */
  25219. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25220. /**
  25221. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25222. * @param name defines the name of the mesh to create
  25223. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25224. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25225. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25226. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25227. * @param p the number of windings on X axis (positive integers, default 2)
  25228. * @param q the number of windings on Y axis (positive integers, default 3)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25235. /**
  25236. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25237. * @param name defines the name of the mesh to create
  25238. * @param points is an array successive Vector3
  25239. * @param scene defines the hosting scene
  25240. * @param updatable defines if the mesh must be flagged as updatable
  25241. * @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).
  25242. * @returns a new Mesh
  25243. */
  25244. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25245. /**
  25246. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25247. * @param name defines the name of the mesh to create
  25248. * @param points is an array successive Vector3
  25249. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25250. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25251. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25252. * @param scene defines the hosting scene
  25253. * @param updatable defines if the mesh must be flagged as updatable
  25254. * @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)
  25255. * @returns a new Mesh
  25256. */
  25257. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25258. /**
  25259. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25260. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25261. * 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.
  25262. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25263. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25264. * Remember you can only change the shape positions, not their number when updating a polygon.
  25265. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25266. * @param name defines the name of the mesh to create
  25267. * @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
  25268. * @param scene defines the hosting scene
  25269. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25272. * @param earcutInjection can be used to inject your own earcut reference
  25273. * @returns a new Mesh
  25274. */
  25275. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25276. /**
  25277. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25278. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25279. * @param name defines the name of the mesh to create
  25280. * @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
  25281. * @param depth defines the height of extrusion
  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 ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25290. /**
  25291. * Creates an extruded shape mesh.
  25292. * 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
  25293. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25294. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25295. * @param name defines the name of the mesh to create
  25296. * @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
  25297. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25298. * @param scale is the value to scale the shape
  25299. * @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
  25300. * @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
  25301. * @param scene defines the hosting scene
  25302. * @param updatable defines if the mesh must be flagged as updatable
  25303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25304. * @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)
  25305. * @returns a new Mesh
  25306. */
  25307. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25308. /**
  25309. * Creates an custom extruded shape mesh.
  25310. * The custom extrusion is a parametric shape.
  25311. * It has no predefined shape. Its final shape will depend on the input parameters.
  25312. * Please consider using the same method from the MeshBuilder class instead
  25313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25314. * @param name defines the name of the mesh to create
  25315. * @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
  25316. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25317. * @param scaleFunction is a custom Javascript function called on each path point
  25318. * @param rotationFunction is a custom Javascript function called on each path point
  25319. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25320. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25321. * @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
  25322. * @param scene defines the hosting scene
  25323. * @param updatable defines if the mesh must be flagged as updatable
  25324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25325. * @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)
  25326. * @returns a new Mesh
  25327. */
  25328. 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;
  25329. /**
  25330. * Creates lathe mesh.
  25331. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25332. * Please consider using the same method from the MeshBuilder class instead
  25333. * @param name defines the name of the mesh to create
  25334. * @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
  25335. * @param radius is the radius value of the lathe
  25336. * @param tessellation is the side number of the lathe.
  25337. * @param scene defines the hosting scene
  25338. * @param updatable defines if the mesh must be flagged as updatable
  25339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25340. * @returns a new Mesh
  25341. */
  25342. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25343. /**
  25344. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25345. * @param name defines the name of the mesh to create
  25346. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25347. * @param scene defines the hosting scene
  25348. * @param updatable defines if the mesh must be flagged as updatable
  25349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25350. * @returns a new Mesh
  25351. */
  25352. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25353. /**
  25354. * Creates a ground mesh.
  25355. * Please consider using the same method from the MeshBuilder class instead
  25356. * @param name defines the name of the mesh to create
  25357. * @param width set the width of the ground
  25358. * @param height set the height of the ground
  25359. * @param subdivisions sets the number of subdivisions per side
  25360. * @param scene defines the hosting scene
  25361. * @param updatable defines if the mesh must be flagged as updatable
  25362. * @returns a new Mesh
  25363. */
  25364. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25365. /**
  25366. * Creates a tiled ground mesh.
  25367. * Please consider using the same method from the MeshBuilder class instead
  25368. * @param name defines the name of the mesh to create
  25369. * @param xmin set the ground minimum X coordinate
  25370. * @param zmin set the ground minimum Y coordinate
  25371. * @param xmax set the ground maximum X coordinate
  25372. * @param zmax set the ground maximum Z coordinate
  25373. * @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
  25374. * @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
  25375. * @param scene defines the hosting scene
  25376. * @param updatable defines if the mesh must be flagged as updatable
  25377. * @returns a new Mesh
  25378. */
  25379. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25380. w: number;
  25381. h: number;
  25382. }, precision: {
  25383. w: number;
  25384. h: number;
  25385. }, scene: Scene, updatable?: boolean): Mesh;
  25386. /**
  25387. * Creates a ground mesh from a height map.
  25388. * Please consider using the same method from the MeshBuilder class instead
  25389. * @see http://doc.babylonjs.com/babylon101/height_map
  25390. * @param name defines the name of the mesh to create
  25391. * @param url sets the URL of the height map image resource
  25392. * @param width set the ground width size
  25393. * @param height set the ground height size
  25394. * @param subdivisions sets the number of subdivision per side
  25395. * @param minHeight is the minimum altitude on the ground
  25396. * @param maxHeight is the maximum altitude on the ground
  25397. * @param scene defines the hosting scene
  25398. * @param updatable defines if the mesh must be flagged as updatable
  25399. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25400. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25401. * @returns a new Mesh
  25402. */
  25403. 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;
  25404. /**
  25405. * Creates a tube mesh.
  25406. * The tube is a parametric shape.
  25407. * It has no predefined shape. Its final shape will depend on the input parameters.
  25408. * Please consider using the same method from the MeshBuilder class instead
  25409. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25410. * @param name defines the name of the mesh to create
  25411. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25412. * @param radius sets the tube radius size
  25413. * @param tessellation is the number of sides on the tubular surface
  25414. * @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
  25415. * @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
  25416. * @param scene defines the hosting scene
  25417. * @param updatable defines if the mesh must be flagged as updatable
  25418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25419. * @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)
  25420. * @returns a new Mesh
  25421. */
  25422. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25423. (i: number, distance: number): number;
  25424. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25425. /**
  25426. * Creates a polyhedron mesh.
  25427. * Please consider using the same method from the MeshBuilder class instead.
  25428. * * 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
  25429. * * The parameter `size` (positive float, default 1) sets the polygon size
  25430. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25431. * * 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`
  25432. * * 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
  25433. * * 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)`)
  25434. * * 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
  25435. * * 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
  25436. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * * If you create a double-sided mesh, you can choose what parts of 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
  25438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25439. * @param name defines the name of the mesh to create
  25440. * @param options defines the options used to create the mesh
  25441. * @param scene defines the hosting scene
  25442. * @returns a new Mesh
  25443. */
  25444. static CreatePolyhedron(name: string, options: {
  25445. type?: number;
  25446. size?: number;
  25447. sizeX?: number;
  25448. sizeY?: number;
  25449. sizeZ?: number;
  25450. custom?: any;
  25451. faceUV?: Vector4[];
  25452. faceColors?: Color4[];
  25453. updatable?: boolean;
  25454. sideOrientation?: number;
  25455. }, scene: Scene): Mesh;
  25456. /**
  25457. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25458. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25459. * * 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`)
  25460. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25461. * * 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
  25462. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25463. * * If you create a double-sided mesh, you can choose what parts of 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
  25464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25465. * @param name defines the name of the mesh
  25466. * @param options defines the options used to create the mesh
  25467. * @param scene defines the hosting scene
  25468. * @returns a new Mesh
  25469. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25470. */
  25471. static CreateIcoSphere(name: string, options: {
  25472. radius?: number;
  25473. flat?: boolean;
  25474. subdivisions?: number;
  25475. sideOrientation?: number;
  25476. updatable?: boolean;
  25477. }, scene: Scene): Mesh;
  25478. /**
  25479. * Creates a decal mesh.
  25480. * Please consider using the same method from the MeshBuilder class instead.
  25481. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25482. * @param name defines the name of the mesh
  25483. * @param sourceMesh defines the mesh receiving the decal
  25484. * @param position sets the position of the decal in world coordinates
  25485. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25486. * @param size sets the decal scaling
  25487. * @param angle sets the angle to rotate the decal
  25488. * @returns a new Mesh
  25489. */
  25490. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25491. /**
  25492. * Prepare internal position array for software CPU skinning
  25493. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25494. */
  25495. setPositionsForCPUSkinning(): Float32Array;
  25496. /**
  25497. * Prepare internal normal array for software CPU skinning
  25498. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25499. */
  25500. setNormalsForCPUSkinning(): Float32Array;
  25501. /**
  25502. * Updates the vertex buffer by applying transformation from the bones
  25503. * @param skeleton defines the skeleton to apply to current mesh
  25504. * @returns the current mesh
  25505. */
  25506. applySkeleton(skeleton: Skeleton): Mesh;
  25507. /**
  25508. * 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
  25509. * @param meshes defines the list of meshes to scan
  25510. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25511. */
  25512. static MinMax(meshes: AbstractMesh[]): {
  25513. min: Vector3;
  25514. max: Vector3;
  25515. };
  25516. /**
  25517. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25518. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25519. * @returns a vector3
  25520. */
  25521. static Center(meshesOrMinMaxVector: {
  25522. min: Vector3;
  25523. max: Vector3;
  25524. } | AbstractMesh[]): Vector3;
  25525. /**
  25526. * Merge the array of meshes into a single mesh for performance reasons.
  25527. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25528. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25529. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25530. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25531. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25532. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25533. * @returns a new mesh
  25534. */
  25535. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25536. /** @hidden */
  25537. addInstance(instance: InstancedMesh): void;
  25538. /** @hidden */
  25539. removeInstance(instance: InstancedMesh): void;
  25540. }
  25541. }
  25542. declare module "babylonjs/Cameras/camera" {
  25543. import { SmartArray } from "babylonjs/Misc/smartArray";
  25544. import { Observable } from "babylonjs/Misc/observable";
  25545. import { Nullable } from "babylonjs/types";
  25546. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25547. import { Scene } from "babylonjs/scene";
  25548. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25549. import { Node } from "babylonjs/node";
  25550. import { Mesh } from "babylonjs/Meshes/mesh";
  25551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25552. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25553. import { Viewport } from "babylonjs/Maths/math.viewport";
  25554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25556. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25557. import { Ray } from "babylonjs/Culling/ray";
  25558. /**
  25559. * This is the base class of all the camera used in the application.
  25560. * @see http://doc.babylonjs.com/features/cameras
  25561. */
  25562. export class Camera extends Node {
  25563. /** @hidden */
  25564. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25565. /**
  25566. * This is the default projection mode used by the cameras.
  25567. * It helps recreating a feeling of perspective and better appreciate depth.
  25568. * This is the best way to simulate real life cameras.
  25569. */
  25570. static readonly PERSPECTIVE_CAMERA: number;
  25571. /**
  25572. * This helps creating camera with an orthographic mode.
  25573. * 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.
  25574. */
  25575. static readonly ORTHOGRAPHIC_CAMERA: number;
  25576. /**
  25577. * This is the default FOV mode for perspective cameras.
  25578. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25579. */
  25580. static readonly FOVMODE_VERTICAL_FIXED: number;
  25581. /**
  25582. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25583. */
  25584. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25585. /**
  25586. * This specifies ther is no need for a camera rig.
  25587. * Basically only one eye is rendered corresponding to the camera.
  25588. */
  25589. static readonly RIG_MODE_NONE: number;
  25590. /**
  25591. * Simulates a camera Rig with one blue eye and one red eye.
  25592. * This can be use with 3d blue and red glasses.
  25593. */
  25594. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25595. /**
  25596. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25597. */
  25598. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25599. /**
  25600. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25601. */
  25602. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25603. /**
  25604. * Defines that both eyes of the camera will be rendered over under each other.
  25605. */
  25606. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25607. /**
  25608. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25609. */
  25610. static readonly RIG_MODE_VR: number;
  25611. /**
  25612. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25613. */
  25614. static readonly RIG_MODE_WEBVR: number;
  25615. /**
  25616. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25617. */
  25618. static readonly RIG_MODE_CUSTOM: number;
  25619. /**
  25620. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25621. */
  25622. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25623. /**
  25624. * Define the input manager associated with the camera.
  25625. */
  25626. inputs: CameraInputsManager<Camera>;
  25627. /** @hidden */
  25628. _position: Vector3;
  25629. /**
  25630. * Define the current local position of the camera in the scene
  25631. */
  25632. position: Vector3;
  25633. /**
  25634. * The vector the camera should consider as up.
  25635. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25636. */
  25637. upVector: Vector3;
  25638. /**
  25639. * Define the current limit on the left side for an orthographic camera
  25640. * In scene unit
  25641. */
  25642. orthoLeft: Nullable<number>;
  25643. /**
  25644. * Define the current limit on the right side for an orthographic camera
  25645. * In scene unit
  25646. */
  25647. orthoRight: Nullable<number>;
  25648. /**
  25649. * Define the current limit on the bottom side for an orthographic camera
  25650. * In scene unit
  25651. */
  25652. orthoBottom: Nullable<number>;
  25653. /**
  25654. * Define the current limit on the top side for an orthographic camera
  25655. * In scene unit
  25656. */
  25657. orthoTop: Nullable<number>;
  25658. /**
  25659. * Field Of View is set in Radians. (default is 0.8)
  25660. */
  25661. fov: number;
  25662. /**
  25663. * Define the minimum distance the camera can see from.
  25664. * This is important to note that the depth buffer are not infinite and the closer it starts
  25665. * the more your scene might encounter depth fighting issue.
  25666. */
  25667. minZ: number;
  25668. /**
  25669. * Define the maximum distance the camera can see to.
  25670. * This is important to note that the depth buffer are not infinite and the further it end
  25671. * the more your scene might encounter depth fighting issue.
  25672. */
  25673. maxZ: number;
  25674. /**
  25675. * Define the default inertia of the camera.
  25676. * This helps giving a smooth feeling to the camera movement.
  25677. */
  25678. inertia: number;
  25679. /**
  25680. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25681. */
  25682. mode: number;
  25683. /**
  25684. * Define wether the camera is intermediate.
  25685. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25686. */
  25687. isIntermediate: boolean;
  25688. /**
  25689. * Define the viewport of the camera.
  25690. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25691. */
  25692. viewport: Viewport;
  25693. /**
  25694. * Restricts the camera to viewing objects with the same layerMask.
  25695. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25696. */
  25697. layerMask: number;
  25698. /**
  25699. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25700. */
  25701. fovMode: number;
  25702. /**
  25703. * Rig mode of the camera.
  25704. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25705. * This is normally controlled byt the camera themselves as internal use.
  25706. */
  25707. cameraRigMode: number;
  25708. /**
  25709. * Defines the distance between both "eyes" in case of a RIG
  25710. */
  25711. interaxialDistance: number;
  25712. /**
  25713. * Defines if stereoscopic rendering is done side by side or over under.
  25714. */
  25715. isStereoscopicSideBySide: boolean;
  25716. /**
  25717. * 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
  25718. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25719. * else in the scene. (Eg. security camera)
  25720. *
  25721. * 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)
  25722. */
  25723. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25724. /**
  25725. * When set, the camera will render to this render target instead of the default canvas
  25726. *
  25727. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25728. */
  25729. outputRenderTarget: Nullable<RenderTargetTexture>;
  25730. /**
  25731. * Observable triggered when the camera view matrix has changed.
  25732. */
  25733. onViewMatrixChangedObservable: Observable<Camera>;
  25734. /**
  25735. * Observable triggered when the camera Projection matrix has changed.
  25736. */
  25737. onProjectionMatrixChangedObservable: Observable<Camera>;
  25738. /**
  25739. * Observable triggered when the inputs have been processed.
  25740. */
  25741. onAfterCheckInputsObservable: Observable<Camera>;
  25742. /**
  25743. * Observable triggered when reset has been called and applied to the camera.
  25744. */
  25745. onRestoreStateObservable: Observable<Camera>;
  25746. /** @hidden */
  25747. _cameraRigParams: any;
  25748. /** @hidden */
  25749. _rigCameras: Camera[];
  25750. /** @hidden */
  25751. _rigPostProcess: Nullable<PostProcess>;
  25752. protected _webvrViewMatrix: Matrix;
  25753. /** @hidden */
  25754. _skipRendering: boolean;
  25755. /** @hidden */
  25756. _projectionMatrix: Matrix;
  25757. /** @hidden */
  25758. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25759. /** @hidden */
  25760. _activeMeshes: SmartArray<AbstractMesh>;
  25761. protected _globalPosition: Vector3;
  25762. /** @hidden */
  25763. _computedViewMatrix: Matrix;
  25764. private _doNotComputeProjectionMatrix;
  25765. private _transformMatrix;
  25766. private _frustumPlanes;
  25767. private _refreshFrustumPlanes;
  25768. private _storedFov;
  25769. private _stateStored;
  25770. /**
  25771. * Instantiates a new camera object.
  25772. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25773. * @see http://doc.babylonjs.com/features/cameras
  25774. * @param name Defines the name of the camera in the scene
  25775. * @param position Defines the position of the camera
  25776. * @param scene Defines the scene the camera belongs too
  25777. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25778. */
  25779. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25780. /**
  25781. * Store current camera state (fov, position, etc..)
  25782. * @returns the camera
  25783. */
  25784. storeState(): Camera;
  25785. /**
  25786. * Restores the camera state values if it has been stored. You must call storeState() first
  25787. */
  25788. protected _restoreStateValues(): boolean;
  25789. /**
  25790. * Restored camera state. You must call storeState() first.
  25791. * @returns true if restored and false otherwise
  25792. */
  25793. restoreState(): boolean;
  25794. /**
  25795. * Gets the class name of the camera.
  25796. * @returns the class name
  25797. */
  25798. getClassName(): string;
  25799. /** @hidden */
  25800. readonly _isCamera: boolean;
  25801. /**
  25802. * Gets a string representation of the camera useful for debug purpose.
  25803. * @param fullDetails Defines that a more verboe level of logging is required
  25804. * @returns the string representation
  25805. */
  25806. toString(fullDetails?: boolean): string;
  25807. /**
  25808. * Gets the current world space position of the camera.
  25809. */
  25810. readonly globalPosition: Vector3;
  25811. /**
  25812. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25813. * @returns the active meshe list
  25814. */
  25815. getActiveMeshes(): SmartArray<AbstractMesh>;
  25816. /**
  25817. * Check wether a mesh is part of the current active mesh list of the camera
  25818. * @param mesh Defines the mesh to check
  25819. * @returns true if active, false otherwise
  25820. */
  25821. isActiveMesh(mesh: Mesh): boolean;
  25822. /**
  25823. * Is this camera ready to be used/rendered
  25824. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25825. * @return true if the camera is ready
  25826. */
  25827. isReady(completeCheck?: boolean): boolean;
  25828. /** @hidden */
  25829. _initCache(): void;
  25830. /** @hidden */
  25831. _updateCache(ignoreParentClass?: boolean): void;
  25832. /** @hidden */
  25833. _isSynchronized(): boolean;
  25834. /** @hidden */
  25835. _isSynchronizedViewMatrix(): boolean;
  25836. /** @hidden */
  25837. _isSynchronizedProjectionMatrix(): boolean;
  25838. /**
  25839. * Attach the input controls to a specific dom element to get the input from.
  25840. * @param element Defines the element the controls should be listened from
  25841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25842. */
  25843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25844. /**
  25845. * Detach the current controls from the specified dom element.
  25846. * @param element Defines the element to stop listening the inputs from
  25847. */
  25848. detachControl(element: HTMLElement): void;
  25849. /**
  25850. * Update the camera state according to the different inputs gathered during the frame.
  25851. */
  25852. update(): void;
  25853. /** @hidden */
  25854. _checkInputs(): void;
  25855. /** @hidden */
  25856. readonly rigCameras: Camera[];
  25857. /**
  25858. * Gets the post process used by the rig cameras
  25859. */
  25860. readonly rigPostProcess: Nullable<PostProcess>;
  25861. /**
  25862. * Internal, gets the first post proces.
  25863. * @returns the first post process to be run on this camera.
  25864. */
  25865. _getFirstPostProcess(): Nullable<PostProcess>;
  25866. private _cascadePostProcessesToRigCams;
  25867. /**
  25868. * Attach a post process to the camera.
  25869. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25870. * @param postProcess The post process to attach to the camera
  25871. * @param insertAt The position of the post process in case several of them are in use in the scene
  25872. * @returns the position the post process has been inserted at
  25873. */
  25874. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25875. /**
  25876. * Detach a post process to the camera.
  25877. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25878. * @param postProcess The post process to detach from the camera
  25879. */
  25880. detachPostProcess(postProcess: PostProcess): void;
  25881. /**
  25882. * Gets the current world matrix of the camera
  25883. */
  25884. getWorldMatrix(): Matrix;
  25885. /** @hidden */
  25886. _getViewMatrix(): Matrix;
  25887. /**
  25888. * Gets the current view matrix of the camera.
  25889. * @param force forces the camera to recompute the matrix without looking at the cached state
  25890. * @returns the view matrix
  25891. */
  25892. getViewMatrix(force?: boolean): Matrix;
  25893. /**
  25894. * Freeze the projection matrix.
  25895. * It will prevent the cache check of the camera projection compute and can speed up perf
  25896. * if no parameter of the camera are meant to change
  25897. * @param projection Defines manually a projection if necessary
  25898. */
  25899. freezeProjectionMatrix(projection?: Matrix): void;
  25900. /**
  25901. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25902. */
  25903. unfreezeProjectionMatrix(): void;
  25904. /**
  25905. * Gets the current projection matrix of the camera.
  25906. * @param force forces the camera to recompute the matrix without looking at the cached state
  25907. * @returns the projection matrix
  25908. */
  25909. getProjectionMatrix(force?: boolean): Matrix;
  25910. /**
  25911. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25912. * @returns a Matrix
  25913. */
  25914. getTransformationMatrix(): Matrix;
  25915. private _updateFrustumPlanes;
  25916. /**
  25917. * Checks if a cullable object (mesh...) is in the camera frustum
  25918. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25919. * @param target The object to check
  25920. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25921. * @returns true if the object is in frustum otherwise false
  25922. */
  25923. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25924. /**
  25925. * Checks if a cullable object (mesh...) is in the camera frustum
  25926. * Unlike isInFrustum this cheks the full bounding box
  25927. * @param target The object to check
  25928. * @returns true if the object is in frustum otherwise false
  25929. */
  25930. isCompletelyInFrustum(target: ICullable): boolean;
  25931. /**
  25932. * Gets a ray in the forward direction from the camera.
  25933. * @param length Defines the length of the ray to create
  25934. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25935. * @param origin Defines the start point of the ray which defaults to the camera position
  25936. * @returns the forward ray
  25937. */
  25938. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25939. /**
  25940. * Releases resources associated with this node.
  25941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25943. */
  25944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25945. /** @hidden */
  25946. _isLeftCamera: boolean;
  25947. /**
  25948. * Gets the left camera of a rig setup in case of Rigged Camera
  25949. */
  25950. readonly isLeftCamera: boolean;
  25951. /** @hidden */
  25952. _isRightCamera: boolean;
  25953. /**
  25954. * Gets the right camera of a rig setup in case of Rigged Camera
  25955. */
  25956. readonly isRightCamera: boolean;
  25957. /**
  25958. * Gets the left camera of a rig setup in case of Rigged Camera
  25959. */
  25960. readonly leftCamera: Nullable<FreeCamera>;
  25961. /**
  25962. * Gets the right camera of a rig setup in case of Rigged Camera
  25963. */
  25964. readonly rightCamera: Nullable<FreeCamera>;
  25965. /**
  25966. * Gets the left camera target of a rig setup in case of Rigged Camera
  25967. * @returns the target position
  25968. */
  25969. getLeftTarget(): Nullable<Vector3>;
  25970. /**
  25971. * Gets the right camera target of a rig setup in case of Rigged Camera
  25972. * @returns the target position
  25973. */
  25974. getRightTarget(): Nullable<Vector3>;
  25975. /**
  25976. * @hidden
  25977. */
  25978. setCameraRigMode(mode: number, rigParams: any): void;
  25979. /** @hidden */
  25980. static _setStereoscopicRigMode(camera: Camera): void;
  25981. /** @hidden */
  25982. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25983. /** @hidden */
  25984. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25985. /** @hidden */
  25986. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25987. /** @hidden */
  25988. _getVRProjectionMatrix(): Matrix;
  25989. protected _updateCameraRotationMatrix(): void;
  25990. protected _updateWebVRCameraRotationMatrix(): void;
  25991. /**
  25992. * This function MUST be overwritten by the different WebVR cameras available.
  25993. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25994. * @hidden
  25995. */
  25996. _getWebVRProjectionMatrix(): Matrix;
  25997. /**
  25998. * This function MUST be overwritten by the different WebVR cameras available.
  25999. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26000. * @hidden
  26001. */
  26002. _getWebVRViewMatrix(): Matrix;
  26003. /** @hidden */
  26004. setCameraRigParameter(name: string, value: any): void;
  26005. /**
  26006. * needs to be overridden by children so sub has required properties to be copied
  26007. * @hidden
  26008. */
  26009. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26010. /**
  26011. * May need to be overridden by children
  26012. * @hidden
  26013. */
  26014. _updateRigCameras(): void;
  26015. /** @hidden */
  26016. _setupInputs(): void;
  26017. /**
  26018. * Serialiaze the camera setup to a json represention
  26019. * @returns the JSON representation
  26020. */
  26021. serialize(): any;
  26022. /**
  26023. * Clones the current camera.
  26024. * @param name The cloned camera name
  26025. * @returns the cloned camera
  26026. */
  26027. clone(name: string): Camera;
  26028. /**
  26029. * Gets the direction of the camera relative to a given local axis.
  26030. * @param localAxis Defines the reference axis to provide a relative direction.
  26031. * @return the direction
  26032. */
  26033. getDirection(localAxis: Vector3): Vector3;
  26034. /**
  26035. * Returns the current camera absolute rotation
  26036. */
  26037. readonly absoluteRotation: Quaternion;
  26038. /**
  26039. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26040. * @param localAxis Defines the reference axis to provide a relative direction.
  26041. * @param result Defines the vector to store the result in
  26042. */
  26043. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26044. /**
  26045. * Gets a camera constructor for a given camera type
  26046. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26047. * @param name The name of the camera the result will be able to instantiate
  26048. * @param scene The scene the result will construct the camera in
  26049. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26050. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26051. * @returns a factory method to construc the camera
  26052. */
  26053. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26054. /**
  26055. * Compute the world matrix of the camera.
  26056. * @returns the camera world matrix
  26057. */
  26058. computeWorldMatrix(): Matrix;
  26059. /**
  26060. * Parse a JSON and creates the camera from the parsed information
  26061. * @param parsedCamera The JSON to parse
  26062. * @param scene The scene to instantiate the camera in
  26063. * @returns the newly constructed camera
  26064. */
  26065. static Parse(parsedCamera: any, scene: Scene): Camera;
  26066. }
  26067. }
  26068. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26069. import { Nullable } from "babylonjs/types";
  26070. import { Scene } from "babylonjs/scene";
  26071. import { Vector4 } from "babylonjs/Maths/math.vector";
  26072. import { Mesh } from "babylonjs/Meshes/mesh";
  26073. /**
  26074. * Class containing static functions to help procedurally build meshes
  26075. */
  26076. export class DiscBuilder {
  26077. /**
  26078. * Creates a plane polygonal mesh. By default, this is a disc
  26079. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26080. * * 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
  26081. * * 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
  26082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26085. * @param name defines the name of the mesh
  26086. * @param options defines the options used to create the mesh
  26087. * @param scene defines the hosting scene
  26088. * @returns the plane polygonal mesh
  26089. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26090. */
  26091. static CreateDisc(name: string, options: {
  26092. radius?: number;
  26093. tessellation?: number;
  26094. arc?: number;
  26095. updatable?: boolean;
  26096. sideOrientation?: number;
  26097. frontUVs?: Vector4;
  26098. backUVs?: Vector4;
  26099. }, scene?: Nullable<Scene>): Mesh;
  26100. }
  26101. }
  26102. declare module "babylonjs/Particles/solidParticleSystem" {
  26103. import { Nullable } from "babylonjs/types";
  26104. import { Vector3 } from "babylonjs/Maths/math.vector";
  26105. import { Mesh } from "babylonjs/Meshes/mesh";
  26106. import { Scene, IDisposable } from "babylonjs/scene";
  26107. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26108. /**
  26109. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26110. *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.
  26111. * The SPS is also a particle system. It provides some methods to manage the particles.
  26112. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26113. *
  26114. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26115. */
  26116. export class SolidParticleSystem implements IDisposable {
  26117. /**
  26118. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26119. * Example : var p = SPS.particles[i];
  26120. */
  26121. particles: SolidParticle[];
  26122. /**
  26123. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26124. */
  26125. nbParticles: number;
  26126. /**
  26127. * If the particles must ever face the camera (default false). Useful for planar particles.
  26128. */
  26129. billboard: boolean;
  26130. /**
  26131. * Recompute normals when adding a shape
  26132. */
  26133. recomputeNormals: boolean;
  26134. /**
  26135. * This a counter ofr your own usage. It's not set by any SPS functions.
  26136. */
  26137. counter: number;
  26138. /**
  26139. * The SPS name. This name is also given to the underlying mesh.
  26140. */
  26141. name: string;
  26142. /**
  26143. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26144. */
  26145. mesh: Mesh;
  26146. /**
  26147. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26148. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26149. */
  26150. vars: any;
  26151. /**
  26152. * This array is populated when the SPS is set as 'pickable'.
  26153. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26154. * Each element of this array is an object `{idx: int, faceId: int}`.
  26155. * `idx` is the picked particle index in the `SPS.particles` array
  26156. * `faceId` is the picked face index counted within this particle.
  26157. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26158. */
  26159. pickedParticles: {
  26160. idx: number;
  26161. faceId: number;
  26162. }[];
  26163. /**
  26164. * This array is populated when `enableDepthSort` is set to true.
  26165. * Each element of this array is an instance of the class DepthSortedParticle.
  26166. */
  26167. depthSortedParticles: DepthSortedParticle[];
  26168. /**
  26169. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26170. * @hidden
  26171. */
  26172. _bSphereOnly: boolean;
  26173. /**
  26174. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26175. * @hidden
  26176. */
  26177. _bSphereRadiusFactor: number;
  26178. private _scene;
  26179. private _positions;
  26180. private _indices;
  26181. private _normals;
  26182. private _colors;
  26183. private _uvs;
  26184. private _indices32;
  26185. private _positions32;
  26186. private _normals32;
  26187. private _fixedNormal32;
  26188. private _colors32;
  26189. private _uvs32;
  26190. private _index;
  26191. private _updatable;
  26192. private _pickable;
  26193. private _isVisibilityBoxLocked;
  26194. private _alwaysVisible;
  26195. private _depthSort;
  26196. private _expandable;
  26197. private _shapeCounter;
  26198. private _copy;
  26199. private _mustResetCopy;
  26200. private _color;
  26201. private _computeParticleColor;
  26202. private _computeParticleTexture;
  26203. private _computeParticleRotation;
  26204. private _computeParticleVertex;
  26205. private _computeBoundingBox;
  26206. private _depthSortParticles;
  26207. private _camera;
  26208. private _mustUnrotateFixedNormals;
  26209. private _particlesIntersect;
  26210. private _needs32Bits;
  26211. private _isNotBuilt;
  26212. private _lastParticleId;
  26213. private _idxOfId;
  26214. /**
  26215. * Creates a SPS (Solid Particle System) object.
  26216. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26217. * @param scene (Scene) is the scene in which the SPS is added.
  26218. * @param options defines the options of the sps e.g.
  26219. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26220. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26221. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26222. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26223. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26224. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26225. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26226. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26227. */
  26228. constructor(name: string, scene: Scene, options?: {
  26229. updatable?: boolean;
  26230. isPickable?: boolean;
  26231. enableDepthSort?: boolean;
  26232. particleIntersection?: boolean;
  26233. boundingSphereOnly?: boolean;
  26234. bSphereRadiusFactor?: number;
  26235. expandable?: boolean;
  26236. });
  26237. /**
  26238. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26239. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26240. * @returns the created mesh
  26241. */
  26242. buildMesh(): Mesh;
  26243. /**
  26244. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26245. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26246. * Thus the particles generated from `digest()` have their property `position` set yet.
  26247. * @param mesh ( Mesh ) is the mesh to be digested
  26248. * @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
  26249. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26250. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26251. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26252. * @returns the current SPS
  26253. */
  26254. digest(mesh: Mesh, options?: {
  26255. facetNb?: number;
  26256. number?: number;
  26257. delta?: number;
  26258. storage?: [];
  26259. }): SolidParticleSystem;
  26260. /**
  26261. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26262. * @hidden
  26263. */
  26264. private _unrotateFixedNormals;
  26265. /**
  26266. * Resets the temporary working copy particle
  26267. * @hidden
  26268. */
  26269. private _resetCopy;
  26270. /**
  26271. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26272. * @param p the current index in the positions array to be updated
  26273. * @param shape a Vector3 array, the shape geometry
  26274. * @param positions the positions array to be updated
  26275. * @param meshInd the shape indices array
  26276. * @param indices the indices array to be updated
  26277. * @param meshUV the shape uv array
  26278. * @param uvs the uv array to be updated
  26279. * @param meshCol the shape color array
  26280. * @param colors the color array to be updated
  26281. * @param meshNor the shape normals array
  26282. * @param normals the normals array to be updated
  26283. * @param idx the particle index
  26284. * @param idxInShape the particle index in its shape
  26285. * @param options the addShape() method passed options
  26286. * @hidden
  26287. */
  26288. private _meshBuilder;
  26289. /**
  26290. * Returns a shape Vector3 array from positions float array
  26291. * @param positions float array
  26292. * @returns a vector3 array
  26293. * @hidden
  26294. */
  26295. private _posToShape;
  26296. /**
  26297. * Returns a shapeUV array from a float uvs (array deep copy)
  26298. * @param uvs as a float array
  26299. * @returns a shapeUV array
  26300. * @hidden
  26301. */
  26302. private _uvsToShapeUV;
  26303. /**
  26304. * Adds a new particle object in the particles array
  26305. * @param idx particle index in particles array
  26306. * @param id particle id
  26307. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26308. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26309. * @param model particle ModelShape object
  26310. * @param shapeId model shape identifier
  26311. * @param idxInShape index of the particle in the current model
  26312. * @param bInfo model bounding info object
  26313. * @param storage target storage array, if any
  26314. * @hidden
  26315. */
  26316. private _addParticle;
  26317. /**
  26318. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26319. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26320. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26321. * @param nb (positive integer) the number of particles to be created from this model
  26322. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26323. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26324. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26325. * @returns the number of shapes in the system
  26326. */
  26327. addShape(mesh: Mesh, nb: number, options?: {
  26328. positionFunction?: any;
  26329. vertexFunction?: any;
  26330. storage?: [];
  26331. }): number;
  26332. /**
  26333. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26334. * @hidden
  26335. */
  26336. private _rebuildParticle;
  26337. /**
  26338. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26339. * @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.
  26340. * @returns the SPS.
  26341. */
  26342. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26343. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26344. * Returns an array with the removed particles.
  26345. * 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.
  26346. * The SPS can't be empty so at least one particle needs to remain in place.
  26347. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26348. * @param start index of the first particle to remove
  26349. * @param end index of the last particle to remove (included)
  26350. * @returns an array populated with the removed particles
  26351. */
  26352. removeParticles(start: number, end: number): SolidParticle[];
  26353. /**
  26354. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26355. * @param solidParticleArray an array populated with Solid Particles objects
  26356. * @returns the SPS
  26357. */
  26358. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26359. /**
  26360. * Creates a new particle and modifies the SPS mesh geometry :
  26361. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26362. * - calls _addParticle() to populate the particle array
  26363. * factorized code from addShape() and insertParticlesFromArray()
  26364. * @param idx particle index in the particles array
  26365. * @param i particle index in its shape
  26366. * @param modelShape particle ModelShape object
  26367. * @param shape shape vertex array
  26368. * @param meshInd shape indices array
  26369. * @param meshUV shape uv array
  26370. * @param meshCol shape color array
  26371. * @param meshNor shape normals array
  26372. * @param bbInfo shape bounding info
  26373. * @param storage target particle storage
  26374. * @options addShape() passed options
  26375. * @hidden
  26376. */
  26377. private _insertNewParticle;
  26378. /**
  26379. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26380. * This method calls `updateParticle()` for each particle of the SPS.
  26381. * For an animated SPS, it is usually called within the render loop.
  26382. * 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.
  26383. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26384. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26385. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26386. * @returns the SPS.
  26387. */
  26388. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26389. /**
  26390. * Disposes the SPS.
  26391. */
  26392. dispose(): void;
  26393. /**
  26394. * Returns a SolidParticle object from its identifier : particle.id
  26395. * @param id (integer) the particle Id
  26396. * @returns the searched particle or null if not found in the SPS.
  26397. */
  26398. getParticleById(id: number): Nullable<SolidParticle>;
  26399. /**
  26400. * Returns a new array populated with the particles having the passed shapeId.
  26401. * @param shapeId (integer) the shape identifier
  26402. * @returns a new solid particle array
  26403. */
  26404. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26405. /**
  26406. * Populates the passed array "ref" with the particles having the passed shapeId.
  26407. * @param shapeId the shape identifier
  26408. * @returns the SPS
  26409. * @param ref
  26410. */
  26411. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26412. /**
  26413. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26414. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26415. * @returns the SPS.
  26416. */
  26417. refreshVisibleSize(): SolidParticleSystem;
  26418. /**
  26419. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26420. * @param size the size (float) of the visibility box
  26421. * note : this doesn't lock the SPS mesh bounding box.
  26422. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26423. */
  26424. setVisibilityBox(size: number): void;
  26425. /**
  26426. * Gets whether the SPS as always visible or not
  26427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26428. */
  26429. /**
  26430. * Sets the SPS as always visible or not
  26431. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26432. */
  26433. isAlwaysVisible: boolean;
  26434. /**
  26435. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26436. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26437. */
  26438. /**
  26439. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26440. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26441. */
  26442. isVisibilityBoxLocked: boolean;
  26443. /**
  26444. * Tells to `setParticles()` to compute the particle rotations or not.
  26445. * Default value : true. The SPS is faster when it's set to false.
  26446. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26447. */
  26448. /**
  26449. * Gets if `setParticles()` computes the particle rotations or not.
  26450. * Default value : true. The SPS is faster when it's set to false.
  26451. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26452. */
  26453. computeParticleRotation: boolean;
  26454. /**
  26455. * Tells to `setParticles()` to compute the particle colors or not.
  26456. * Default value : true. The SPS is faster when it's set to false.
  26457. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26458. */
  26459. /**
  26460. * Gets if `setParticles()` computes the particle colors or not.
  26461. * Default value : true. The SPS is faster when it's set to false.
  26462. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26463. */
  26464. computeParticleColor: boolean;
  26465. /**
  26466. * Gets if `setParticles()` computes the particle textures or not.
  26467. * Default value : true. The SPS is faster when it's set to false.
  26468. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26469. */
  26470. computeParticleTexture: boolean;
  26471. /**
  26472. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26473. * Default value : false. The SPS is faster when it's set to false.
  26474. * Note : the particle custom vertex positions aren't stored values.
  26475. */
  26476. /**
  26477. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26478. * Default value : false. The SPS is faster when it's set to false.
  26479. * Note : the particle custom vertex positions aren't stored values.
  26480. */
  26481. computeParticleVertex: boolean;
  26482. /**
  26483. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26484. */
  26485. /**
  26486. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26487. */
  26488. computeBoundingBox: boolean;
  26489. /**
  26490. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26491. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26492. * Default : `true`
  26493. */
  26494. /**
  26495. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26496. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26497. * Default : `true`
  26498. */
  26499. depthSortParticles: boolean;
  26500. /**
  26501. * Gets if the SPS is created as expandable at construction time.
  26502. * Default : `false`
  26503. */
  26504. readonly expandable: boolean;
  26505. /**
  26506. * This function does nothing. It may be overwritten to set all the particle first values.
  26507. * The SPS doesn't call this function, you may have to call it by your own.
  26508. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26509. */
  26510. initParticles(): void;
  26511. /**
  26512. * This function does nothing. It may be overwritten to recycle a particle.
  26513. * The SPS doesn't call this function, you may have to call it by your own.
  26514. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26515. * @param particle The particle to recycle
  26516. * @returns the recycled particle
  26517. */
  26518. recycleParticle(particle: SolidParticle): SolidParticle;
  26519. /**
  26520. * Updates a particle : this function should be overwritten by the user.
  26521. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26522. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26523. * @example : just set a particle position or velocity and recycle conditions
  26524. * @param particle The particle to update
  26525. * @returns the updated particle
  26526. */
  26527. updateParticle(particle: SolidParticle): SolidParticle;
  26528. /**
  26529. * Updates a vertex of a particle : it can be overwritten by the user.
  26530. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26531. * @param particle the current particle
  26532. * @param vertex the current index of the current particle
  26533. * @param pt the index of the current vertex in the particle shape
  26534. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26535. * @example : just set a vertex particle position
  26536. * @returns the updated vertex
  26537. */
  26538. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26539. /**
  26540. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26541. * This does nothing and may be overwritten by the user.
  26542. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26543. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26544. * @param update the boolean update value actually passed to setParticles()
  26545. */
  26546. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26547. /**
  26548. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26549. * This will be passed three parameters.
  26550. * This does nothing and may be overwritten by the user.
  26551. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26552. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26553. * @param update the boolean update value actually passed to setParticles()
  26554. */
  26555. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26556. }
  26557. }
  26558. declare module "babylonjs/Particles/solidParticle" {
  26559. import { Nullable } from "babylonjs/types";
  26560. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26561. import { Color4 } from "babylonjs/Maths/math.color";
  26562. import { Mesh } from "babylonjs/Meshes/mesh";
  26563. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26564. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26565. import { Plane } from "babylonjs/Maths/math.plane";
  26566. /**
  26567. * Represents one particle of a solid particle system.
  26568. */
  26569. export class SolidParticle {
  26570. /**
  26571. * particle global index
  26572. */
  26573. idx: number;
  26574. /**
  26575. * particle identifier
  26576. */
  26577. id: number;
  26578. /**
  26579. * The color of the particle
  26580. */
  26581. color: Nullable<Color4>;
  26582. /**
  26583. * The world space position of the particle.
  26584. */
  26585. position: Vector3;
  26586. /**
  26587. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26588. */
  26589. rotation: Vector3;
  26590. /**
  26591. * The world space rotation quaternion of the particle.
  26592. */
  26593. rotationQuaternion: Nullable<Quaternion>;
  26594. /**
  26595. * The scaling of the particle.
  26596. */
  26597. scaling: Vector3;
  26598. /**
  26599. * The uvs of the particle.
  26600. */
  26601. uvs: Vector4;
  26602. /**
  26603. * The current speed of the particle.
  26604. */
  26605. velocity: Vector3;
  26606. /**
  26607. * The pivot point in the particle local space.
  26608. */
  26609. pivot: Vector3;
  26610. /**
  26611. * Must the particle be translated from its pivot point in its local space ?
  26612. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26613. * Default : false
  26614. */
  26615. translateFromPivot: boolean;
  26616. /**
  26617. * Is the particle active or not ?
  26618. */
  26619. alive: boolean;
  26620. /**
  26621. * Is the particle visible or not ?
  26622. */
  26623. isVisible: boolean;
  26624. /**
  26625. * Index of this particle in the global "positions" array (Internal use)
  26626. * @hidden
  26627. */
  26628. _pos: number;
  26629. /**
  26630. * @hidden Index of this particle in the global "indices" array (Internal use)
  26631. */
  26632. _ind: number;
  26633. /**
  26634. * @hidden ModelShape of this particle (Internal use)
  26635. */
  26636. _model: ModelShape;
  26637. /**
  26638. * ModelShape id of this particle
  26639. */
  26640. shapeId: number;
  26641. /**
  26642. * Index of the particle in its shape id
  26643. */
  26644. idxInShape: number;
  26645. /**
  26646. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26647. */
  26648. _modelBoundingInfo: BoundingInfo;
  26649. /**
  26650. * @hidden Particle BoundingInfo object (Internal use)
  26651. */
  26652. _boundingInfo: BoundingInfo;
  26653. /**
  26654. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26655. */
  26656. _sps: SolidParticleSystem;
  26657. /**
  26658. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26659. */
  26660. _stillInvisible: boolean;
  26661. /**
  26662. * @hidden Last computed particle rotation matrix
  26663. */
  26664. _rotationMatrix: number[];
  26665. /**
  26666. * Parent particle Id, if any.
  26667. * Default null.
  26668. */
  26669. parentId: Nullable<number>;
  26670. /**
  26671. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26672. * The possible values are :
  26673. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26674. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26675. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26676. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26677. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26678. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26679. * */
  26680. cullingStrategy: number;
  26681. /**
  26682. * @hidden Internal global position in the SPS.
  26683. */
  26684. _globalPosition: Vector3;
  26685. /**
  26686. * Creates a Solid Particle object.
  26687. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26688. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26689. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26690. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26691. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26692. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26693. * @param shapeId (integer) is the model shape identifier in the SPS.
  26694. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26695. * @param sps defines the sps it is associated to
  26696. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26697. */
  26698. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26699. /**
  26700. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26701. * @param target the particle target
  26702. * @returns the current particle
  26703. */
  26704. copyToRef(target: SolidParticle): SolidParticle;
  26705. /**
  26706. * Legacy support, changed scale to scaling
  26707. */
  26708. /**
  26709. * Legacy support, changed scale to scaling
  26710. */
  26711. scale: Vector3;
  26712. /**
  26713. * Legacy support, changed quaternion to rotationQuaternion
  26714. */
  26715. /**
  26716. * Legacy support, changed quaternion to rotationQuaternion
  26717. */
  26718. quaternion: Nullable<Quaternion>;
  26719. /**
  26720. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26721. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26722. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26723. * @returns true if it intersects
  26724. */
  26725. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26726. /**
  26727. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26728. * A particle is in the frustum if its bounding box intersects the frustum
  26729. * @param frustumPlanes defines the frustum to test
  26730. * @returns true if the particle is in the frustum planes
  26731. */
  26732. isInFrustum(frustumPlanes: Plane[]): boolean;
  26733. /**
  26734. * get the rotation matrix of the particle
  26735. * @hidden
  26736. */
  26737. getRotationMatrix(m: Matrix): void;
  26738. }
  26739. /**
  26740. * Represents the shape of the model used by one particle of a solid particle system.
  26741. * SPS internal tool, don't use it manually.
  26742. */
  26743. export class ModelShape {
  26744. /**
  26745. * The shape id
  26746. * @hidden
  26747. */
  26748. shapeID: number;
  26749. /**
  26750. * flat array of model positions (internal use)
  26751. * @hidden
  26752. */
  26753. _shape: Vector3[];
  26754. /**
  26755. * flat array of model UVs (internal use)
  26756. * @hidden
  26757. */
  26758. _shapeUV: number[];
  26759. /**
  26760. * color array of the model
  26761. * @hidden
  26762. */
  26763. _shapeColors: number[];
  26764. /**
  26765. * indices array of the model
  26766. * @hidden
  26767. */
  26768. _indices: number[];
  26769. /**
  26770. * normals array of the model
  26771. * @hidden
  26772. */
  26773. _normals: number[];
  26774. /**
  26775. * length of the shape in the model indices array (internal use)
  26776. * @hidden
  26777. */
  26778. _indicesLength: number;
  26779. /**
  26780. * Custom position function (internal use)
  26781. * @hidden
  26782. */
  26783. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26784. /**
  26785. * Custom vertex function (internal use)
  26786. * @hidden
  26787. */
  26788. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26789. /**
  26790. * 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.
  26791. * SPS internal tool, don't use it manually.
  26792. * @hidden
  26793. */
  26794. 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>);
  26795. }
  26796. /**
  26797. * Represents a Depth Sorted Particle in the solid particle system.
  26798. */
  26799. export class DepthSortedParticle {
  26800. /**
  26801. * Index of the particle in the "indices" array
  26802. */
  26803. ind: number;
  26804. /**
  26805. * Length of the particle shape in the "indices" array
  26806. */
  26807. indicesLength: number;
  26808. /**
  26809. * Squared distance from the particle to the camera
  26810. */
  26811. sqDistance: number;
  26812. }
  26813. }
  26814. declare module "babylonjs/Collisions/meshCollisionData" {
  26815. import { Collider } from "babylonjs/Collisions/collider";
  26816. import { Vector3 } from "babylonjs/Maths/math.vector";
  26817. import { Nullable } from "babylonjs/types";
  26818. import { Observer } from "babylonjs/Misc/observable";
  26819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26820. /**
  26821. * @hidden
  26822. */
  26823. export class _MeshCollisionData {
  26824. _checkCollisions: boolean;
  26825. _collisionMask: number;
  26826. _collisionGroup: number;
  26827. _collider: Nullable<Collider>;
  26828. _oldPositionForCollisions: Vector3;
  26829. _diffPositionForCollisions: Vector3;
  26830. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26831. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26832. }
  26833. }
  26834. declare module "babylonjs/Meshes/abstractMesh" {
  26835. import { Observable } from "babylonjs/Misc/observable";
  26836. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26837. import { Camera } from "babylonjs/Cameras/camera";
  26838. import { Scene, IDisposable } from "babylonjs/scene";
  26839. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26840. import { Node } from "babylonjs/node";
  26841. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26842. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26843. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26844. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26845. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26846. import { Material } from "babylonjs/Materials/material";
  26847. import { Light } from "babylonjs/Lights/light";
  26848. import { Skeleton } from "babylonjs/Bones/skeleton";
  26849. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26850. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26852. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26853. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26854. import { Plane } from "babylonjs/Maths/math.plane";
  26855. import { Ray } from "babylonjs/Culling/ray";
  26856. import { Collider } from "babylonjs/Collisions/collider";
  26857. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26858. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26859. /** @hidden */
  26860. class _FacetDataStorage {
  26861. facetPositions: Vector3[];
  26862. facetNormals: Vector3[];
  26863. facetPartitioning: number[][];
  26864. facetNb: number;
  26865. partitioningSubdivisions: number;
  26866. partitioningBBoxRatio: number;
  26867. facetDataEnabled: boolean;
  26868. facetParameters: any;
  26869. bbSize: Vector3;
  26870. subDiv: {
  26871. max: number;
  26872. X: number;
  26873. Y: number;
  26874. Z: number;
  26875. };
  26876. facetDepthSort: boolean;
  26877. facetDepthSortEnabled: boolean;
  26878. depthSortedIndices: IndicesArray;
  26879. depthSortedFacets: {
  26880. ind: number;
  26881. sqDistance: number;
  26882. }[];
  26883. facetDepthSortFunction: (f1: {
  26884. ind: number;
  26885. sqDistance: number;
  26886. }, f2: {
  26887. ind: number;
  26888. sqDistance: number;
  26889. }) => number;
  26890. facetDepthSortFrom: Vector3;
  26891. facetDepthSortOrigin: Vector3;
  26892. invertedMatrix: Matrix;
  26893. }
  26894. /**
  26895. * @hidden
  26896. **/
  26897. class _InternalAbstractMeshDataInfo {
  26898. _hasVertexAlpha: boolean;
  26899. _useVertexColors: boolean;
  26900. _numBoneInfluencers: number;
  26901. _applyFog: boolean;
  26902. _receiveShadows: boolean;
  26903. _facetData: _FacetDataStorage;
  26904. _visibility: number;
  26905. _skeleton: Nullable<Skeleton>;
  26906. _layerMask: number;
  26907. _computeBonesUsingShaders: boolean;
  26908. _isActive: boolean;
  26909. _onlyForInstances: boolean;
  26910. _isActiveIntermediate: boolean;
  26911. _onlyForInstancesIntermediate: boolean;
  26912. _actAsRegularMesh: boolean;
  26913. }
  26914. /**
  26915. * Class used to store all common mesh properties
  26916. */
  26917. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26918. /** No occlusion */
  26919. static OCCLUSION_TYPE_NONE: number;
  26920. /** Occlusion set to optimisitic */
  26921. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26922. /** Occlusion set to strict */
  26923. static OCCLUSION_TYPE_STRICT: number;
  26924. /** Use an accurante occlusion algorithm */
  26925. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26926. /** Use a conservative occlusion algorithm */
  26927. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26928. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26929. * Test order :
  26930. * Is the bounding sphere outside the frustum ?
  26931. * If not, are the bounding box vertices outside the frustum ?
  26932. * It not, then the cullable object is in the frustum.
  26933. */
  26934. static readonly CULLINGSTRATEGY_STANDARD: number;
  26935. /** Culling strategy : Bounding Sphere Only.
  26936. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26937. * It's also less accurate than the standard because some not visible objects can still be selected.
  26938. * Test : is the bounding sphere outside the frustum ?
  26939. * If not, then the cullable object is in the frustum.
  26940. */
  26941. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26942. /** Culling strategy : Optimistic Inclusion.
  26943. * This in an inclusion test first, then the standard exclusion test.
  26944. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26945. * 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.
  26946. * Anyway, it's as accurate as the standard strategy.
  26947. * Test :
  26948. * Is the cullable object bounding sphere center in the frustum ?
  26949. * If not, apply the default culling strategy.
  26950. */
  26951. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26952. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26953. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26954. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26955. * 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.
  26956. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26957. * Test :
  26958. * Is the cullable object bounding sphere center in the frustum ?
  26959. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26960. */
  26961. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26962. /**
  26963. * No billboard
  26964. */
  26965. static readonly BILLBOARDMODE_NONE: number;
  26966. /** Billboard on X axis */
  26967. static readonly BILLBOARDMODE_X: number;
  26968. /** Billboard on Y axis */
  26969. static readonly BILLBOARDMODE_Y: number;
  26970. /** Billboard on Z axis */
  26971. static readonly BILLBOARDMODE_Z: number;
  26972. /** Billboard on all axes */
  26973. static readonly BILLBOARDMODE_ALL: number;
  26974. /** Billboard on using position instead of orientation */
  26975. static readonly BILLBOARDMODE_USE_POSITION: number;
  26976. /** @hidden */
  26977. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26978. /**
  26979. * The culling strategy to use to check whether the mesh must be rendered or not.
  26980. * This value can be changed at any time and will be used on the next render mesh selection.
  26981. * The possible values are :
  26982. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26983. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26984. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26985. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26986. * Please read each static variable documentation to get details about the culling process.
  26987. * */
  26988. cullingStrategy: number;
  26989. /**
  26990. * Gets the number of facets in the mesh
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26992. */
  26993. readonly facetNb: number;
  26994. /**
  26995. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26997. */
  26998. partitioningSubdivisions: number;
  26999. /**
  27000. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27001. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27003. */
  27004. partitioningBBoxRatio: number;
  27005. /**
  27006. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27007. * Works only for updatable meshes.
  27008. * Doesn't work with multi-materials
  27009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27010. */
  27011. mustDepthSortFacets: boolean;
  27012. /**
  27013. * The location (Vector3) where the facet depth sort must be computed from.
  27014. * By default, the active camera position.
  27015. * Used only when facet depth sort is enabled
  27016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27017. */
  27018. facetDepthSortFrom: Vector3;
  27019. /**
  27020. * gets a boolean indicating if facetData is enabled
  27021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27022. */
  27023. readonly isFacetDataEnabled: boolean;
  27024. /** @hidden */
  27025. _updateNonUniformScalingState(value: boolean): boolean;
  27026. /**
  27027. * An event triggered when this mesh collides with another one
  27028. */
  27029. onCollideObservable: Observable<AbstractMesh>;
  27030. /** Set a function to call when this mesh collides with another one */
  27031. onCollide: () => void;
  27032. /**
  27033. * An event triggered when the collision's position changes
  27034. */
  27035. onCollisionPositionChangeObservable: Observable<Vector3>;
  27036. /** Set a function to call when the collision's position changes */
  27037. onCollisionPositionChange: () => void;
  27038. /**
  27039. * An event triggered when material is changed
  27040. */
  27041. onMaterialChangedObservable: Observable<AbstractMesh>;
  27042. /**
  27043. * Gets or sets the orientation for POV movement & rotation
  27044. */
  27045. definedFacingForward: boolean;
  27046. /** @hidden */
  27047. _occlusionQuery: Nullable<WebGLQuery>;
  27048. /** @hidden */
  27049. _renderingGroup: Nullable<RenderingGroup>;
  27050. /**
  27051. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27052. */
  27053. /**
  27054. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27055. */
  27056. visibility: number;
  27057. /** Gets or sets the alpha index used to sort transparent meshes
  27058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27059. */
  27060. alphaIndex: number;
  27061. /**
  27062. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27063. */
  27064. isVisible: boolean;
  27065. /**
  27066. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27067. */
  27068. isPickable: boolean;
  27069. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27070. showSubMeshesBoundingBox: boolean;
  27071. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27073. */
  27074. isBlocker: boolean;
  27075. /**
  27076. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27077. */
  27078. enablePointerMoveEvents: boolean;
  27079. /**
  27080. * Specifies the rendering group id for this mesh (0 by default)
  27081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27082. */
  27083. renderingGroupId: number;
  27084. private _material;
  27085. /** Gets or sets current material */
  27086. material: Nullable<Material>;
  27087. /**
  27088. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27089. * @see http://doc.babylonjs.com/babylon101/shadows
  27090. */
  27091. receiveShadows: boolean;
  27092. /** Defines color to use when rendering outline */
  27093. outlineColor: Color3;
  27094. /** Define width to use when rendering outline */
  27095. outlineWidth: number;
  27096. /** Defines color to use when rendering overlay */
  27097. overlayColor: Color3;
  27098. /** Defines alpha to use when rendering overlay */
  27099. overlayAlpha: number;
  27100. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27101. hasVertexAlpha: boolean;
  27102. /** 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) */
  27103. useVertexColors: boolean;
  27104. /**
  27105. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27106. */
  27107. computeBonesUsingShaders: boolean;
  27108. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27109. numBoneInfluencers: number;
  27110. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27111. applyFog: boolean;
  27112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27113. useOctreeForRenderingSelection: boolean;
  27114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27115. useOctreeForPicking: boolean;
  27116. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27117. useOctreeForCollisions: boolean;
  27118. /**
  27119. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27120. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27121. */
  27122. layerMask: number;
  27123. /**
  27124. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27125. */
  27126. alwaysSelectAsActiveMesh: boolean;
  27127. /**
  27128. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27129. */
  27130. doNotSyncBoundingInfo: boolean;
  27131. /**
  27132. * Gets or sets the current action manager
  27133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27134. */
  27135. actionManager: Nullable<AbstractActionManager>;
  27136. private _meshCollisionData;
  27137. /**
  27138. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27140. */
  27141. ellipsoid: Vector3;
  27142. /**
  27143. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27145. */
  27146. ellipsoidOffset: Vector3;
  27147. /**
  27148. * Gets or sets a collision mask used to mask collisions (default is -1).
  27149. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27150. */
  27151. collisionMask: number;
  27152. /**
  27153. * Gets or sets the current collision group mask (-1 by default).
  27154. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27155. */
  27156. collisionGroup: number;
  27157. /**
  27158. * Defines edge width used when edgesRenderer is enabled
  27159. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27160. */
  27161. edgesWidth: number;
  27162. /**
  27163. * Defines edge color used when edgesRenderer is enabled
  27164. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27165. */
  27166. edgesColor: Color4;
  27167. /** @hidden */
  27168. _edgesRenderer: Nullable<IEdgesRenderer>;
  27169. /** @hidden */
  27170. _masterMesh: Nullable<AbstractMesh>;
  27171. /** @hidden */
  27172. _boundingInfo: Nullable<BoundingInfo>;
  27173. /** @hidden */
  27174. _renderId: number;
  27175. /**
  27176. * Gets or sets the list of subMeshes
  27177. * @see http://doc.babylonjs.com/how_to/multi_materials
  27178. */
  27179. subMeshes: SubMesh[];
  27180. /** @hidden */
  27181. _intersectionsInProgress: AbstractMesh[];
  27182. /** @hidden */
  27183. _unIndexed: boolean;
  27184. /** @hidden */
  27185. _lightSources: Light[];
  27186. /** Gets the list of lights affecting that mesh */
  27187. readonly lightSources: Light[];
  27188. /** @hidden */
  27189. readonly _positions: Nullable<Vector3[]>;
  27190. /** @hidden */
  27191. _waitingData: {
  27192. lods: Nullable<any>;
  27193. actions: Nullable<any>;
  27194. freezeWorldMatrix: Nullable<boolean>;
  27195. };
  27196. /** @hidden */
  27197. _bonesTransformMatrices: Nullable<Float32Array>;
  27198. /** @hidden */
  27199. _transformMatrixTexture: Nullable<RawTexture>;
  27200. /**
  27201. * Gets or sets a skeleton to apply skining transformations
  27202. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27203. */
  27204. skeleton: Nullable<Skeleton>;
  27205. /**
  27206. * An event triggered when the mesh is rebuilt.
  27207. */
  27208. onRebuildObservable: Observable<AbstractMesh>;
  27209. /**
  27210. * Creates a new AbstractMesh
  27211. * @param name defines the name of the mesh
  27212. * @param scene defines the hosting scene
  27213. */
  27214. constructor(name: string, scene?: Nullable<Scene>);
  27215. /**
  27216. * Returns the string "AbstractMesh"
  27217. * @returns "AbstractMesh"
  27218. */
  27219. getClassName(): string;
  27220. /**
  27221. * Gets a string representation of the current mesh
  27222. * @param fullDetails defines a boolean indicating if full details must be included
  27223. * @returns a string representation of the current mesh
  27224. */
  27225. toString(fullDetails?: boolean): string;
  27226. /**
  27227. * @hidden
  27228. */
  27229. protected _getEffectiveParent(): Nullable<Node>;
  27230. /** @hidden */
  27231. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27232. /** @hidden */
  27233. _rebuild(): void;
  27234. /** @hidden */
  27235. _resyncLightSources(): void;
  27236. /** @hidden */
  27237. _resyncLighSource(light: Light): void;
  27238. /** @hidden */
  27239. _unBindEffect(): void;
  27240. /** @hidden */
  27241. _removeLightSource(light: Light, dispose: boolean): void;
  27242. private _markSubMeshesAsDirty;
  27243. /** @hidden */
  27244. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27245. /** @hidden */
  27246. _markSubMeshesAsAttributesDirty(): void;
  27247. /** @hidden */
  27248. _markSubMeshesAsMiscDirty(): void;
  27249. /**
  27250. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27251. */
  27252. scaling: Vector3;
  27253. /**
  27254. * Returns true if the mesh is blocked. Implemented by child classes
  27255. */
  27256. readonly isBlocked: boolean;
  27257. /**
  27258. * Returns the mesh itself by default. Implemented by child classes
  27259. * @param camera defines the camera to use to pick the right LOD level
  27260. * @returns the currentAbstractMesh
  27261. */
  27262. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27263. /**
  27264. * Returns 0 by default. Implemented by child classes
  27265. * @returns an integer
  27266. */
  27267. getTotalVertices(): number;
  27268. /**
  27269. * Returns a positive integer : the total number of indices in this mesh geometry.
  27270. * @returns the numner of indices or zero if the mesh has no geometry.
  27271. */
  27272. getTotalIndices(): number;
  27273. /**
  27274. * Returns null by default. Implemented by child classes
  27275. * @returns null
  27276. */
  27277. getIndices(): Nullable<IndicesArray>;
  27278. /**
  27279. * Returns the array of the requested vertex data kind. Implemented by child classes
  27280. * @param kind defines the vertex data kind to use
  27281. * @returns null
  27282. */
  27283. getVerticesData(kind: string): Nullable<FloatArray>;
  27284. /**
  27285. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27286. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27287. * Note that a new underlying VertexBuffer object is created each call.
  27288. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27289. * @param kind defines vertex data kind:
  27290. * * VertexBuffer.PositionKind
  27291. * * VertexBuffer.UVKind
  27292. * * VertexBuffer.UV2Kind
  27293. * * VertexBuffer.UV3Kind
  27294. * * VertexBuffer.UV4Kind
  27295. * * VertexBuffer.UV5Kind
  27296. * * VertexBuffer.UV6Kind
  27297. * * VertexBuffer.ColorKind
  27298. * * VertexBuffer.MatricesIndicesKind
  27299. * * VertexBuffer.MatricesIndicesExtraKind
  27300. * * VertexBuffer.MatricesWeightsKind
  27301. * * VertexBuffer.MatricesWeightsExtraKind
  27302. * @param data defines the data source
  27303. * @param updatable defines if the data must be flagged as updatable (or static)
  27304. * @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
  27305. * @returns the current mesh
  27306. */
  27307. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27308. /**
  27309. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27310. * If the mesh has no geometry, it is simply returned as it is.
  27311. * @param kind defines vertex data kind:
  27312. * * VertexBuffer.PositionKind
  27313. * * VertexBuffer.UVKind
  27314. * * VertexBuffer.UV2Kind
  27315. * * VertexBuffer.UV3Kind
  27316. * * VertexBuffer.UV4Kind
  27317. * * VertexBuffer.UV5Kind
  27318. * * VertexBuffer.UV6Kind
  27319. * * VertexBuffer.ColorKind
  27320. * * VertexBuffer.MatricesIndicesKind
  27321. * * VertexBuffer.MatricesIndicesExtraKind
  27322. * * VertexBuffer.MatricesWeightsKind
  27323. * * VertexBuffer.MatricesWeightsExtraKind
  27324. * @param data defines the data source
  27325. * @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
  27326. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27327. * @returns the current mesh
  27328. */
  27329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27330. /**
  27331. * Sets the mesh indices,
  27332. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27333. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27334. * @param totalVertices Defines the total number of vertices
  27335. * @returns the current mesh
  27336. */
  27337. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27338. /**
  27339. * Gets a boolean indicating if specific vertex data is present
  27340. * @param kind defines the vertex data kind to use
  27341. * @returns true is data kind is present
  27342. */
  27343. isVerticesDataPresent(kind: string): boolean;
  27344. /**
  27345. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27346. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27347. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27348. * @returns a BoundingInfo
  27349. */
  27350. getBoundingInfo(): BoundingInfo;
  27351. /**
  27352. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27353. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27354. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27355. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27356. * @returns the current mesh
  27357. */
  27358. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27359. /**
  27360. * Overwrite the current bounding info
  27361. * @param boundingInfo defines the new bounding info
  27362. * @returns the current mesh
  27363. */
  27364. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27365. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27366. readonly useBones: boolean;
  27367. /** @hidden */
  27368. _preActivate(): void;
  27369. /** @hidden */
  27370. _preActivateForIntermediateRendering(renderId: number): void;
  27371. /** @hidden */
  27372. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27373. /** @hidden */
  27374. _postActivate(): void;
  27375. /** @hidden */
  27376. _freeze(): void;
  27377. /** @hidden */
  27378. _unFreeze(): void;
  27379. /**
  27380. * Gets the current world matrix
  27381. * @returns a Matrix
  27382. */
  27383. getWorldMatrix(): Matrix;
  27384. /** @hidden */
  27385. _getWorldMatrixDeterminant(): number;
  27386. /**
  27387. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27388. */
  27389. readonly isAnInstance: boolean;
  27390. /**
  27391. * Gets a boolean indicating if this mesh has instances
  27392. */
  27393. readonly hasInstances: boolean;
  27394. /**
  27395. * Perform relative position change from the point of view of behind the front of the mesh.
  27396. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27397. * Supports definition of mesh facing forward or backward
  27398. * @param amountRight defines the distance on the right axis
  27399. * @param amountUp defines the distance on the up axis
  27400. * @param amountForward defines the distance on the forward axis
  27401. * @returns the current mesh
  27402. */
  27403. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27404. /**
  27405. * Calculate relative position change from the point of view of behind the front of the mesh.
  27406. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27407. * Supports definition of mesh facing forward or backward
  27408. * @param amountRight defines the distance on the right axis
  27409. * @param amountUp defines the distance on the up axis
  27410. * @param amountForward defines the distance on the forward axis
  27411. * @returns the new displacement vector
  27412. */
  27413. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27414. /**
  27415. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27416. * Supports definition of mesh facing forward or backward
  27417. * @param flipBack defines the flip
  27418. * @param twirlClockwise defines the twirl
  27419. * @param tiltRight defines the tilt
  27420. * @returns the current mesh
  27421. */
  27422. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27423. /**
  27424. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27425. * Supports definition of mesh facing forward or backward.
  27426. * @param flipBack defines the flip
  27427. * @param twirlClockwise defines the twirl
  27428. * @param tiltRight defines the tilt
  27429. * @returns the new rotation vector
  27430. */
  27431. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27432. /**
  27433. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27434. * This means the mesh underlying bounding box and sphere are recomputed.
  27435. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27436. * @returns the current mesh
  27437. */
  27438. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27439. /** @hidden */
  27440. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27441. /** @hidden */
  27442. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27443. /** @hidden */
  27444. _updateBoundingInfo(): AbstractMesh;
  27445. /** @hidden */
  27446. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27447. /** @hidden */
  27448. protected _afterComputeWorldMatrix(): void;
  27449. /** @hidden */
  27450. readonly _effectiveMesh: AbstractMesh;
  27451. /**
  27452. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27453. * A mesh is in the frustum if its bounding box intersects the frustum
  27454. * @param frustumPlanes defines the frustum to test
  27455. * @returns true if the mesh is in the frustum planes
  27456. */
  27457. isInFrustum(frustumPlanes: Plane[]): boolean;
  27458. /**
  27459. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27460. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27461. * @param frustumPlanes defines the frustum to test
  27462. * @returns true if the mesh is completely in the frustum planes
  27463. */
  27464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27465. /**
  27466. * True if the mesh intersects another mesh or a SolidParticle object
  27467. * @param mesh defines a target mesh or SolidParticle to test
  27468. * @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)
  27469. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27470. * @returns true if there is an intersection
  27471. */
  27472. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27473. /**
  27474. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27475. * @param point defines the point to test
  27476. * @returns true if there is an intersection
  27477. */
  27478. intersectsPoint(point: Vector3): boolean;
  27479. /**
  27480. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27481. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27482. */
  27483. checkCollisions: boolean;
  27484. /**
  27485. * Gets Collider object used to compute collisions (not physics)
  27486. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27487. */
  27488. readonly collider: Nullable<Collider>;
  27489. /**
  27490. * Move the mesh using collision engine
  27491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27492. * @param displacement defines the requested displacement vector
  27493. * @returns the current mesh
  27494. */
  27495. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27496. private _onCollisionPositionChange;
  27497. /** @hidden */
  27498. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27499. /** @hidden */
  27500. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27501. /** @hidden */
  27502. _checkCollision(collider: Collider): AbstractMesh;
  27503. /** @hidden */
  27504. _generatePointsArray(): boolean;
  27505. /**
  27506. * Checks if the passed Ray intersects with the mesh
  27507. * @param ray defines the ray to use
  27508. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27510. * @returns the picking info
  27511. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27512. */
  27513. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27514. /**
  27515. * Clones the current mesh
  27516. * @param name defines the mesh name
  27517. * @param newParent defines the new mesh parent
  27518. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27519. * @returns the new mesh
  27520. */
  27521. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27522. /**
  27523. * Disposes all the submeshes of the current meshnp
  27524. * @returns the current mesh
  27525. */
  27526. releaseSubMeshes(): AbstractMesh;
  27527. /**
  27528. * Releases resources associated with this abstract mesh.
  27529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27531. */
  27532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27533. /**
  27534. * Adds the passed mesh as a child to the current mesh
  27535. * @param mesh defines the child mesh
  27536. * @returns the current mesh
  27537. */
  27538. addChild(mesh: AbstractMesh): AbstractMesh;
  27539. /**
  27540. * Removes the passed mesh from the current mesh children list
  27541. * @param mesh defines the child mesh
  27542. * @returns the current mesh
  27543. */
  27544. removeChild(mesh: AbstractMesh): AbstractMesh;
  27545. /** @hidden */
  27546. private _initFacetData;
  27547. /**
  27548. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27549. * This method can be called within the render loop.
  27550. * 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
  27551. * @returns the current mesh
  27552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27553. */
  27554. updateFacetData(): AbstractMesh;
  27555. /**
  27556. * Returns the facetLocalNormals array.
  27557. * The normals are expressed in the mesh local spac
  27558. * @returns an array of Vector3
  27559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27560. */
  27561. getFacetLocalNormals(): Vector3[];
  27562. /**
  27563. * Returns the facetLocalPositions array.
  27564. * The facet positions are expressed in the mesh local space
  27565. * @returns an array of Vector3
  27566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27567. */
  27568. getFacetLocalPositions(): Vector3[];
  27569. /**
  27570. * Returns the facetLocalPartioning array
  27571. * @returns an array of array of numbers
  27572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27573. */
  27574. getFacetLocalPartitioning(): number[][];
  27575. /**
  27576. * Returns the i-th facet position in the world system.
  27577. * This method allocates a new Vector3 per call
  27578. * @param i defines the facet index
  27579. * @returns a new Vector3
  27580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27581. */
  27582. getFacetPosition(i: number): Vector3;
  27583. /**
  27584. * Sets the reference Vector3 with the i-th facet position in the world system
  27585. * @param i defines the facet index
  27586. * @param ref defines the target vector
  27587. * @returns the current mesh
  27588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27589. */
  27590. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27591. /**
  27592. * Returns the i-th facet normal in the world system.
  27593. * This method allocates a new Vector3 per call
  27594. * @param i defines the facet index
  27595. * @returns a new Vector3
  27596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27597. */
  27598. getFacetNormal(i: number): Vector3;
  27599. /**
  27600. * Sets the reference Vector3 with the i-th facet normal in the world system
  27601. * @param i defines the facet index
  27602. * @param ref defines the target vector
  27603. * @returns the current mesh
  27604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27605. */
  27606. getFacetNormalToRef(i: number, ref: Vector3): this;
  27607. /**
  27608. * 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)
  27609. * @param x defines x coordinate
  27610. * @param y defines y coordinate
  27611. * @param z defines z coordinate
  27612. * @returns the array of facet indexes
  27613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27614. */
  27615. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27616. /**
  27617. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27618. * @param projected sets as the (x,y,z) world projection on the facet
  27619. * @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
  27620. * @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
  27621. * @param x defines x coordinate
  27622. * @param y defines y coordinate
  27623. * @param z defines z coordinate
  27624. * @returns the face index if found (or null instead)
  27625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27626. */
  27627. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27628. /**
  27629. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27630. * @param projected sets as the (x,y,z) local projection on the facet
  27631. * @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
  27632. * @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
  27633. * @param x defines x coordinate
  27634. * @param y defines y coordinate
  27635. * @param z defines z coordinate
  27636. * @returns the face index if found (or null instead)
  27637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27638. */
  27639. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27640. /**
  27641. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27642. * @returns the parameters
  27643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27644. */
  27645. getFacetDataParameters(): any;
  27646. /**
  27647. * Disables the feature FacetData and frees the related memory
  27648. * @returns the current mesh
  27649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27650. */
  27651. disableFacetData(): AbstractMesh;
  27652. /**
  27653. * Updates the AbstractMesh indices array
  27654. * @param indices defines the data source
  27655. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27656. * @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)
  27657. * @returns the current mesh
  27658. */
  27659. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27660. /**
  27661. * Creates new normals data for the mesh
  27662. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27663. * @returns the current mesh
  27664. */
  27665. createNormals(updatable: boolean): AbstractMesh;
  27666. /**
  27667. * Align the mesh with a normal
  27668. * @param normal defines the normal to use
  27669. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27670. * @returns the current mesh
  27671. */
  27672. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27673. /** @hidden */
  27674. _checkOcclusionQuery(): boolean;
  27675. /**
  27676. * Disables the mesh edge rendering mode
  27677. * @returns the currentAbstractMesh
  27678. */
  27679. disableEdgesRendering(): AbstractMesh;
  27680. /**
  27681. * Enables the edge rendering mode on the mesh.
  27682. * This mode makes the mesh edges visible
  27683. * @param epsilon defines the maximal distance between two angles to detect a face
  27684. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27685. * @returns the currentAbstractMesh
  27686. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27687. */
  27688. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27689. }
  27690. }
  27691. declare module "babylonjs/Actions/actionEvent" {
  27692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27693. import { Nullable } from "babylonjs/types";
  27694. import { Sprite } from "babylonjs/Sprites/sprite";
  27695. import { Scene } from "babylonjs/scene";
  27696. import { Vector2 } from "babylonjs/Maths/math.vector";
  27697. /**
  27698. * Interface used to define ActionEvent
  27699. */
  27700. export interface IActionEvent {
  27701. /** The mesh or sprite that triggered the action */
  27702. source: any;
  27703. /** The X mouse cursor position at the time of the event */
  27704. pointerX: number;
  27705. /** The Y mouse cursor position at the time of the event */
  27706. pointerY: number;
  27707. /** The mesh that is currently pointed at (can be null) */
  27708. meshUnderPointer: Nullable<AbstractMesh>;
  27709. /** the original (browser) event that triggered the ActionEvent */
  27710. sourceEvent?: any;
  27711. /** additional data for the event */
  27712. additionalData?: any;
  27713. }
  27714. /**
  27715. * ActionEvent is the event being sent when an action is triggered.
  27716. */
  27717. export class ActionEvent implements IActionEvent {
  27718. /** The mesh or sprite that triggered the action */
  27719. source: any;
  27720. /** The X mouse cursor position at the time of the event */
  27721. pointerX: number;
  27722. /** The Y mouse cursor position at the time of the event */
  27723. pointerY: number;
  27724. /** The mesh that is currently pointed at (can be null) */
  27725. meshUnderPointer: Nullable<AbstractMesh>;
  27726. /** the original (browser) event that triggered the ActionEvent */
  27727. sourceEvent?: any;
  27728. /** additional data for the event */
  27729. additionalData?: any;
  27730. /**
  27731. * Creates a new ActionEvent
  27732. * @param source The mesh or sprite that triggered the action
  27733. * @param pointerX The X mouse cursor position at the time of the event
  27734. * @param pointerY The Y mouse cursor position at the time of the event
  27735. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27736. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27737. * @param additionalData additional data for the event
  27738. */
  27739. constructor(
  27740. /** The mesh or sprite that triggered the action */
  27741. source: any,
  27742. /** The X mouse cursor position at the time of the event */
  27743. pointerX: number,
  27744. /** The Y mouse cursor position at the time of the event */
  27745. pointerY: number,
  27746. /** The mesh that is currently pointed at (can be null) */
  27747. meshUnderPointer: Nullable<AbstractMesh>,
  27748. /** the original (browser) event that triggered the ActionEvent */
  27749. sourceEvent?: any,
  27750. /** additional data for the event */
  27751. additionalData?: any);
  27752. /**
  27753. * Helper function to auto-create an ActionEvent from a source mesh.
  27754. * @param source The source mesh that triggered the event
  27755. * @param evt The original (browser) event
  27756. * @param additionalData additional data for the event
  27757. * @returns the new ActionEvent
  27758. */
  27759. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27760. /**
  27761. * Helper function to auto-create an ActionEvent from a source sprite
  27762. * @param source The source sprite that triggered the event
  27763. * @param scene Scene associated with the sprite
  27764. * @param evt The original (browser) event
  27765. * @param additionalData additional data for the event
  27766. * @returns the new ActionEvent
  27767. */
  27768. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27769. /**
  27770. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27771. * @param scene the scene where the event occurred
  27772. * @param evt The original (browser) event
  27773. * @returns the new ActionEvent
  27774. */
  27775. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27776. /**
  27777. * Helper function to auto-create an ActionEvent from a primitive
  27778. * @param prim defines the target primitive
  27779. * @param pointerPos defines the pointer position
  27780. * @param evt The original (browser) event
  27781. * @param additionalData additional data for the event
  27782. * @returns the new ActionEvent
  27783. */
  27784. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27785. }
  27786. }
  27787. declare module "babylonjs/Actions/abstractActionManager" {
  27788. import { IDisposable } from "babylonjs/scene";
  27789. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27790. import { IAction } from "babylonjs/Actions/action";
  27791. import { Nullable } from "babylonjs/types";
  27792. /**
  27793. * Abstract class used to decouple action Manager from scene and meshes.
  27794. * Do not instantiate.
  27795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27796. */
  27797. export abstract class AbstractActionManager implements IDisposable {
  27798. /** Gets the list of active triggers */
  27799. static Triggers: {
  27800. [key: string]: number;
  27801. };
  27802. /** Gets the cursor to use when hovering items */
  27803. hoverCursor: string;
  27804. /** Gets the list of actions */
  27805. actions: IAction[];
  27806. /**
  27807. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27808. */
  27809. isRecursive: boolean;
  27810. /**
  27811. * Releases all associated resources
  27812. */
  27813. abstract dispose(): void;
  27814. /**
  27815. * Does this action manager has pointer triggers
  27816. */
  27817. abstract readonly hasPointerTriggers: boolean;
  27818. /**
  27819. * Does this action manager has pick triggers
  27820. */
  27821. abstract readonly hasPickTriggers: boolean;
  27822. /**
  27823. * Process a specific trigger
  27824. * @param trigger defines the trigger to process
  27825. * @param evt defines the event details to be processed
  27826. */
  27827. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27828. /**
  27829. * Does this action manager handles actions of any of the given triggers
  27830. * @param triggers defines the triggers to be tested
  27831. * @return a boolean indicating whether one (or more) of the triggers is handled
  27832. */
  27833. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27834. /**
  27835. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27836. * speed.
  27837. * @param triggerA defines the trigger to be tested
  27838. * @param triggerB defines the trigger to be tested
  27839. * @return a boolean indicating whether one (or more) of the triggers is handled
  27840. */
  27841. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27842. /**
  27843. * Does this action manager handles actions of a given trigger
  27844. * @param trigger defines the trigger to be tested
  27845. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27846. * @return whether the trigger is handled
  27847. */
  27848. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27849. /**
  27850. * Serialize this manager to a JSON object
  27851. * @param name defines the property name to store this manager
  27852. * @returns a JSON representation of this manager
  27853. */
  27854. abstract serialize(name: string): any;
  27855. /**
  27856. * Registers an action to this action manager
  27857. * @param action defines the action to be registered
  27858. * @return the action amended (prepared) after registration
  27859. */
  27860. abstract registerAction(action: IAction): Nullable<IAction>;
  27861. /**
  27862. * Unregisters an action to this action manager
  27863. * @param action defines the action to be unregistered
  27864. * @return a boolean indicating whether the action has been unregistered
  27865. */
  27866. abstract unregisterAction(action: IAction): Boolean;
  27867. /**
  27868. * Does exist one action manager with at least one trigger
  27869. **/
  27870. static readonly HasTriggers: boolean;
  27871. /**
  27872. * Does exist one action manager with at least one pick trigger
  27873. **/
  27874. static readonly HasPickTriggers: boolean;
  27875. /**
  27876. * Does exist one action manager that handles actions of a given trigger
  27877. * @param trigger defines the trigger to be tested
  27878. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27879. **/
  27880. static HasSpecificTrigger(trigger: number): boolean;
  27881. }
  27882. }
  27883. declare module "babylonjs/node" {
  27884. import { Scene } from "babylonjs/scene";
  27885. import { Nullable } from "babylonjs/types";
  27886. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27887. import { Engine } from "babylonjs/Engines/engine";
  27888. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27889. import { Observable } from "babylonjs/Misc/observable";
  27890. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27891. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27892. import { Animatable } from "babylonjs/Animations/animatable";
  27893. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27894. import { Animation } from "babylonjs/Animations/animation";
  27895. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27897. /**
  27898. * Defines how a node can be built from a string name.
  27899. */
  27900. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27901. /**
  27902. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27903. */
  27904. export class Node implements IBehaviorAware<Node> {
  27905. /** @hidden */
  27906. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27907. private static _NodeConstructors;
  27908. /**
  27909. * Add a new node constructor
  27910. * @param type defines the type name of the node to construct
  27911. * @param constructorFunc defines the constructor function
  27912. */
  27913. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27914. /**
  27915. * Returns a node constructor based on type name
  27916. * @param type defines the type name
  27917. * @param name defines the new node name
  27918. * @param scene defines the hosting scene
  27919. * @param options defines optional options to transmit to constructors
  27920. * @returns the new constructor or null
  27921. */
  27922. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27923. /**
  27924. * Gets or sets the name of the node
  27925. */
  27926. name: string;
  27927. /**
  27928. * Gets or sets the id of the node
  27929. */
  27930. id: string;
  27931. /**
  27932. * Gets or sets the unique id of the node
  27933. */
  27934. uniqueId: number;
  27935. /**
  27936. * Gets or sets a string used to store user defined state for the node
  27937. */
  27938. state: string;
  27939. /**
  27940. * Gets or sets an object used to store user defined information for the node
  27941. */
  27942. metadata: any;
  27943. /**
  27944. * For internal use only. Please do not use.
  27945. */
  27946. reservedDataStore: any;
  27947. /**
  27948. * List of inspectable custom properties (used by the Inspector)
  27949. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27950. */
  27951. inspectableCustomProperties: IInspectable[];
  27952. private _doNotSerialize;
  27953. /**
  27954. * Gets or sets a boolean used to define if the node must be serialized
  27955. */
  27956. doNotSerialize: boolean;
  27957. /** @hidden */
  27958. _isDisposed: boolean;
  27959. /**
  27960. * Gets a list of Animations associated with the node
  27961. */
  27962. animations: import("babylonjs/Animations/animation").Animation[];
  27963. protected _ranges: {
  27964. [name: string]: Nullable<AnimationRange>;
  27965. };
  27966. /**
  27967. * Callback raised when the node is ready to be used
  27968. */
  27969. onReady: Nullable<(node: Node) => void>;
  27970. private _isEnabled;
  27971. private _isParentEnabled;
  27972. private _isReady;
  27973. /** @hidden */
  27974. _currentRenderId: number;
  27975. private _parentUpdateId;
  27976. /** @hidden */
  27977. _childUpdateId: number;
  27978. /** @hidden */
  27979. _waitingParentId: Nullable<string>;
  27980. /** @hidden */
  27981. _scene: Scene;
  27982. /** @hidden */
  27983. _cache: any;
  27984. private _parentNode;
  27985. private _children;
  27986. /** @hidden */
  27987. _worldMatrix: Matrix;
  27988. /** @hidden */
  27989. _worldMatrixDeterminant: number;
  27990. /** @hidden */
  27991. _worldMatrixDeterminantIsDirty: boolean;
  27992. /** @hidden */
  27993. private _sceneRootNodesIndex;
  27994. /**
  27995. * Gets a boolean indicating if the node has been disposed
  27996. * @returns true if the node was disposed
  27997. */
  27998. isDisposed(): boolean;
  27999. /**
  28000. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28001. * @see https://doc.babylonjs.com/how_to/parenting
  28002. */
  28003. parent: Nullable<Node>;
  28004. /** @hidden */
  28005. _addToSceneRootNodes(): void;
  28006. /** @hidden */
  28007. _removeFromSceneRootNodes(): void;
  28008. private _animationPropertiesOverride;
  28009. /**
  28010. * Gets or sets the animation properties override
  28011. */
  28012. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28013. /**
  28014. * Gets a string idenfifying the name of the class
  28015. * @returns "Node" string
  28016. */
  28017. getClassName(): string;
  28018. /** @hidden */
  28019. readonly _isNode: boolean;
  28020. /**
  28021. * An event triggered when the mesh is disposed
  28022. */
  28023. onDisposeObservable: Observable<Node>;
  28024. private _onDisposeObserver;
  28025. /**
  28026. * Sets a callback that will be raised when the node will be disposed
  28027. */
  28028. onDispose: () => void;
  28029. /**
  28030. * Creates a new Node
  28031. * @param name the name and id to be given to this node
  28032. * @param scene the scene this node will be added to
  28033. */
  28034. constructor(name: string, scene?: Nullable<Scene>);
  28035. /**
  28036. * Gets the scene of the node
  28037. * @returns a scene
  28038. */
  28039. getScene(): Scene;
  28040. /**
  28041. * Gets the engine of the node
  28042. * @returns a Engine
  28043. */
  28044. getEngine(): Engine;
  28045. private _behaviors;
  28046. /**
  28047. * Attach a behavior to the node
  28048. * @see http://doc.babylonjs.com/features/behaviour
  28049. * @param behavior defines the behavior to attach
  28050. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28051. * @returns the current Node
  28052. */
  28053. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28054. /**
  28055. * Remove an attached behavior
  28056. * @see http://doc.babylonjs.com/features/behaviour
  28057. * @param behavior defines the behavior to attach
  28058. * @returns the current Node
  28059. */
  28060. removeBehavior(behavior: Behavior<Node>): Node;
  28061. /**
  28062. * Gets the list of attached behaviors
  28063. * @see http://doc.babylonjs.com/features/behaviour
  28064. */
  28065. readonly behaviors: Behavior<Node>[];
  28066. /**
  28067. * Gets an attached behavior by name
  28068. * @param name defines the name of the behavior to look for
  28069. * @see http://doc.babylonjs.com/features/behaviour
  28070. * @returns null if behavior was not found else the requested behavior
  28071. */
  28072. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28073. /**
  28074. * Returns the latest update of the World matrix
  28075. * @returns a Matrix
  28076. */
  28077. getWorldMatrix(): Matrix;
  28078. /** @hidden */
  28079. _getWorldMatrixDeterminant(): number;
  28080. /**
  28081. * Returns directly the latest state of the mesh World matrix.
  28082. * A Matrix is returned.
  28083. */
  28084. readonly worldMatrixFromCache: Matrix;
  28085. /** @hidden */
  28086. _initCache(): void;
  28087. /** @hidden */
  28088. updateCache(force?: boolean): void;
  28089. /** @hidden */
  28090. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28091. /** @hidden */
  28092. _updateCache(ignoreParentClass?: boolean): void;
  28093. /** @hidden */
  28094. _isSynchronized(): boolean;
  28095. /** @hidden */
  28096. _markSyncedWithParent(): void;
  28097. /** @hidden */
  28098. isSynchronizedWithParent(): boolean;
  28099. /** @hidden */
  28100. isSynchronized(): boolean;
  28101. /**
  28102. * Is this node ready to be used/rendered
  28103. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28104. * @return true if the node is ready
  28105. */
  28106. isReady(completeCheck?: boolean): boolean;
  28107. /**
  28108. * Is this node enabled?
  28109. * 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
  28110. * @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
  28111. * @return whether this node (and its parent) is enabled
  28112. */
  28113. isEnabled(checkAncestors?: boolean): boolean;
  28114. /** @hidden */
  28115. protected _syncParentEnabledState(): void;
  28116. /**
  28117. * Set the enabled state of this node
  28118. * @param value defines the new enabled state
  28119. */
  28120. setEnabled(value: boolean): void;
  28121. /**
  28122. * Is this node a descendant of the given node?
  28123. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28124. * @param ancestor defines the parent node to inspect
  28125. * @returns a boolean indicating if this node is a descendant of the given node
  28126. */
  28127. isDescendantOf(ancestor: Node): boolean;
  28128. /** @hidden */
  28129. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28130. /**
  28131. * Will return all nodes that have this node as ascendant
  28132. * @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
  28133. * @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
  28134. * @return all children nodes of all types
  28135. */
  28136. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28137. /**
  28138. * Get all child-meshes of this node
  28139. * @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)
  28140. * @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
  28141. * @returns an array of AbstractMesh
  28142. */
  28143. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28144. /**
  28145. * Get all direct children of this node
  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. * @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)
  28148. * @returns an array of Node
  28149. */
  28150. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28151. /** @hidden */
  28152. _setReady(state: boolean): void;
  28153. /**
  28154. * Get an animation by name
  28155. * @param name defines the name of the animation to look for
  28156. * @returns null if not found else the requested animation
  28157. */
  28158. getAnimationByName(name: string): Nullable<Animation>;
  28159. /**
  28160. * Creates an animation range for this node
  28161. * @param name defines the name of the range
  28162. * @param from defines the starting key
  28163. * @param to defines the end key
  28164. */
  28165. createAnimationRange(name: string, from: number, to: number): void;
  28166. /**
  28167. * Delete a specific animation range
  28168. * @param name defines the name of the range to delete
  28169. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28170. */
  28171. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28172. /**
  28173. * Get an animation range by name
  28174. * @param name defines the name of the animation range to look for
  28175. * @returns null if not found else the requested animation range
  28176. */
  28177. getAnimationRange(name: string): Nullable<AnimationRange>;
  28178. /**
  28179. * Gets the list of all animation ranges defined on this node
  28180. * @returns an array
  28181. */
  28182. getAnimationRanges(): Nullable<AnimationRange>[];
  28183. /**
  28184. * Will start the animation sequence
  28185. * @param name defines the range frames for animation sequence
  28186. * @param loop defines if the animation should loop (false by default)
  28187. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28188. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28189. * @returns the object created for this animation. If range does not exist, it will return null
  28190. */
  28191. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28192. /**
  28193. * Serialize animation ranges into a JSON compatible object
  28194. * @returns serialization object
  28195. */
  28196. serializeAnimationRanges(): any;
  28197. /**
  28198. * Computes the world matrix of the node
  28199. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28200. * @returns the world matrix
  28201. */
  28202. computeWorldMatrix(force?: boolean): Matrix;
  28203. /**
  28204. * Releases resources associated with this node.
  28205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28207. */
  28208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28209. /**
  28210. * Parse animation range data from a serialization object and store them into a given node
  28211. * @param node defines where to store the animation ranges
  28212. * @param parsedNode defines the serialization object to read data from
  28213. * @param scene defines the hosting scene
  28214. */
  28215. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28216. /**
  28217. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28218. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28219. * @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
  28220. * @returns the new bounding vectors
  28221. */
  28222. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28223. min: Vector3;
  28224. max: Vector3;
  28225. };
  28226. }
  28227. }
  28228. declare module "babylonjs/Animations/animation" {
  28229. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28230. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28231. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28232. import { Nullable } from "babylonjs/types";
  28233. import { Scene } from "babylonjs/scene";
  28234. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28235. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28236. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28237. import { Node } from "babylonjs/node";
  28238. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28239. import { Size } from "babylonjs/Maths/math.size";
  28240. import { Animatable } from "babylonjs/Animations/animatable";
  28241. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28242. /**
  28243. * @hidden
  28244. */
  28245. export class _IAnimationState {
  28246. key: number;
  28247. repeatCount: number;
  28248. workValue?: any;
  28249. loopMode?: number;
  28250. offsetValue?: any;
  28251. highLimitValue?: any;
  28252. }
  28253. /**
  28254. * Class used to store any kind of animation
  28255. */
  28256. export class Animation {
  28257. /**Name of the animation */
  28258. name: string;
  28259. /**Property to animate */
  28260. targetProperty: string;
  28261. /**The frames per second of the animation */
  28262. framePerSecond: number;
  28263. /**The data type of the animation */
  28264. dataType: number;
  28265. /**The loop mode of the animation */
  28266. loopMode?: number | undefined;
  28267. /**Specifies if blending should be enabled */
  28268. enableBlending?: boolean | undefined;
  28269. /**
  28270. * Use matrix interpolation instead of using direct key value when animating matrices
  28271. */
  28272. static AllowMatricesInterpolation: boolean;
  28273. /**
  28274. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28275. */
  28276. static AllowMatrixDecomposeForInterpolation: boolean;
  28277. /**
  28278. * Stores the key frames of the animation
  28279. */
  28280. private _keys;
  28281. /**
  28282. * Stores the easing function of the animation
  28283. */
  28284. private _easingFunction;
  28285. /**
  28286. * @hidden Internal use only
  28287. */
  28288. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28289. /**
  28290. * The set of event that will be linked to this animation
  28291. */
  28292. private _events;
  28293. /**
  28294. * Stores an array of target property paths
  28295. */
  28296. targetPropertyPath: string[];
  28297. /**
  28298. * Stores the blending speed of the animation
  28299. */
  28300. blendingSpeed: number;
  28301. /**
  28302. * Stores the animation ranges for the animation
  28303. */
  28304. private _ranges;
  28305. /**
  28306. * @hidden Internal use
  28307. */
  28308. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28309. /**
  28310. * Sets up an animation
  28311. * @param property The property to animate
  28312. * @param animationType The animation type to apply
  28313. * @param framePerSecond The frames per second of the animation
  28314. * @param easingFunction The easing function used in the animation
  28315. * @returns The created animation
  28316. */
  28317. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28318. /**
  28319. * Create and start an animation on a node
  28320. * @param name defines the name of the global animation that will be run on all nodes
  28321. * @param node defines the root node where the animation will take place
  28322. * @param targetProperty defines property to animate
  28323. * @param framePerSecond defines the number of frame per second yo use
  28324. * @param totalFrame defines the number of frames in total
  28325. * @param from defines the initial value
  28326. * @param to defines the final value
  28327. * @param loopMode defines which loop mode you want to use (off by default)
  28328. * @param easingFunction defines the easing function to use (linear by default)
  28329. * @param onAnimationEnd defines the callback to call when animation end
  28330. * @returns the animatable created for this animation
  28331. */
  28332. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28333. /**
  28334. * Create and start an animation on a node and its descendants
  28335. * @param name defines the name of the global animation that will be run on all nodes
  28336. * @param node defines the root node where the animation will take place
  28337. * @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
  28338. * @param targetProperty defines property to animate
  28339. * @param framePerSecond defines the number of frame per second to use
  28340. * @param totalFrame defines the number of frames in total
  28341. * @param from defines the initial value
  28342. * @param to defines the final value
  28343. * @param loopMode defines which loop mode you want to use (off by default)
  28344. * @param easingFunction defines the easing function to use (linear by default)
  28345. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28346. * @returns the list of animatables created for all nodes
  28347. * @example https://www.babylonjs-playground.com/#MH0VLI
  28348. */
  28349. 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[]>;
  28350. /**
  28351. * Creates a new animation, merges it with the existing animations and starts it
  28352. * @param name Name of the animation
  28353. * @param node Node which contains the scene that begins the animations
  28354. * @param targetProperty Specifies which property to animate
  28355. * @param framePerSecond The frames per second of the animation
  28356. * @param totalFrame The total number of frames
  28357. * @param from The frame at the beginning of the animation
  28358. * @param to The frame at the end of the animation
  28359. * @param loopMode Specifies the loop mode of the animation
  28360. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28361. * @param onAnimationEnd Callback to run once the animation is complete
  28362. * @returns Nullable animation
  28363. */
  28364. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28365. /**
  28366. * Transition property of an host to the target Value
  28367. * @param property The property to transition
  28368. * @param targetValue The target Value of the property
  28369. * @param host The object where the property to animate belongs
  28370. * @param scene Scene used to run the animation
  28371. * @param frameRate Framerate (in frame/s) to use
  28372. * @param transition The transition type we want to use
  28373. * @param duration The duration of the animation, in milliseconds
  28374. * @param onAnimationEnd Callback trigger at the end of the animation
  28375. * @returns Nullable animation
  28376. */
  28377. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28378. /**
  28379. * Return the array of runtime animations currently using this animation
  28380. */
  28381. readonly runtimeAnimations: RuntimeAnimation[];
  28382. /**
  28383. * Specifies if any of the runtime animations are currently running
  28384. */
  28385. readonly hasRunningRuntimeAnimations: boolean;
  28386. /**
  28387. * Initializes the animation
  28388. * @param name Name of the animation
  28389. * @param targetProperty Property to animate
  28390. * @param framePerSecond The frames per second of the animation
  28391. * @param dataType The data type of the animation
  28392. * @param loopMode The loop mode of the animation
  28393. * @param enableBlending Specifies if blending should be enabled
  28394. */
  28395. constructor(
  28396. /**Name of the animation */
  28397. name: string,
  28398. /**Property to animate */
  28399. targetProperty: string,
  28400. /**The frames per second of the animation */
  28401. framePerSecond: number,
  28402. /**The data type of the animation */
  28403. dataType: number,
  28404. /**The loop mode of the animation */
  28405. loopMode?: number | undefined,
  28406. /**Specifies if blending should be enabled */
  28407. enableBlending?: boolean | undefined);
  28408. /**
  28409. * Converts the animation to a string
  28410. * @param fullDetails support for multiple levels of logging within scene loading
  28411. * @returns String form of the animation
  28412. */
  28413. toString(fullDetails?: boolean): string;
  28414. /**
  28415. * Add an event to this animation
  28416. * @param event Event to add
  28417. */
  28418. addEvent(event: AnimationEvent): void;
  28419. /**
  28420. * Remove all events found at the given frame
  28421. * @param frame The frame to remove events from
  28422. */
  28423. removeEvents(frame: number): void;
  28424. /**
  28425. * Retrieves all the events from the animation
  28426. * @returns Events from the animation
  28427. */
  28428. getEvents(): AnimationEvent[];
  28429. /**
  28430. * Creates an animation range
  28431. * @param name Name of the animation range
  28432. * @param from Starting frame of the animation range
  28433. * @param to Ending frame of the animation
  28434. */
  28435. createRange(name: string, from: number, to: number): void;
  28436. /**
  28437. * Deletes an animation range by name
  28438. * @param name Name of the animation range to delete
  28439. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28440. */
  28441. deleteRange(name: string, deleteFrames?: boolean): void;
  28442. /**
  28443. * Gets the animation range by name, or null if not defined
  28444. * @param name Name of the animation range
  28445. * @returns Nullable animation range
  28446. */
  28447. getRange(name: string): Nullable<AnimationRange>;
  28448. /**
  28449. * Gets the key frames from the animation
  28450. * @returns The key frames of the animation
  28451. */
  28452. getKeys(): Array<IAnimationKey>;
  28453. /**
  28454. * Gets the highest frame rate of the animation
  28455. * @returns Highest frame rate of the animation
  28456. */
  28457. getHighestFrame(): number;
  28458. /**
  28459. * Gets the easing function of the animation
  28460. * @returns Easing function of the animation
  28461. */
  28462. getEasingFunction(): IEasingFunction;
  28463. /**
  28464. * Sets the easing function of the animation
  28465. * @param easingFunction A custom mathematical formula for animation
  28466. */
  28467. setEasingFunction(easingFunction: EasingFunction): void;
  28468. /**
  28469. * Interpolates a scalar linearly
  28470. * @param startValue Start value of the animation curve
  28471. * @param endValue End value of the animation curve
  28472. * @param gradient Scalar amount to interpolate
  28473. * @returns Interpolated scalar value
  28474. */
  28475. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28476. /**
  28477. * Interpolates a scalar cubically
  28478. * @param startValue Start value of the animation curve
  28479. * @param outTangent End tangent of the animation
  28480. * @param endValue End value of the animation curve
  28481. * @param inTangent Start tangent of the animation curve
  28482. * @param gradient Scalar amount to interpolate
  28483. * @returns Interpolated scalar value
  28484. */
  28485. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28486. /**
  28487. * Interpolates a quaternion using a spherical linear interpolation
  28488. * @param startValue Start value of the animation curve
  28489. * @param endValue End value of the animation curve
  28490. * @param gradient Scalar amount to interpolate
  28491. * @returns Interpolated quaternion value
  28492. */
  28493. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28494. /**
  28495. * Interpolates a quaternion cubically
  28496. * @param startValue Start value of the animation curve
  28497. * @param outTangent End tangent of the animation curve
  28498. * @param endValue End value of the animation curve
  28499. * @param inTangent Start tangent of the animation curve
  28500. * @param gradient Scalar amount to interpolate
  28501. * @returns Interpolated quaternion value
  28502. */
  28503. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28504. /**
  28505. * Interpolates a Vector3 linearl
  28506. * @param startValue Start value of the animation curve
  28507. * @param endValue End value of the animation curve
  28508. * @param gradient Scalar amount to interpolate
  28509. * @returns Interpolated scalar value
  28510. */
  28511. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28512. /**
  28513. * Interpolates a Vector3 cubically
  28514. * @param startValue Start value of the animation curve
  28515. * @param outTangent End tangent of the animation
  28516. * @param endValue End value of the animation curve
  28517. * @param inTangent Start tangent of the animation curve
  28518. * @param gradient Scalar amount to interpolate
  28519. * @returns InterpolatedVector3 value
  28520. */
  28521. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28522. /**
  28523. * Interpolates a Vector2 linearly
  28524. * @param startValue Start value of the animation curve
  28525. * @param endValue End value of the animation curve
  28526. * @param gradient Scalar amount to interpolate
  28527. * @returns Interpolated Vector2 value
  28528. */
  28529. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28530. /**
  28531. * Interpolates a Vector2 cubically
  28532. * @param startValue Start value of the animation curve
  28533. * @param outTangent End tangent of the animation
  28534. * @param endValue End value of the animation curve
  28535. * @param inTangent Start tangent of the animation curve
  28536. * @param gradient Scalar amount to interpolate
  28537. * @returns Interpolated Vector2 value
  28538. */
  28539. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28540. /**
  28541. * Interpolates a size linearly
  28542. * @param startValue Start value of the animation curve
  28543. * @param endValue End value of the animation curve
  28544. * @param gradient Scalar amount to interpolate
  28545. * @returns Interpolated Size value
  28546. */
  28547. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28548. /**
  28549. * Interpolates a Color3 linearly
  28550. * @param startValue Start value of the animation curve
  28551. * @param endValue End value of the animation curve
  28552. * @param gradient Scalar amount to interpolate
  28553. * @returns Interpolated Color3 value
  28554. */
  28555. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28556. /**
  28557. * Interpolates a Color4 linearly
  28558. * @param startValue Start value of the animation curve
  28559. * @param endValue End value of the animation curve
  28560. * @param gradient Scalar amount to interpolate
  28561. * @returns Interpolated Color3 value
  28562. */
  28563. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28564. /**
  28565. * @hidden Internal use only
  28566. */
  28567. _getKeyValue(value: any): any;
  28568. /**
  28569. * @hidden Internal use only
  28570. */
  28571. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28572. /**
  28573. * Defines the function to use to interpolate matrices
  28574. * @param startValue defines the start matrix
  28575. * @param endValue defines the end matrix
  28576. * @param gradient defines the gradient between both matrices
  28577. * @param result defines an optional target matrix where to store the interpolation
  28578. * @returns the interpolated matrix
  28579. */
  28580. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28581. /**
  28582. * Makes a copy of the animation
  28583. * @returns Cloned animation
  28584. */
  28585. clone(): Animation;
  28586. /**
  28587. * Sets the key frames of the animation
  28588. * @param values The animation key frames to set
  28589. */
  28590. setKeys(values: Array<IAnimationKey>): void;
  28591. /**
  28592. * Serializes the animation to an object
  28593. * @returns Serialized object
  28594. */
  28595. serialize(): any;
  28596. /**
  28597. * Float animation type
  28598. */
  28599. static readonly ANIMATIONTYPE_FLOAT: number;
  28600. /**
  28601. * Vector3 animation type
  28602. */
  28603. static readonly ANIMATIONTYPE_VECTOR3: number;
  28604. /**
  28605. * Quaternion animation type
  28606. */
  28607. static readonly ANIMATIONTYPE_QUATERNION: number;
  28608. /**
  28609. * Matrix animation type
  28610. */
  28611. static readonly ANIMATIONTYPE_MATRIX: number;
  28612. /**
  28613. * Color3 animation type
  28614. */
  28615. static readonly ANIMATIONTYPE_COLOR3: number;
  28616. /**
  28617. * Color3 animation type
  28618. */
  28619. static readonly ANIMATIONTYPE_COLOR4: number;
  28620. /**
  28621. * Vector2 animation type
  28622. */
  28623. static readonly ANIMATIONTYPE_VECTOR2: number;
  28624. /**
  28625. * Size animation type
  28626. */
  28627. static readonly ANIMATIONTYPE_SIZE: number;
  28628. /**
  28629. * Relative Loop Mode
  28630. */
  28631. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28632. /**
  28633. * Cycle Loop Mode
  28634. */
  28635. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28636. /**
  28637. * Constant Loop Mode
  28638. */
  28639. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28640. /** @hidden */
  28641. static _UniversalLerp(left: any, right: any, amount: number): any;
  28642. /**
  28643. * Parses an animation object and creates an animation
  28644. * @param parsedAnimation Parsed animation object
  28645. * @returns Animation object
  28646. */
  28647. static Parse(parsedAnimation: any): Animation;
  28648. /**
  28649. * Appends the serialized animations from the source animations
  28650. * @param source Source containing the animations
  28651. * @param destination Target to store the animations
  28652. */
  28653. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28654. }
  28655. }
  28656. declare module "babylonjs/Animations/animatable.interface" {
  28657. import { Nullable } from "babylonjs/types";
  28658. import { Animation } from "babylonjs/Animations/animation";
  28659. /**
  28660. * Interface containing an array of animations
  28661. */
  28662. export interface IAnimatable {
  28663. /**
  28664. * Array of animations
  28665. */
  28666. animations: Nullable<Array<Animation>>;
  28667. }
  28668. }
  28669. declare module "babylonjs/Materials/fresnelParameters" {
  28670. import { Color3 } from "babylonjs/Maths/math.color";
  28671. /**
  28672. * This represents all the required information to add a fresnel effect on a material:
  28673. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28674. */
  28675. export class FresnelParameters {
  28676. private _isEnabled;
  28677. /**
  28678. * Define if the fresnel effect is enable or not.
  28679. */
  28680. isEnabled: boolean;
  28681. /**
  28682. * Define the color used on edges (grazing angle)
  28683. */
  28684. leftColor: Color3;
  28685. /**
  28686. * Define the color used on center
  28687. */
  28688. rightColor: Color3;
  28689. /**
  28690. * Define bias applied to computed fresnel term
  28691. */
  28692. bias: number;
  28693. /**
  28694. * Defined the power exponent applied to fresnel term
  28695. */
  28696. power: number;
  28697. /**
  28698. * Clones the current fresnel and its valuues
  28699. * @returns a clone fresnel configuration
  28700. */
  28701. clone(): FresnelParameters;
  28702. /**
  28703. * Serializes the current fresnel parameters to a JSON representation.
  28704. * @return the JSON serialization
  28705. */
  28706. serialize(): any;
  28707. /**
  28708. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28709. * @param parsedFresnelParameters Define the JSON representation
  28710. * @returns the parsed parameters
  28711. */
  28712. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28713. }
  28714. }
  28715. declare module "babylonjs/Misc/decorators" {
  28716. import { Nullable } from "babylonjs/types";
  28717. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28718. import { Scene } from "babylonjs/scene";
  28719. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28720. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28721. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28722. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28723. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28724. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28725. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28726. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28727. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28728. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28729. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28730. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28731. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28732. /**
  28733. * Decorator used to define property that can be serialized as reference to a camera
  28734. * @param sourceName defines the name of the property to decorate
  28735. */
  28736. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28737. /**
  28738. * Class used to help serialization objects
  28739. */
  28740. export class SerializationHelper {
  28741. /** @hidden */
  28742. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28743. /** @hidden */
  28744. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28745. /** @hidden */
  28746. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28747. /** @hidden */
  28748. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28749. /**
  28750. * Appends the serialized animations from the source animations
  28751. * @param source Source containing the animations
  28752. * @param destination Target to store the animations
  28753. */
  28754. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28755. /**
  28756. * Static function used to serialized a specific entity
  28757. * @param entity defines the entity to serialize
  28758. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28759. * @returns a JSON compatible object representing the serialization of the entity
  28760. */
  28761. static Serialize<T>(entity: T, serializationObject?: any): any;
  28762. /**
  28763. * Creates a new entity from a serialization data object
  28764. * @param creationFunction defines a function used to instanciated the new entity
  28765. * @param source defines the source serialization data
  28766. * @param scene defines the hosting scene
  28767. * @param rootUrl defines the root url for resources
  28768. * @returns a new entity
  28769. */
  28770. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28771. /**
  28772. * Clones an object
  28773. * @param creationFunction defines the function used to instanciate the new object
  28774. * @param source defines the source object
  28775. * @returns the cloned object
  28776. */
  28777. static Clone<T>(creationFunction: () => T, source: T): T;
  28778. /**
  28779. * Instanciates a new object based on a source one (some data will be shared between both object)
  28780. * @param creationFunction defines the function used to instanciate the new object
  28781. * @param source defines the source object
  28782. * @returns the new object
  28783. */
  28784. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28785. }
  28786. }
  28787. declare module "babylonjs/Misc/guid" {
  28788. /**
  28789. * Class used to manipulate GUIDs
  28790. */
  28791. export class GUID {
  28792. /**
  28793. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28794. * Be aware Math.random() could cause collisions, but:
  28795. * "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"
  28796. * @returns a pseudo random id
  28797. */
  28798. static RandomId(): string;
  28799. }
  28800. }
  28801. declare module "babylonjs/Materials/Textures/baseTexture" {
  28802. import { Observable } from "babylonjs/Misc/observable";
  28803. import { Nullable } from "babylonjs/types";
  28804. import { Scene } from "babylonjs/scene";
  28805. import { Matrix } from "babylonjs/Maths/math.vector";
  28806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28808. import { ISize } from "babylonjs/Maths/math.size";
  28809. /**
  28810. * Base class of all the textures in babylon.
  28811. * It groups all the common properties the materials, post process, lights... might need
  28812. * in order to make a correct use of the texture.
  28813. */
  28814. export class BaseTexture implements IAnimatable {
  28815. /**
  28816. * Default anisotropic filtering level for the application.
  28817. * It is set to 4 as a good tradeoff between perf and quality.
  28818. */
  28819. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28820. /**
  28821. * Gets or sets the unique id of the texture
  28822. */
  28823. uniqueId: number;
  28824. /**
  28825. * Define the name of the texture.
  28826. */
  28827. name: string;
  28828. /**
  28829. * Gets or sets an object used to store user defined information.
  28830. */
  28831. metadata: any;
  28832. /**
  28833. * For internal use only. Please do not use.
  28834. */
  28835. reservedDataStore: any;
  28836. private _hasAlpha;
  28837. /**
  28838. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28839. */
  28840. hasAlpha: boolean;
  28841. /**
  28842. * Defines if the alpha value should be determined via the rgb values.
  28843. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28844. */
  28845. getAlphaFromRGB: boolean;
  28846. /**
  28847. * Intensity or strength of the texture.
  28848. * It is commonly used by materials to fine tune the intensity of the texture
  28849. */
  28850. level: number;
  28851. /**
  28852. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28853. * This is part of the texture as textures usually maps to one uv set.
  28854. */
  28855. coordinatesIndex: number;
  28856. private _coordinatesMode;
  28857. /**
  28858. * How a texture is mapped.
  28859. *
  28860. * | Value | Type | Description |
  28861. * | ----- | ----------------------------------- | ----------- |
  28862. * | 0 | EXPLICIT_MODE | |
  28863. * | 1 | SPHERICAL_MODE | |
  28864. * | 2 | PLANAR_MODE | |
  28865. * | 3 | CUBIC_MODE | |
  28866. * | 4 | PROJECTION_MODE | |
  28867. * | 5 | SKYBOX_MODE | |
  28868. * | 6 | INVCUBIC_MODE | |
  28869. * | 7 | EQUIRECTANGULAR_MODE | |
  28870. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28871. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28872. */
  28873. coordinatesMode: number;
  28874. /**
  28875. * | Value | Type | Description |
  28876. * | ----- | ------------------ | ----------- |
  28877. * | 0 | CLAMP_ADDRESSMODE | |
  28878. * | 1 | WRAP_ADDRESSMODE | |
  28879. * | 2 | MIRROR_ADDRESSMODE | |
  28880. */
  28881. wrapU: number;
  28882. /**
  28883. * | Value | Type | Description |
  28884. * | ----- | ------------------ | ----------- |
  28885. * | 0 | CLAMP_ADDRESSMODE | |
  28886. * | 1 | WRAP_ADDRESSMODE | |
  28887. * | 2 | MIRROR_ADDRESSMODE | |
  28888. */
  28889. wrapV: number;
  28890. /**
  28891. * | Value | Type | Description |
  28892. * | ----- | ------------------ | ----------- |
  28893. * | 0 | CLAMP_ADDRESSMODE | |
  28894. * | 1 | WRAP_ADDRESSMODE | |
  28895. * | 2 | MIRROR_ADDRESSMODE | |
  28896. */
  28897. wrapR: number;
  28898. /**
  28899. * With compliant hardware and browser (supporting anisotropic filtering)
  28900. * this defines the level of anisotropic filtering in the texture.
  28901. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28902. */
  28903. anisotropicFilteringLevel: number;
  28904. /**
  28905. * Define if the texture is a cube texture or if false a 2d texture.
  28906. */
  28907. isCube: boolean;
  28908. /**
  28909. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28910. */
  28911. is3D: boolean;
  28912. /**
  28913. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28914. */
  28915. is2DArray: boolean;
  28916. /**
  28917. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28918. * HDR texture are usually stored in linear space.
  28919. * This only impacts the PBR and Background materials
  28920. */
  28921. gammaSpace: boolean;
  28922. /**
  28923. * Gets or sets whether or not the texture contains RGBD data.
  28924. */
  28925. isRGBD: boolean;
  28926. /**
  28927. * Is Z inverted in the texture (useful in a cube texture).
  28928. */
  28929. invertZ: boolean;
  28930. /**
  28931. * Are mip maps generated for this texture or not.
  28932. */
  28933. readonly noMipmap: boolean;
  28934. /**
  28935. * @hidden
  28936. */
  28937. lodLevelInAlpha: boolean;
  28938. /**
  28939. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28940. */
  28941. lodGenerationOffset: number;
  28942. /**
  28943. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28944. */
  28945. lodGenerationScale: number;
  28946. /**
  28947. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28948. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28949. * average roughness values.
  28950. */
  28951. linearSpecularLOD: boolean;
  28952. /**
  28953. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28954. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28955. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28956. */
  28957. irradianceTexture: Nullable<BaseTexture>;
  28958. /**
  28959. * Define if the texture is a render target.
  28960. */
  28961. isRenderTarget: boolean;
  28962. /**
  28963. * Define the unique id of the texture in the scene.
  28964. */
  28965. readonly uid: string;
  28966. /**
  28967. * Return a string representation of the texture.
  28968. * @returns the texture as a string
  28969. */
  28970. toString(): string;
  28971. /**
  28972. * Get the class name of the texture.
  28973. * @returns "BaseTexture"
  28974. */
  28975. getClassName(): string;
  28976. /**
  28977. * Define the list of animation attached to the texture.
  28978. */
  28979. animations: import("babylonjs/Animations/animation").Animation[];
  28980. /**
  28981. * An event triggered when the texture is disposed.
  28982. */
  28983. onDisposeObservable: Observable<BaseTexture>;
  28984. private _onDisposeObserver;
  28985. /**
  28986. * Callback triggered when the texture has been disposed.
  28987. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28988. */
  28989. onDispose: () => void;
  28990. /**
  28991. * Define the current state of the loading sequence when in delayed load mode.
  28992. */
  28993. delayLoadState: number;
  28994. private _scene;
  28995. /** @hidden */
  28996. _texture: Nullable<InternalTexture>;
  28997. private _uid;
  28998. /**
  28999. * Define if the texture is preventinga material to render or not.
  29000. * If not and the texture is not ready, the engine will use a default black texture instead.
  29001. */
  29002. readonly isBlocking: boolean;
  29003. /**
  29004. * Instantiates a new BaseTexture.
  29005. * Base class of all the textures in babylon.
  29006. * It groups all the common properties the materials, post process, lights... might need
  29007. * in order to make a correct use of the texture.
  29008. * @param scene Define the scene the texture blongs to
  29009. */
  29010. constructor(scene: Nullable<Scene>);
  29011. /**
  29012. * Get the scene the texture belongs to.
  29013. * @returns the scene or null if undefined
  29014. */
  29015. getScene(): Nullable<Scene>;
  29016. /**
  29017. * Get the texture transform matrix used to offset tile the texture for istance.
  29018. * @returns the transformation matrix
  29019. */
  29020. getTextureMatrix(): Matrix;
  29021. /**
  29022. * Get the texture reflection matrix used to rotate/transform the reflection.
  29023. * @returns the reflection matrix
  29024. */
  29025. getReflectionTextureMatrix(): Matrix;
  29026. /**
  29027. * Get the underlying lower level texture from Babylon.
  29028. * @returns the insternal texture
  29029. */
  29030. getInternalTexture(): Nullable<InternalTexture>;
  29031. /**
  29032. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29033. * @returns true if ready or not blocking
  29034. */
  29035. isReadyOrNotBlocking(): boolean;
  29036. /**
  29037. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29038. * @returns true if fully ready
  29039. */
  29040. isReady(): boolean;
  29041. private _cachedSize;
  29042. /**
  29043. * Get the size of the texture.
  29044. * @returns the texture size.
  29045. */
  29046. getSize(): ISize;
  29047. /**
  29048. * Get the base size of the texture.
  29049. * It can be different from the size if the texture has been resized for POT for instance
  29050. * @returns the base size
  29051. */
  29052. getBaseSize(): ISize;
  29053. /**
  29054. * Update the sampling mode of the texture.
  29055. * Default is Trilinear mode.
  29056. *
  29057. * | Value | Type | Description |
  29058. * | ----- | ------------------ | ----------- |
  29059. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29060. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29061. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29062. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29063. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29064. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29065. * | 7 | NEAREST_LINEAR | |
  29066. * | 8 | NEAREST_NEAREST | |
  29067. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29068. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29069. * | 11 | LINEAR_LINEAR | |
  29070. * | 12 | LINEAR_NEAREST | |
  29071. *
  29072. * > _mag_: magnification filter (close to the viewer)
  29073. * > _min_: minification filter (far from the viewer)
  29074. * > _mip_: filter used between mip map levels
  29075. *@param samplingMode Define the new sampling mode of the texture
  29076. */
  29077. updateSamplingMode(samplingMode: number): void;
  29078. /**
  29079. * Scales the texture if is `canRescale()`
  29080. * @param ratio the resize factor we want to use to rescale
  29081. */
  29082. scale(ratio: number): void;
  29083. /**
  29084. * Get if the texture can rescale.
  29085. */
  29086. readonly canRescale: boolean;
  29087. /** @hidden */
  29088. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29089. /** @hidden */
  29090. _rebuild(): void;
  29091. /**
  29092. * Triggers the load sequence in delayed load mode.
  29093. */
  29094. delayLoad(): void;
  29095. /**
  29096. * Clones the texture.
  29097. * @returns the cloned texture
  29098. */
  29099. clone(): Nullable<BaseTexture>;
  29100. /**
  29101. * Get the texture underlying type (INT, FLOAT...)
  29102. */
  29103. readonly textureType: number;
  29104. /**
  29105. * Get the texture underlying format (RGB, RGBA...)
  29106. */
  29107. readonly textureFormat: number;
  29108. /**
  29109. * Indicates that textures need to be re-calculated for all materials
  29110. */
  29111. protected _markAllSubMeshesAsTexturesDirty(): void;
  29112. /**
  29113. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29114. * This will returns an RGBA array buffer containing either in values (0-255) or
  29115. * float values (0-1) depending of the underlying buffer type.
  29116. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29117. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29118. * @param buffer defines a user defined buffer to fill with data (can be null)
  29119. * @returns The Array buffer containing the pixels data.
  29120. */
  29121. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29122. /**
  29123. * Release and destroy the underlying lower level texture aka internalTexture.
  29124. */
  29125. releaseInternalTexture(): void;
  29126. /** @hidden */
  29127. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29128. /** @hidden */
  29129. readonly _lodTextureMid: Nullable<BaseTexture>;
  29130. /** @hidden */
  29131. readonly _lodTextureLow: Nullable<BaseTexture>;
  29132. /**
  29133. * Dispose the texture and release its associated resources.
  29134. */
  29135. dispose(): void;
  29136. /**
  29137. * Serialize the texture into a JSON representation that can be parsed later on.
  29138. * @returns the JSON representation of the texture
  29139. */
  29140. serialize(): any;
  29141. /**
  29142. * Helper function to be called back once a list of texture contains only ready textures.
  29143. * @param textures Define the list of textures to wait for
  29144. * @param callback Define the callback triggered once the entire list will be ready
  29145. */
  29146. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29147. }
  29148. }
  29149. declare module "babylonjs/Materials/effect" {
  29150. import { Observable } from "babylonjs/Misc/observable";
  29151. import { Nullable } from "babylonjs/types";
  29152. import { IDisposable } from "babylonjs/scene";
  29153. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29154. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29155. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29156. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29157. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29158. import { Engine } from "babylonjs/Engines/engine";
  29159. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29161. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29163. /**
  29164. * Options to be used when creating an effect.
  29165. */
  29166. export interface IEffectCreationOptions {
  29167. /**
  29168. * Atrributes that will be used in the shader.
  29169. */
  29170. attributes: string[];
  29171. /**
  29172. * Uniform varible names that will be set in the shader.
  29173. */
  29174. uniformsNames: string[];
  29175. /**
  29176. * Uniform buffer varible names that will be set in the shader.
  29177. */
  29178. uniformBuffersNames: string[];
  29179. /**
  29180. * Sampler texture variable names that will be set in the shader.
  29181. */
  29182. samplers: string[];
  29183. /**
  29184. * Define statements that will be set in the shader.
  29185. */
  29186. defines: any;
  29187. /**
  29188. * Possible fallbacks for this effect to improve performance when needed.
  29189. */
  29190. fallbacks: Nullable<IEffectFallbacks>;
  29191. /**
  29192. * Callback that will be called when the shader is compiled.
  29193. */
  29194. onCompiled: Nullable<(effect: Effect) => void>;
  29195. /**
  29196. * Callback that will be called if an error occurs during shader compilation.
  29197. */
  29198. onError: Nullable<(effect: Effect, errors: string) => void>;
  29199. /**
  29200. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29201. */
  29202. indexParameters?: any;
  29203. /**
  29204. * Max number of lights that can be used in the shader.
  29205. */
  29206. maxSimultaneousLights?: number;
  29207. /**
  29208. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29209. */
  29210. transformFeedbackVaryings?: Nullable<string[]>;
  29211. }
  29212. /**
  29213. * Effect containing vertex and fragment shader that can be executed on an object.
  29214. */
  29215. export class Effect implements IDisposable {
  29216. /**
  29217. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29218. */
  29219. static ShadersRepository: string;
  29220. /**
  29221. * Name of the effect.
  29222. */
  29223. name: any;
  29224. /**
  29225. * String container all the define statements that should be set on the shader.
  29226. */
  29227. defines: string;
  29228. /**
  29229. * Callback that will be called when the shader is compiled.
  29230. */
  29231. onCompiled: Nullable<(effect: Effect) => void>;
  29232. /**
  29233. * Callback that will be called if an error occurs during shader compilation.
  29234. */
  29235. onError: Nullable<(effect: Effect, errors: string) => void>;
  29236. /**
  29237. * Callback that will be called when effect is bound.
  29238. */
  29239. onBind: Nullable<(effect: Effect) => void>;
  29240. /**
  29241. * Unique ID of the effect.
  29242. */
  29243. uniqueId: number;
  29244. /**
  29245. * Observable that will be called when the shader is compiled.
  29246. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29247. */
  29248. onCompileObservable: Observable<Effect>;
  29249. /**
  29250. * Observable that will be called if an error occurs during shader compilation.
  29251. */
  29252. onErrorObservable: Observable<Effect>;
  29253. /** @hidden */
  29254. _onBindObservable: Nullable<Observable<Effect>>;
  29255. /**
  29256. * Observable that will be called when effect is bound.
  29257. */
  29258. readonly onBindObservable: Observable<Effect>;
  29259. /** @hidden */
  29260. _bonesComputationForcedToCPU: boolean;
  29261. private static _uniqueIdSeed;
  29262. private _engine;
  29263. private _uniformBuffersNames;
  29264. private _uniformsNames;
  29265. private _samplerList;
  29266. private _samplers;
  29267. private _isReady;
  29268. private _compilationError;
  29269. private _allFallbacksProcessed;
  29270. private _attributesNames;
  29271. private _attributes;
  29272. private _uniforms;
  29273. /**
  29274. * Key for the effect.
  29275. * @hidden
  29276. */
  29277. _key: string;
  29278. private _indexParameters;
  29279. private _fallbacks;
  29280. private _vertexSourceCode;
  29281. private _fragmentSourceCode;
  29282. private _vertexSourceCodeOverride;
  29283. private _fragmentSourceCodeOverride;
  29284. private _transformFeedbackVaryings;
  29285. /**
  29286. * Compiled shader to webGL program.
  29287. * @hidden
  29288. */
  29289. _pipelineContext: Nullable<IPipelineContext>;
  29290. private _valueCache;
  29291. private static _baseCache;
  29292. /**
  29293. * Instantiates an effect.
  29294. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29295. * @param baseName Name of the effect.
  29296. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29297. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29298. * @param samplers List of sampler variables that will be passed to the shader.
  29299. * @param engine Engine to be used to render the effect
  29300. * @param defines Define statements to be added to the shader.
  29301. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29302. * @param onCompiled Callback that will be called when the shader is compiled.
  29303. * @param onError Callback that will be called if an error occurs during shader compilation.
  29304. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29305. */
  29306. 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);
  29307. private _useFinalCode;
  29308. /**
  29309. * Unique key for this effect
  29310. */
  29311. readonly key: string;
  29312. /**
  29313. * If the effect has been compiled and prepared.
  29314. * @returns if the effect is compiled and prepared.
  29315. */
  29316. isReady(): boolean;
  29317. private _isReadyInternal;
  29318. /**
  29319. * The engine the effect was initialized with.
  29320. * @returns the engine.
  29321. */
  29322. getEngine(): Engine;
  29323. /**
  29324. * The pipeline context for this effect
  29325. * @returns the associated pipeline context
  29326. */
  29327. getPipelineContext(): Nullable<IPipelineContext>;
  29328. /**
  29329. * The set of names of attribute variables for the shader.
  29330. * @returns An array of attribute names.
  29331. */
  29332. getAttributesNames(): string[];
  29333. /**
  29334. * Returns the attribute at the given index.
  29335. * @param index The index of the attribute.
  29336. * @returns The location of the attribute.
  29337. */
  29338. getAttributeLocation(index: number): number;
  29339. /**
  29340. * Returns the attribute based on the name of the variable.
  29341. * @param name of the attribute to look up.
  29342. * @returns the attribute location.
  29343. */
  29344. getAttributeLocationByName(name: string): number;
  29345. /**
  29346. * The number of attributes.
  29347. * @returns the numnber of attributes.
  29348. */
  29349. getAttributesCount(): number;
  29350. /**
  29351. * Gets the index of a uniform variable.
  29352. * @param uniformName of the uniform to look up.
  29353. * @returns the index.
  29354. */
  29355. getUniformIndex(uniformName: string): number;
  29356. /**
  29357. * Returns the attribute based on the name of the variable.
  29358. * @param uniformName of the uniform to look up.
  29359. * @returns the location of the uniform.
  29360. */
  29361. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29362. /**
  29363. * Returns an array of sampler variable names
  29364. * @returns The array of sampler variable neames.
  29365. */
  29366. getSamplers(): string[];
  29367. /**
  29368. * The error from the last compilation.
  29369. * @returns the error string.
  29370. */
  29371. getCompilationError(): string;
  29372. /**
  29373. * Gets a boolean indicating that all fallbacks were used during compilation
  29374. * @returns true if all fallbacks were used
  29375. */
  29376. allFallbacksProcessed(): boolean;
  29377. /**
  29378. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29379. * @param func The callback to be used.
  29380. */
  29381. executeWhenCompiled(func: (effect: Effect) => void): void;
  29382. private _checkIsReady;
  29383. private _loadShader;
  29384. /**
  29385. * Recompiles the webGL program
  29386. * @param vertexSourceCode The source code for the vertex shader.
  29387. * @param fragmentSourceCode The source code for the fragment shader.
  29388. * @param onCompiled Callback called when completed.
  29389. * @param onError Callback called on error.
  29390. * @hidden
  29391. */
  29392. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29393. /**
  29394. * Prepares the effect
  29395. * @hidden
  29396. */
  29397. _prepareEffect(): void;
  29398. private _processCompilationErrors;
  29399. /**
  29400. * Checks if the effect is supported. (Must be called after compilation)
  29401. */
  29402. readonly isSupported: boolean;
  29403. /**
  29404. * Binds a texture to the engine to be used as output of the shader.
  29405. * @param channel Name of the output variable.
  29406. * @param texture Texture to bind.
  29407. * @hidden
  29408. */
  29409. _bindTexture(channel: string, texture: InternalTexture): void;
  29410. /**
  29411. * Sets a texture on the engine to be used in the shader.
  29412. * @param channel Name of the sampler variable.
  29413. * @param texture Texture to set.
  29414. */
  29415. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29416. /**
  29417. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29418. * @param channel Name of the sampler variable.
  29419. * @param texture Texture to set.
  29420. */
  29421. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29422. /**
  29423. * Sets an array of textures on the engine to be used in the shader.
  29424. * @param channel Name of the variable.
  29425. * @param textures Textures to set.
  29426. */
  29427. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29428. /**
  29429. * 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)
  29430. * @param channel Name of the sampler variable.
  29431. * @param postProcess Post process to get the input texture from.
  29432. */
  29433. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29434. /**
  29435. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29436. * 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)
  29437. * @param channel Name of the sampler variable.
  29438. * @param postProcess Post process to get the output texture from.
  29439. */
  29440. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29441. /** @hidden */
  29442. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29443. /** @hidden */
  29444. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29445. /** @hidden */
  29446. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29447. /** @hidden */
  29448. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29449. /**
  29450. * Binds a buffer to a uniform.
  29451. * @param buffer Buffer to bind.
  29452. * @param name Name of the uniform variable to bind to.
  29453. */
  29454. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29455. /**
  29456. * Binds block to a uniform.
  29457. * @param blockName Name of the block to bind.
  29458. * @param index Index to bind.
  29459. */
  29460. bindUniformBlock(blockName: string, index: number): void;
  29461. /**
  29462. * Sets an interger value on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param value Value to be set.
  29465. * @returns this effect.
  29466. */
  29467. setInt(uniformName: string, value: number): Effect;
  29468. /**
  29469. * Sets an int array on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param array array to be set.
  29472. * @returns this effect.
  29473. */
  29474. setIntArray(uniformName: string, array: Int32Array): Effect;
  29475. /**
  29476. * 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)
  29477. * @param uniformName Name of the variable.
  29478. * @param array array to be set.
  29479. * @returns this effect.
  29480. */
  29481. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29482. /**
  29483. * 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)
  29484. * @param uniformName Name of the variable.
  29485. * @param array array to be set.
  29486. * @returns this effect.
  29487. */
  29488. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29489. /**
  29490. * 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)
  29491. * @param uniformName Name of the variable.
  29492. * @param array array to be set.
  29493. * @returns this effect.
  29494. */
  29495. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29496. /**
  29497. * Sets an float array on a uniform variable.
  29498. * @param uniformName Name of the variable.
  29499. * @param array array to be set.
  29500. * @returns this effect.
  29501. */
  29502. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29503. /**
  29504. * 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)
  29505. * @param uniformName Name of the variable.
  29506. * @param array array to be set.
  29507. * @returns this effect.
  29508. */
  29509. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29510. /**
  29511. * 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)
  29512. * @param uniformName Name of the variable.
  29513. * @param array array to be set.
  29514. * @returns this effect.
  29515. */
  29516. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29517. /**
  29518. * 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)
  29519. * @param uniformName Name of the variable.
  29520. * @param array array to be set.
  29521. * @returns this effect.
  29522. */
  29523. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29524. /**
  29525. * Sets an array on a uniform variable.
  29526. * @param uniformName Name of the variable.
  29527. * @param array array to be set.
  29528. * @returns this effect.
  29529. */
  29530. setArray(uniformName: string, array: number[]): Effect;
  29531. /**
  29532. * 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)
  29533. * @param uniformName Name of the variable.
  29534. * @param array array to be set.
  29535. * @returns this effect.
  29536. */
  29537. setArray2(uniformName: string, array: number[]): Effect;
  29538. /**
  29539. * 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)
  29540. * @param uniformName Name of the variable.
  29541. * @param array array to be set.
  29542. * @returns this effect.
  29543. */
  29544. setArray3(uniformName: string, array: number[]): Effect;
  29545. /**
  29546. * 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)
  29547. * @param uniformName Name of the variable.
  29548. * @param array array to be set.
  29549. * @returns this effect.
  29550. */
  29551. setArray4(uniformName: string, array: number[]): Effect;
  29552. /**
  29553. * Sets matrices on a uniform variable.
  29554. * @param uniformName Name of the variable.
  29555. * @param matrices matrices to be set.
  29556. * @returns this effect.
  29557. */
  29558. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29559. /**
  29560. * Sets matrix on a uniform variable.
  29561. * @param uniformName Name of the variable.
  29562. * @param matrix matrix to be set.
  29563. * @returns this effect.
  29564. */
  29565. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29566. /**
  29567. * 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)
  29568. * @param uniformName Name of the variable.
  29569. * @param matrix matrix to be set.
  29570. * @returns this effect.
  29571. */
  29572. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29573. /**
  29574. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29575. * @param uniformName Name of the variable.
  29576. * @param matrix matrix to be set.
  29577. * @returns this effect.
  29578. */
  29579. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29580. /**
  29581. * Sets a float on a uniform variable.
  29582. * @param uniformName Name of the variable.
  29583. * @param value value to be set.
  29584. * @returns this effect.
  29585. */
  29586. setFloat(uniformName: string, value: number): Effect;
  29587. /**
  29588. * Sets a boolean on a uniform variable.
  29589. * @param uniformName Name of the variable.
  29590. * @param bool value to be set.
  29591. * @returns this effect.
  29592. */
  29593. setBool(uniformName: string, bool: boolean): Effect;
  29594. /**
  29595. * Sets a Vector2 on a uniform variable.
  29596. * @param uniformName Name of the variable.
  29597. * @param vector2 vector2 to be set.
  29598. * @returns this effect.
  29599. */
  29600. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29601. /**
  29602. * Sets a float2 on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param x First float in float2.
  29605. * @param y Second float in float2.
  29606. * @returns this effect.
  29607. */
  29608. setFloat2(uniformName: string, x: number, y: number): Effect;
  29609. /**
  29610. * Sets a Vector3 on a uniform variable.
  29611. * @param uniformName Name of the variable.
  29612. * @param vector3 Value to be set.
  29613. * @returns this effect.
  29614. */
  29615. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29616. /**
  29617. * Sets a float3 on a uniform variable.
  29618. * @param uniformName Name of the variable.
  29619. * @param x First float in float3.
  29620. * @param y Second float in float3.
  29621. * @param z Third float in float3.
  29622. * @returns this effect.
  29623. */
  29624. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29625. /**
  29626. * Sets a Vector4 on a uniform variable.
  29627. * @param uniformName Name of the variable.
  29628. * @param vector4 Value to be set.
  29629. * @returns this effect.
  29630. */
  29631. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29632. /**
  29633. * Sets a float4 on a uniform variable.
  29634. * @param uniformName Name of the variable.
  29635. * @param x First float in float4.
  29636. * @param y Second float in float4.
  29637. * @param z Third float in float4.
  29638. * @param w Fourth float in float4.
  29639. * @returns this effect.
  29640. */
  29641. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29642. /**
  29643. * Sets a Color3 on a uniform variable.
  29644. * @param uniformName Name of the variable.
  29645. * @param color3 Value to be set.
  29646. * @returns this effect.
  29647. */
  29648. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29649. /**
  29650. * Sets a Color4 on a uniform variable.
  29651. * @param uniformName Name of the variable.
  29652. * @param color3 Value to be set.
  29653. * @param alpha Alpha value to be set.
  29654. * @returns this effect.
  29655. */
  29656. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29657. /**
  29658. * Sets a Color4 on a uniform variable
  29659. * @param uniformName defines the name of the variable
  29660. * @param color4 defines the value to be set
  29661. * @returns this effect.
  29662. */
  29663. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29664. /** Release all associated resources */
  29665. dispose(): void;
  29666. /**
  29667. * This function will add a new shader to the shader store
  29668. * @param name the name of the shader
  29669. * @param pixelShader optional pixel shader content
  29670. * @param vertexShader optional vertex shader content
  29671. */
  29672. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29673. /**
  29674. * Store of each shader (The can be looked up using effect.key)
  29675. */
  29676. static ShadersStore: {
  29677. [key: string]: string;
  29678. };
  29679. /**
  29680. * Store of each included file for a shader (The can be looked up using effect.key)
  29681. */
  29682. static IncludesShadersStore: {
  29683. [key: string]: string;
  29684. };
  29685. /**
  29686. * Resets the cache of effects.
  29687. */
  29688. static ResetCache(): void;
  29689. }
  29690. }
  29691. declare module "babylonjs/Engines/engineCapabilities" {
  29692. /**
  29693. * Interface used to describe the capabilities of the engine relatively to the current browser
  29694. */
  29695. export interface EngineCapabilities {
  29696. /** Maximum textures units per fragment shader */
  29697. maxTexturesImageUnits: number;
  29698. /** Maximum texture units per vertex shader */
  29699. maxVertexTextureImageUnits: number;
  29700. /** Maximum textures units in the entire pipeline */
  29701. maxCombinedTexturesImageUnits: number;
  29702. /** Maximum texture size */
  29703. maxTextureSize: number;
  29704. /** Maximum cube texture size */
  29705. maxCubemapTextureSize: number;
  29706. /** Maximum render texture size */
  29707. maxRenderTextureSize: number;
  29708. /** Maximum number of vertex attributes */
  29709. maxVertexAttribs: number;
  29710. /** Maximum number of varyings */
  29711. maxVaryingVectors: number;
  29712. /** Maximum number of uniforms per vertex shader */
  29713. maxVertexUniformVectors: number;
  29714. /** Maximum number of uniforms per fragment shader */
  29715. maxFragmentUniformVectors: number;
  29716. /** Defines if standard derivates (dx/dy) are supported */
  29717. standardDerivatives: boolean;
  29718. /** Defines if s3tc texture compression is supported */
  29719. s3tc?: WEBGL_compressed_texture_s3tc;
  29720. /** Defines if pvrtc texture compression is supported */
  29721. pvrtc: any;
  29722. /** Defines if etc1 texture compression is supported */
  29723. etc1: any;
  29724. /** Defines if etc2 texture compression is supported */
  29725. etc2: any;
  29726. /** Defines if astc texture compression is supported */
  29727. astc: any;
  29728. /** Defines if float textures are supported */
  29729. textureFloat: boolean;
  29730. /** Defines if vertex array objects are supported */
  29731. vertexArrayObject: boolean;
  29732. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29733. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29734. /** Gets the maximum level of anisotropy supported */
  29735. maxAnisotropy: number;
  29736. /** Defines if instancing is supported */
  29737. instancedArrays: boolean;
  29738. /** Defines if 32 bits indices are supported */
  29739. uintIndices: boolean;
  29740. /** Defines if high precision shaders are supported */
  29741. highPrecisionShaderSupported: boolean;
  29742. /** Defines if depth reading in the fragment shader is supported */
  29743. fragmentDepthSupported: boolean;
  29744. /** Defines if float texture linear filtering is supported*/
  29745. textureFloatLinearFiltering: boolean;
  29746. /** Defines if rendering to float textures is supported */
  29747. textureFloatRender: boolean;
  29748. /** Defines if half float textures are supported*/
  29749. textureHalfFloat: boolean;
  29750. /** Defines if half float texture linear filtering is supported*/
  29751. textureHalfFloatLinearFiltering: boolean;
  29752. /** Defines if rendering to half float textures is supported */
  29753. textureHalfFloatRender: boolean;
  29754. /** Defines if textureLOD shader command is supported */
  29755. textureLOD: boolean;
  29756. /** Defines if draw buffers extension is supported */
  29757. drawBuffersExtension: boolean;
  29758. /** Defines if depth textures are supported */
  29759. depthTextureExtension: boolean;
  29760. /** Defines if float color buffer are supported */
  29761. colorBufferFloat: boolean;
  29762. /** Gets disjoint timer query extension (null if not supported) */
  29763. timerQuery?: EXT_disjoint_timer_query;
  29764. /** Defines if timestamp can be used with timer query */
  29765. canUseTimestampForTimerQuery: boolean;
  29766. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29767. multiview?: any;
  29768. /** Function used to let the system compiles shaders in background */
  29769. parallelShaderCompile?: {
  29770. COMPLETION_STATUS_KHR: number;
  29771. };
  29772. /** Max number of texture samples for MSAA */
  29773. maxMSAASamples: number;
  29774. /** Defines if the blend min max extension is supported */
  29775. blendMinMax: boolean;
  29776. }
  29777. }
  29778. declare module "babylonjs/States/depthCullingState" {
  29779. import { Nullable } from "babylonjs/types";
  29780. /**
  29781. * @hidden
  29782. **/
  29783. export class DepthCullingState {
  29784. private _isDepthTestDirty;
  29785. private _isDepthMaskDirty;
  29786. private _isDepthFuncDirty;
  29787. private _isCullFaceDirty;
  29788. private _isCullDirty;
  29789. private _isZOffsetDirty;
  29790. private _isFrontFaceDirty;
  29791. private _depthTest;
  29792. private _depthMask;
  29793. private _depthFunc;
  29794. private _cull;
  29795. private _cullFace;
  29796. private _zOffset;
  29797. private _frontFace;
  29798. /**
  29799. * Initializes the state.
  29800. */
  29801. constructor();
  29802. readonly isDirty: boolean;
  29803. zOffset: number;
  29804. cullFace: Nullable<number>;
  29805. cull: Nullable<boolean>;
  29806. depthFunc: Nullable<number>;
  29807. depthMask: boolean;
  29808. depthTest: boolean;
  29809. frontFace: Nullable<number>;
  29810. reset(): void;
  29811. apply(gl: WebGLRenderingContext): void;
  29812. }
  29813. }
  29814. declare module "babylonjs/States/stencilState" {
  29815. /**
  29816. * @hidden
  29817. **/
  29818. export class StencilState {
  29819. /** 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 */
  29820. static readonly ALWAYS: number;
  29821. /** Passed to stencilOperation to specify that stencil value must be kept */
  29822. static readonly KEEP: number;
  29823. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29824. static readonly REPLACE: number;
  29825. private _isStencilTestDirty;
  29826. private _isStencilMaskDirty;
  29827. private _isStencilFuncDirty;
  29828. private _isStencilOpDirty;
  29829. private _stencilTest;
  29830. private _stencilMask;
  29831. private _stencilFunc;
  29832. private _stencilFuncRef;
  29833. private _stencilFuncMask;
  29834. private _stencilOpStencilFail;
  29835. private _stencilOpDepthFail;
  29836. private _stencilOpStencilDepthPass;
  29837. readonly isDirty: boolean;
  29838. stencilFunc: number;
  29839. stencilFuncRef: number;
  29840. stencilFuncMask: number;
  29841. stencilOpStencilFail: number;
  29842. stencilOpDepthFail: number;
  29843. stencilOpStencilDepthPass: number;
  29844. stencilMask: number;
  29845. stencilTest: boolean;
  29846. constructor();
  29847. reset(): void;
  29848. apply(gl: WebGLRenderingContext): void;
  29849. }
  29850. }
  29851. declare module "babylonjs/States/alphaCullingState" {
  29852. /**
  29853. * @hidden
  29854. **/
  29855. export class AlphaState {
  29856. private _isAlphaBlendDirty;
  29857. private _isBlendFunctionParametersDirty;
  29858. private _isBlendEquationParametersDirty;
  29859. private _isBlendConstantsDirty;
  29860. private _alphaBlend;
  29861. private _blendFunctionParameters;
  29862. private _blendEquationParameters;
  29863. private _blendConstants;
  29864. /**
  29865. * Initializes the state.
  29866. */
  29867. constructor();
  29868. readonly isDirty: boolean;
  29869. alphaBlend: boolean;
  29870. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29871. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29872. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29873. reset(): void;
  29874. apply(gl: WebGLRenderingContext): void;
  29875. }
  29876. }
  29877. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29878. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29879. /** @hidden */
  29880. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29881. attributeProcessor(attribute: string): string;
  29882. varyingProcessor(varying: string, isFragment: boolean): string;
  29883. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29884. }
  29885. }
  29886. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29887. /**
  29888. * Interface for attribute information associated with buffer instanciation
  29889. */
  29890. export interface InstancingAttributeInfo {
  29891. /**
  29892. * Index/offset of the attribute in the vertex shader
  29893. */
  29894. index: number;
  29895. /**
  29896. * size of the attribute, 1, 2, 3 or 4
  29897. */
  29898. attributeSize: number;
  29899. /**
  29900. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29901. * default is FLOAT
  29902. */
  29903. attributeType: number;
  29904. /**
  29905. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29906. */
  29907. normalized: boolean;
  29908. /**
  29909. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29910. */
  29911. offset: number;
  29912. /**
  29913. * Name of the GLSL attribute, for debugging purpose only
  29914. */
  29915. attributeName: string;
  29916. }
  29917. }
  29918. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29919. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29920. import { Nullable } from "babylonjs/types";
  29921. module "babylonjs/Engines/thinEngine" {
  29922. interface ThinEngine {
  29923. /**
  29924. * Update a video texture
  29925. * @param texture defines the texture to update
  29926. * @param video defines the video element to use
  29927. * @param invertY defines if data must be stored with Y axis inverted
  29928. */
  29929. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29930. }
  29931. }
  29932. }
  29933. declare module "babylonjs/Materials/Textures/videoTexture" {
  29934. import { Observable } from "babylonjs/Misc/observable";
  29935. import { Nullable } from "babylonjs/types";
  29936. import { Scene } from "babylonjs/scene";
  29937. import { Texture } from "babylonjs/Materials/Textures/texture";
  29938. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29939. /**
  29940. * Settings for finer control over video usage
  29941. */
  29942. export interface VideoTextureSettings {
  29943. /**
  29944. * Applies `autoplay` to video, if specified
  29945. */
  29946. autoPlay?: boolean;
  29947. /**
  29948. * Applies `loop` to video, if specified
  29949. */
  29950. loop?: boolean;
  29951. /**
  29952. * Automatically updates internal texture from video at every frame in the render loop
  29953. */
  29954. autoUpdateTexture: boolean;
  29955. /**
  29956. * Image src displayed during the video loading or until the user interacts with the video.
  29957. */
  29958. poster?: string;
  29959. }
  29960. /**
  29961. * If you want to display a video in your scene, this is the special texture for that.
  29962. * This special texture works similar to other textures, with the exception of a few parameters.
  29963. * @see https://doc.babylonjs.com/how_to/video_texture
  29964. */
  29965. export class VideoTexture extends Texture {
  29966. /**
  29967. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29968. */
  29969. readonly autoUpdateTexture: boolean;
  29970. /**
  29971. * The video instance used by the texture internally
  29972. */
  29973. readonly video: HTMLVideoElement;
  29974. private _onUserActionRequestedObservable;
  29975. /**
  29976. * Event triggerd when a dom action is required by the user to play the video.
  29977. * This happens due to recent changes in browser policies preventing video to auto start.
  29978. */
  29979. readonly onUserActionRequestedObservable: Observable<Texture>;
  29980. private _generateMipMaps;
  29981. private _engine;
  29982. private _stillImageCaptured;
  29983. private _displayingPosterTexture;
  29984. private _settings;
  29985. private _createInternalTextureOnEvent;
  29986. private _frameId;
  29987. /**
  29988. * Creates a video texture.
  29989. * If you want to display a video in your scene, this is the special texture for that.
  29990. * This special texture works similar to other textures, with the exception of a few parameters.
  29991. * @see https://doc.babylonjs.com/how_to/video_texture
  29992. * @param name optional name, will detect from video source, if not defined
  29993. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29994. * @param scene is obviously the current scene.
  29995. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29996. * @param invertY is false by default but can be used to invert video on Y axis
  29997. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29998. * @param settings allows finer control over video usage
  29999. */
  30000. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30001. private _getName;
  30002. private _getVideo;
  30003. private _createInternalTexture;
  30004. private reset;
  30005. /**
  30006. * @hidden Internal method to initiate `update`.
  30007. */
  30008. _rebuild(): void;
  30009. /**
  30010. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30011. */
  30012. update(): void;
  30013. /**
  30014. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30015. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30016. */
  30017. updateTexture(isVisible: boolean): void;
  30018. protected _updateInternalTexture: () => void;
  30019. /**
  30020. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30021. * @param url New url.
  30022. */
  30023. updateURL(url: string): void;
  30024. /**
  30025. * Dispose the texture and release its associated resources.
  30026. */
  30027. dispose(): void;
  30028. /**
  30029. * Creates a video texture straight from a stream.
  30030. * @param scene Define the scene the texture should be created in
  30031. * @param stream Define the stream the texture should be created from
  30032. * @returns The created video texture as a promise
  30033. */
  30034. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30035. /**
  30036. * Creates a video texture straight from your WebCam video feed.
  30037. * @param scene Define the scene the texture should be created in
  30038. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30039. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30040. * @returns The created video texture as a promise
  30041. */
  30042. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30043. minWidth: number;
  30044. maxWidth: number;
  30045. minHeight: number;
  30046. maxHeight: number;
  30047. deviceId: string;
  30048. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30049. /**
  30050. * Creates a video texture straight from your WebCam video feed.
  30051. * @param scene Define the scene the texture should be created in
  30052. * @param onReady Define a callback to triggered once the texture will be ready
  30053. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30054. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30055. */
  30056. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30057. minWidth: number;
  30058. maxWidth: number;
  30059. minHeight: number;
  30060. maxHeight: number;
  30061. deviceId: string;
  30062. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30063. }
  30064. }
  30065. declare module "babylonjs/Engines/thinEngine" {
  30066. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30067. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30068. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30069. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30070. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30071. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30072. import { Observable } from "babylonjs/Misc/observable";
  30073. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30074. import { StencilState } from "babylonjs/States/stencilState";
  30075. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30077. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30079. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30080. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30081. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30082. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30083. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30085. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30086. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30087. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30088. /**
  30089. * Defines the interface used by objects working like Scene
  30090. * @hidden
  30091. */
  30092. interface ISceneLike {
  30093. _addPendingData(data: any): void;
  30094. _removePendingData(data: any): void;
  30095. offlineProvider: IOfflineProvider;
  30096. }
  30097. /** Interface defining initialization parameters for Engine class */
  30098. export interface EngineOptions extends WebGLContextAttributes {
  30099. /**
  30100. * Defines if the engine should no exceed a specified device ratio
  30101. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30102. */
  30103. limitDeviceRatio?: number;
  30104. /**
  30105. * Defines if webvr should be enabled automatically
  30106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30107. */
  30108. autoEnableWebVR?: boolean;
  30109. /**
  30110. * Defines if webgl2 should be turned off even if supported
  30111. * @see http://doc.babylonjs.com/features/webgl2
  30112. */
  30113. disableWebGL2Support?: boolean;
  30114. /**
  30115. * Defines if webaudio should be initialized as well
  30116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30117. */
  30118. audioEngine?: boolean;
  30119. /**
  30120. * Defines if animations should run using a deterministic lock step
  30121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30122. */
  30123. deterministicLockstep?: boolean;
  30124. /** Defines the maximum steps to use with deterministic lock step mode */
  30125. lockstepMaxSteps?: number;
  30126. /**
  30127. * Defines that engine should ignore context lost events
  30128. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30129. */
  30130. doNotHandleContextLost?: boolean;
  30131. /**
  30132. * Defines that engine should ignore modifying touch action attribute and style
  30133. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30134. */
  30135. doNotHandleTouchAction?: boolean;
  30136. /**
  30137. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30138. */
  30139. useHighPrecisionFloats?: boolean;
  30140. }
  30141. /**
  30142. * The base engine class (root of all engines)
  30143. */
  30144. export class ThinEngine {
  30145. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30146. static ExceptionList: ({
  30147. key: string;
  30148. capture: string;
  30149. captureConstraint: number;
  30150. targets: string[];
  30151. } | {
  30152. key: string;
  30153. capture: null;
  30154. captureConstraint: null;
  30155. targets: string[];
  30156. })[];
  30157. /** @hidden */
  30158. static _TextureLoaders: IInternalTextureLoader[];
  30159. /**
  30160. * Returns the current npm package of the sdk
  30161. */
  30162. static readonly NpmPackage: string;
  30163. /**
  30164. * Returns the current version of the framework
  30165. */
  30166. static readonly Version: string;
  30167. /**
  30168. * Returns a string describing the current engine
  30169. */
  30170. readonly description: string;
  30171. /**
  30172. * Gets or sets the epsilon value used by collision engine
  30173. */
  30174. static CollisionsEpsilon: number;
  30175. /**
  30176. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30177. */
  30178. static ShadersRepository: string;
  30179. /** @hidden */
  30180. _shaderProcessor: IShaderProcessor;
  30181. /**
  30182. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30183. */
  30184. forcePOTTextures: boolean;
  30185. /**
  30186. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30187. */
  30188. isFullscreen: boolean;
  30189. /**
  30190. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30191. */
  30192. cullBackFaces: boolean;
  30193. /**
  30194. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30195. */
  30196. renderEvenInBackground: boolean;
  30197. /**
  30198. * Gets or sets a boolean indicating that cache can be kept between frames
  30199. */
  30200. preventCacheWipeBetweenFrames: boolean;
  30201. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30202. validateShaderPrograms: boolean;
  30203. /**
  30204. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30205. */
  30206. disableUniformBuffers: boolean;
  30207. /** @hidden */
  30208. _uniformBuffers: UniformBuffer[];
  30209. /**
  30210. * Gets a boolean indicating that the engine supports uniform buffers
  30211. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30212. */
  30213. readonly supportsUniformBuffers: boolean;
  30214. /** @hidden */
  30215. _gl: WebGLRenderingContext;
  30216. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30217. protected _windowIsBackground: boolean;
  30218. protected _webGLVersion: number;
  30219. protected _creationOptions: EngineOptions;
  30220. protected _highPrecisionShadersAllowed: boolean;
  30221. /** @hidden */
  30222. readonly _shouldUseHighPrecisionShader: boolean;
  30223. /**
  30224. * Gets a boolean indicating that only power of 2 textures are supported
  30225. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30226. */
  30227. readonly needPOTTextures: boolean;
  30228. /** @hidden */
  30229. _badOS: boolean;
  30230. /** @hidden */
  30231. _badDesktopOS: boolean;
  30232. private _hardwareScalingLevel;
  30233. /** @hidden */
  30234. _caps: EngineCapabilities;
  30235. private _isStencilEnable;
  30236. protected _colorWrite: boolean;
  30237. private _glVersion;
  30238. private _glRenderer;
  30239. private _glVendor;
  30240. /** @hidden */
  30241. _videoTextureSupported: boolean;
  30242. protected _renderingQueueLaunched: boolean;
  30243. protected _activeRenderLoops: (() => void)[];
  30244. /**
  30245. * Observable signaled when a context lost event is raised
  30246. */
  30247. onContextLostObservable: Observable<ThinEngine>;
  30248. /**
  30249. * Observable signaled when a context restored event is raised
  30250. */
  30251. onContextRestoredObservable: Observable<ThinEngine>;
  30252. private _onContextLost;
  30253. private _onContextRestored;
  30254. protected _contextWasLost: boolean;
  30255. /** @hidden */
  30256. _doNotHandleContextLost: boolean;
  30257. /**
  30258. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30260. */
  30261. doNotHandleContextLost: boolean;
  30262. /**
  30263. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30264. */
  30265. disableVertexArrayObjects: boolean;
  30266. /** @hidden */
  30267. protected _depthCullingState: DepthCullingState;
  30268. /** @hidden */
  30269. protected _stencilState: StencilState;
  30270. /** @hidden */
  30271. protected _alphaState: AlphaState;
  30272. /** @hidden */
  30273. _internalTexturesCache: InternalTexture[];
  30274. /** @hidden */
  30275. protected _activeChannel: number;
  30276. private _currentTextureChannel;
  30277. /** @hidden */
  30278. protected _boundTexturesCache: {
  30279. [key: string]: Nullable<InternalTexture>;
  30280. };
  30281. /** @hidden */
  30282. protected _currentEffect: Nullable<Effect>;
  30283. /** @hidden */
  30284. protected _currentProgram: Nullable<WebGLProgram>;
  30285. private _compiledEffects;
  30286. private _vertexAttribArraysEnabled;
  30287. /** @hidden */
  30288. protected _cachedViewport: Nullable<IViewportLike>;
  30289. private _cachedVertexArrayObject;
  30290. /** @hidden */
  30291. protected _cachedVertexBuffers: any;
  30292. /** @hidden */
  30293. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30294. /** @hidden */
  30295. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30296. /** @hidden */
  30297. _currentRenderTarget: Nullable<InternalTexture>;
  30298. private _uintIndicesCurrentlySet;
  30299. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30300. /** @hidden */
  30301. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30302. private _currentBufferPointers;
  30303. private _currentInstanceLocations;
  30304. private _currentInstanceBuffers;
  30305. private _textureUnits;
  30306. /** @hidden */
  30307. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30308. /** @hidden */
  30309. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30310. /** @hidden */
  30311. _boundRenderFunction: any;
  30312. private _vaoRecordInProgress;
  30313. private _mustWipeVertexAttributes;
  30314. private _emptyTexture;
  30315. private _emptyCubeTexture;
  30316. private _emptyTexture3D;
  30317. private _emptyTexture2DArray;
  30318. /** @hidden */
  30319. _frameHandler: number;
  30320. private _nextFreeTextureSlots;
  30321. private _maxSimultaneousTextures;
  30322. private _activeRequests;
  30323. protected _texturesSupported: string[];
  30324. /** @hidden */
  30325. _textureFormatInUse: Nullable<string>;
  30326. protected readonly _supportsHardwareTextureRescaling: boolean;
  30327. /**
  30328. * Gets the list of texture formats supported
  30329. */
  30330. readonly texturesSupported: Array<string>;
  30331. /**
  30332. * Gets the list of texture formats in use
  30333. */
  30334. readonly textureFormatInUse: Nullable<string>;
  30335. /**
  30336. * Gets the current viewport
  30337. */
  30338. readonly currentViewport: Nullable<IViewportLike>;
  30339. /**
  30340. * Gets the default empty texture
  30341. */
  30342. readonly emptyTexture: InternalTexture;
  30343. /**
  30344. * Gets the default empty 3D texture
  30345. */
  30346. readonly emptyTexture3D: InternalTexture;
  30347. /**
  30348. * Gets the default empty 2D array texture
  30349. */
  30350. readonly emptyTexture2DArray: InternalTexture;
  30351. /**
  30352. * Gets the default empty cube texture
  30353. */
  30354. readonly emptyCubeTexture: InternalTexture;
  30355. /**
  30356. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30357. */
  30358. readonly premultipliedAlpha: boolean;
  30359. /**
  30360. * Observable event triggered before each texture is initialized
  30361. */
  30362. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30363. /**
  30364. * Creates a new engine
  30365. * @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
  30366. * @param antialias defines enable antialiasing (default: false)
  30367. * @param options defines further options to be sent to the getContext() function
  30368. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30369. */
  30370. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30371. private _rebuildInternalTextures;
  30372. private _rebuildEffects;
  30373. /**
  30374. * Gets a boolean indicating if all created effects are ready
  30375. * @returns true if all effects are ready
  30376. */
  30377. areAllEffectsReady(): boolean;
  30378. protected _rebuildBuffers(): void;
  30379. private _initGLContext;
  30380. /**
  30381. * Gets version of the current webGL context
  30382. */
  30383. readonly webGLVersion: number;
  30384. /**
  30385. * Gets a string idenfifying the name of the class
  30386. * @returns "Engine" string
  30387. */
  30388. getClassName(): string;
  30389. /**
  30390. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30391. */
  30392. readonly isStencilEnable: boolean;
  30393. /** @hidden */
  30394. _prepareWorkingCanvas(): void;
  30395. /**
  30396. * Reset the texture cache to empty state
  30397. */
  30398. resetTextureCache(): void;
  30399. /**
  30400. * Gets an object containing information about the current webGL context
  30401. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30402. */
  30403. getGlInfo(): {
  30404. vendor: string;
  30405. renderer: string;
  30406. version: string;
  30407. };
  30408. /**
  30409. * Defines the hardware scaling level.
  30410. * By default the hardware scaling level is computed from the window device ratio.
  30411. * 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.
  30412. * @param level defines the level to use
  30413. */
  30414. setHardwareScalingLevel(level: number): void;
  30415. /**
  30416. * Gets the current hardware scaling level.
  30417. * By default the hardware scaling level is computed from the window device ratio.
  30418. * 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.
  30419. * @returns a number indicating the current hardware scaling level
  30420. */
  30421. getHardwareScalingLevel(): number;
  30422. /**
  30423. * Gets the list of loaded textures
  30424. * @returns an array containing all loaded textures
  30425. */
  30426. getLoadedTexturesCache(): InternalTexture[];
  30427. /**
  30428. * Gets the object containing all engine capabilities
  30429. * @returns the EngineCapabilities object
  30430. */
  30431. getCaps(): EngineCapabilities;
  30432. /**
  30433. * stop executing a render loop function and remove it from the execution array
  30434. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30435. */
  30436. stopRenderLoop(renderFunction?: () => void): void;
  30437. /** @hidden */
  30438. _renderLoop(): void;
  30439. /**
  30440. * Gets the HTML canvas attached with the current webGL context
  30441. * @returns a HTML canvas
  30442. */
  30443. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30444. /**
  30445. * Gets host window
  30446. * @returns the host window object
  30447. */
  30448. getHostWindow(): Nullable<Window>;
  30449. /**
  30450. * Gets the current render width
  30451. * @param useScreen defines if screen size must be used (or the current render target if any)
  30452. * @returns a number defining the current render width
  30453. */
  30454. getRenderWidth(useScreen?: boolean): number;
  30455. /**
  30456. * Gets the current render height
  30457. * @param useScreen defines if screen size must be used (or the current render target if any)
  30458. * @returns a number defining the current render height
  30459. */
  30460. getRenderHeight(useScreen?: boolean): number;
  30461. /**
  30462. * Can be used to override the current requestAnimationFrame requester.
  30463. * @hidden
  30464. */
  30465. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30466. /**
  30467. * Register and execute a render loop. The engine can have more than one render function
  30468. * @param renderFunction defines the function to continuously execute
  30469. */
  30470. runRenderLoop(renderFunction: () => void): void;
  30471. /**
  30472. * Clear the current render buffer or the current render target (if any is set up)
  30473. * @param color defines the color to use
  30474. * @param backBuffer defines if the back buffer must be cleared
  30475. * @param depth defines if the depth buffer must be cleared
  30476. * @param stencil defines if the stencil buffer must be cleared
  30477. */
  30478. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30479. private _viewportCached;
  30480. /** @hidden */
  30481. _viewport(x: number, y: number, width: number, height: number): void;
  30482. /**
  30483. * Set the WebGL's viewport
  30484. * @param viewport defines the viewport element to be used
  30485. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30486. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30487. */
  30488. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30489. /**
  30490. * Begin a new frame
  30491. */
  30492. beginFrame(): void;
  30493. /**
  30494. * Enf the current frame
  30495. */
  30496. endFrame(): void;
  30497. /**
  30498. * Resize the view according to the canvas' size
  30499. */
  30500. resize(): void;
  30501. /**
  30502. * Force a specific size of the canvas
  30503. * @param width defines the new canvas' width
  30504. * @param height defines the new canvas' height
  30505. */
  30506. setSize(width: number, height: number): void;
  30507. /**
  30508. * Binds the frame buffer to the specified texture.
  30509. * @param texture The texture to render to or null for the default canvas
  30510. * @param faceIndex The face of the texture to render to in case of cube texture
  30511. * @param requiredWidth The width of the target to render to
  30512. * @param requiredHeight The height of the target to render to
  30513. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30514. * @param depthStencilTexture The depth stencil texture to use to render
  30515. * @param lodLevel defines le lod level to bind to the frame buffer
  30516. */
  30517. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30518. /** @hidden */
  30519. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30520. /**
  30521. * Unbind the current render target texture from the webGL context
  30522. * @param texture defines the render target texture to unbind
  30523. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30524. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30525. */
  30526. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30527. /**
  30528. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30529. */
  30530. flushFramebuffer(): void;
  30531. /**
  30532. * Unbind the current render target and bind the default framebuffer
  30533. */
  30534. restoreDefaultFramebuffer(): void;
  30535. /** @hidden */
  30536. protected _resetVertexBufferBinding(): void;
  30537. /**
  30538. * Creates a vertex buffer
  30539. * @param data the data for the vertex buffer
  30540. * @returns the new WebGL static buffer
  30541. */
  30542. createVertexBuffer(data: DataArray): DataBuffer;
  30543. private _createVertexBuffer;
  30544. /**
  30545. * Creates a dynamic vertex buffer
  30546. * @param data the data for the dynamic vertex buffer
  30547. * @returns the new WebGL dynamic buffer
  30548. */
  30549. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30550. protected _resetIndexBufferBinding(): void;
  30551. /**
  30552. * Creates a new index buffer
  30553. * @param indices defines the content of the index buffer
  30554. * @param updatable defines if the index buffer must be updatable
  30555. * @returns a new webGL buffer
  30556. */
  30557. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30558. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30559. /**
  30560. * Bind a webGL buffer to the webGL context
  30561. * @param buffer defines the buffer to bind
  30562. */
  30563. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30564. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30565. private bindBuffer;
  30566. /**
  30567. * update the bound buffer with the given data
  30568. * @param data defines the data to update
  30569. */
  30570. updateArrayBuffer(data: Float32Array): void;
  30571. private _vertexAttribPointer;
  30572. private _bindIndexBufferWithCache;
  30573. private _bindVertexBuffersAttributes;
  30574. /**
  30575. * Records a vertex array object
  30576. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30577. * @param vertexBuffers defines the list of vertex buffers to store
  30578. * @param indexBuffer defines the index buffer to store
  30579. * @param effect defines the effect to store
  30580. * @returns the new vertex array object
  30581. */
  30582. recordVertexArrayObject(vertexBuffers: {
  30583. [key: string]: VertexBuffer;
  30584. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30585. /**
  30586. * Bind a specific vertex array object
  30587. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30588. * @param vertexArrayObject defines the vertex array object to bind
  30589. * @param indexBuffer defines the index buffer to bind
  30590. */
  30591. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30592. /**
  30593. * Bind webGl buffers directly to the webGL context
  30594. * @param vertexBuffer defines the vertex buffer to bind
  30595. * @param indexBuffer defines the index buffer to bind
  30596. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30597. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30598. * @param effect defines the effect associated with the vertex buffer
  30599. */
  30600. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30601. private _unbindVertexArrayObject;
  30602. /**
  30603. * Bind a list of vertex buffers to the webGL context
  30604. * @param vertexBuffers defines the list of vertex buffers to bind
  30605. * @param indexBuffer defines the index buffer to bind
  30606. * @param effect defines the effect associated with the vertex buffers
  30607. */
  30608. bindBuffers(vertexBuffers: {
  30609. [key: string]: Nullable<VertexBuffer>;
  30610. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30611. /**
  30612. * Unbind all instance attributes
  30613. */
  30614. unbindInstanceAttributes(): void;
  30615. /**
  30616. * Release and free the memory of a vertex array object
  30617. * @param vao defines the vertex array object to delete
  30618. */
  30619. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30620. /** @hidden */
  30621. _releaseBuffer(buffer: DataBuffer): boolean;
  30622. protected _deleteBuffer(buffer: DataBuffer): void;
  30623. /**
  30624. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30625. * @param instancesBuffer defines the webGL buffer to update and bind
  30626. * @param data defines the data to store in the buffer
  30627. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30628. */
  30629. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30630. /**
  30631. * Apply all cached states (depth, culling, stencil and alpha)
  30632. */
  30633. applyStates(): void;
  30634. /**
  30635. * Send a draw order
  30636. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30637. * @param indexStart defines the starting index
  30638. * @param indexCount defines the number of index to draw
  30639. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30640. */
  30641. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30642. /**
  30643. * Draw a list of points
  30644. * @param verticesStart defines the index of first vertex to draw
  30645. * @param verticesCount defines the count of vertices to draw
  30646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30647. */
  30648. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30649. /**
  30650. * Draw a list of unindexed primitives
  30651. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30652. * @param verticesStart defines the index of first vertex to draw
  30653. * @param verticesCount defines the count of vertices to draw
  30654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30655. */
  30656. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30657. /**
  30658. * Draw a list of indexed primitives
  30659. * @param fillMode defines the primitive to use
  30660. * @param indexStart defines the starting index
  30661. * @param indexCount defines the number of index to draw
  30662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30663. */
  30664. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30665. /**
  30666. * Draw a list of unindexed primitives
  30667. * @param fillMode defines the primitive to use
  30668. * @param verticesStart defines the index of first vertex to draw
  30669. * @param verticesCount defines the count of vertices to draw
  30670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30671. */
  30672. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30673. private _drawMode;
  30674. /** @hidden */
  30675. protected _reportDrawCall(): void;
  30676. /** @hidden */
  30677. _releaseEffect(effect: Effect): void;
  30678. /** @hidden */
  30679. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30680. /**
  30681. * Create a new effect (used to store vertex/fragment shaders)
  30682. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30683. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30684. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30685. * @param samplers defines an array of string used to represent textures
  30686. * @param defines defines the string containing the defines to use to compile the shaders
  30687. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30688. * @param onCompiled defines a function to call when the effect creation is successful
  30689. * @param onError defines a function to call when the effect creation has failed
  30690. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30691. * @returns the new Effect
  30692. */
  30693. 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;
  30694. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30695. private _compileShader;
  30696. private _compileRawShader;
  30697. /**
  30698. * Directly creates a webGL program
  30699. * @param pipelineContext defines the pipeline context to attach to
  30700. * @param vertexCode defines the vertex shader code to use
  30701. * @param fragmentCode defines the fragment shader code to use
  30702. * @param context defines the webGL context to use (if not set, the current one will be used)
  30703. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30704. * @returns the new webGL program
  30705. */
  30706. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30707. /**
  30708. * Creates a webGL program
  30709. * @param pipelineContext defines the pipeline context to attach to
  30710. * @param vertexCode defines the vertex shader code to use
  30711. * @param fragmentCode defines the fragment shader code to use
  30712. * @param defines defines the string containing the defines to use to compile the shaders
  30713. * @param context defines the webGL context to use (if not set, the current one will be used)
  30714. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30715. * @returns the new webGL program
  30716. */
  30717. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30718. /**
  30719. * Creates a new pipeline context
  30720. * @returns the new pipeline
  30721. */
  30722. createPipelineContext(): IPipelineContext;
  30723. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30724. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30725. /** @hidden */
  30726. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30727. /** @hidden */
  30728. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30729. /** @hidden */
  30730. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30731. /**
  30732. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30733. * @param pipelineContext defines the pipeline context to use
  30734. * @param uniformsNames defines the list of uniform names
  30735. * @returns an array of webGL uniform locations
  30736. */
  30737. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30738. /**
  30739. * Gets the lsit of active attributes for a given webGL program
  30740. * @param pipelineContext defines the pipeline context to use
  30741. * @param attributesNames defines the list of attribute names to get
  30742. * @returns an array of indices indicating the offset of each attribute
  30743. */
  30744. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30745. /**
  30746. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30747. * @param effect defines the effect to activate
  30748. */
  30749. enableEffect(effect: Nullable<Effect>): void;
  30750. /**
  30751. * Set the value of an uniform to a number (int)
  30752. * @param uniform defines the webGL uniform location where to store the value
  30753. * @param value defines the int number to store
  30754. */
  30755. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30756. /**
  30757. * Set the value of an uniform to an array of int32
  30758. * @param uniform defines the webGL uniform location where to store the value
  30759. * @param array defines the array of int32 to store
  30760. */
  30761. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30762. /**
  30763. * Set the value of an uniform to an array of int32 (stored as vec2)
  30764. * @param uniform defines the webGL uniform location where to store the value
  30765. * @param array defines the array of int32 to store
  30766. */
  30767. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30768. /**
  30769. * Set the value of an uniform to an array of int32 (stored as vec3)
  30770. * @param uniform defines the webGL uniform location where to store the value
  30771. * @param array defines the array of int32 to store
  30772. */
  30773. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30774. /**
  30775. * Set the value of an uniform to an array of int32 (stored as vec4)
  30776. * @param uniform defines the webGL uniform location where to store the value
  30777. * @param array defines the array of int32 to store
  30778. */
  30779. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30780. /**
  30781. * Set the value of an uniform to an array of number
  30782. * @param uniform defines the webGL uniform location where to store the value
  30783. * @param array defines the array of number to store
  30784. */
  30785. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30786. /**
  30787. * Set the value of an uniform to an array of number (stored as vec2)
  30788. * @param uniform defines the webGL uniform location where to store the value
  30789. * @param array defines the array of number to store
  30790. */
  30791. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30792. /**
  30793. * Set the value of an uniform to an array of number (stored as vec3)
  30794. * @param uniform defines the webGL uniform location where to store the value
  30795. * @param array defines the array of number to store
  30796. */
  30797. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30798. /**
  30799. * Set the value of an uniform to an array of number (stored as vec4)
  30800. * @param uniform defines the webGL uniform location where to store the value
  30801. * @param array defines the array of number to store
  30802. */
  30803. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30804. /**
  30805. * Set the value of an uniform to an array of float32 (stored as matrices)
  30806. * @param uniform defines the webGL uniform location where to store the value
  30807. * @param matrices defines the array of float32 to store
  30808. */
  30809. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30810. /**
  30811. * Set the value of an uniform to a matrix (3x3)
  30812. * @param uniform defines the webGL uniform location where to store the value
  30813. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30814. */
  30815. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30816. /**
  30817. * Set the value of an uniform to a matrix (2x2)
  30818. * @param uniform defines the webGL uniform location where to store the value
  30819. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30820. */
  30821. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30822. /**
  30823. * Set the value of an uniform to a number (float)
  30824. * @param uniform defines the webGL uniform location where to store the value
  30825. * @param value defines the float number to store
  30826. */
  30827. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30828. /**
  30829. * Set the value of an uniform to a vec2
  30830. * @param uniform defines the webGL uniform location where to store the value
  30831. * @param x defines the 1st component of the value
  30832. * @param y defines the 2nd component of the value
  30833. */
  30834. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30835. /**
  30836. * Set the value of an uniform to a vec3
  30837. * @param uniform defines the webGL uniform location where to store the value
  30838. * @param x defines the 1st component of the value
  30839. * @param y defines the 2nd component of the value
  30840. * @param z defines the 3rd component of the value
  30841. */
  30842. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30843. /**
  30844. * Set the value of an uniform to a vec4
  30845. * @param uniform defines the webGL uniform location where to store the value
  30846. * @param x defines the 1st component of the value
  30847. * @param y defines the 2nd component of the value
  30848. * @param z defines the 3rd component of the value
  30849. * @param w defines the 4th component of the value
  30850. */
  30851. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30852. /**
  30853. * Gets the depth culling state manager
  30854. */
  30855. readonly depthCullingState: DepthCullingState;
  30856. /**
  30857. * Gets the alpha state manager
  30858. */
  30859. readonly alphaState: AlphaState;
  30860. /**
  30861. * Gets the stencil state manager
  30862. */
  30863. readonly stencilState: StencilState;
  30864. /**
  30865. * Clears the list of texture accessible through engine.
  30866. * This can help preventing texture load conflict due to name collision.
  30867. */
  30868. clearInternalTexturesCache(): void;
  30869. /**
  30870. * Force the entire cache to be cleared
  30871. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30872. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30873. */
  30874. wipeCaches(bruteForce?: boolean): void;
  30875. /** @hidden */
  30876. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30877. min: number;
  30878. mag: number;
  30879. };
  30880. /** @hidden */
  30881. _createTexture(): WebGLTexture;
  30882. /**
  30883. * Usually called from Texture.ts.
  30884. * Passed information to create a WebGLTexture
  30885. * @param urlArg defines a value which contains one of the following:
  30886. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30887. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30888. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30890. * @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)
  30891. * @param scene needed for loading to the correct scene
  30892. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30893. * @param onLoad optional callback to be called upon successful completion
  30894. * @param onError optional callback to be called upon failure
  30895. * @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
  30896. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30897. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30898. * @param forcedExtension defines the extension to use to pick the right loader
  30899. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30900. * @param mimeType defines an optional mime type
  30901. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30902. */
  30903. 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;
  30904. /**
  30905. * @hidden
  30906. */
  30907. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30908. /**
  30909. * Creates a raw texture
  30910. * @param data defines the data to store in the texture
  30911. * @param width defines the width of the texture
  30912. * @param height defines the height of the texture
  30913. * @param format defines the format of the data
  30914. * @param generateMipMaps defines if the engine should generate the mip levels
  30915. * @param invertY defines if data must be stored with Y axis inverted
  30916. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30917. * @param compression defines the compression used (null by default)
  30918. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30919. * @returns the raw texture inside an InternalTexture
  30920. */
  30921. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30922. /**
  30923. * Creates a new raw cube texture
  30924. * @param data defines the array of data to use to create each face
  30925. * @param size defines the size of the textures
  30926. * @param format defines the format of the data
  30927. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30928. * @param generateMipMaps defines if the engine should generate the mip levels
  30929. * @param invertY defines if data must be stored with Y axis inverted
  30930. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30931. * @param compression defines the compression used (null by default)
  30932. * @returns the cube texture as an InternalTexture
  30933. */
  30934. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30935. /**
  30936. * Creates a new raw 3D texture
  30937. * @param data defines the data used to create the texture
  30938. * @param width defines the width of the texture
  30939. * @param height defines the height of the texture
  30940. * @param depth defines the depth of the texture
  30941. * @param format defines the format of the texture
  30942. * @param generateMipMaps defines if the engine must generate mip levels
  30943. * @param invertY defines if data must be stored with Y axis inverted
  30944. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30945. * @param compression defines the compressed used (can be null)
  30946. * @param textureType defines the compressed used (can be null)
  30947. * @returns a new raw 3D texture (stored in an InternalTexture)
  30948. */
  30949. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30950. /**
  30951. * Creates a new raw 2D array texture
  30952. * @param data defines the data used to create the texture
  30953. * @param width defines the width of the texture
  30954. * @param height defines the height of the texture
  30955. * @param depth defines the number of layers of the texture
  30956. * @param format defines the format of the texture
  30957. * @param generateMipMaps defines if the engine must generate mip levels
  30958. * @param invertY defines if data must be stored with Y axis inverted
  30959. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30960. * @param compression defines the compressed used (can be null)
  30961. * @param textureType defines the compressed used (can be null)
  30962. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30963. */
  30964. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30965. private _unpackFlipYCached;
  30966. /**
  30967. * In case you are sharing the context with other applications, it might
  30968. * be interested to not cache the unpack flip y state to ensure a consistent
  30969. * value would be set.
  30970. */
  30971. enableUnpackFlipYCached: boolean;
  30972. /** @hidden */
  30973. _unpackFlipY(value: boolean): void;
  30974. /** @hidden */
  30975. _getUnpackAlignement(): number;
  30976. /**
  30977. * Update the sampling mode of a given texture
  30978. * @param samplingMode defines the required sampling mode
  30979. * @param texture defines the texture to update
  30980. */
  30981. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30982. /** @hidden */
  30983. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30984. width: number;
  30985. height: number;
  30986. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30987. /** @hidden */
  30988. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30989. /** @hidden */
  30990. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30991. /** @hidden */
  30992. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30993. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30994. private _prepareWebGLTexture;
  30995. /** @hidden */
  30996. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30997. /** @hidden */
  30998. _releaseFramebufferObjects(texture: InternalTexture): void;
  30999. /** @hidden */
  31000. _releaseTexture(texture: InternalTexture): void;
  31001. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31002. protected _setProgram(program: WebGLProgram): void;
  31003. protected _boundUniforms: {
  31004. [key: number]: WebGLUniformLocation;
  31005. };
  31006. /**
  31007. * Binds an effect to the webGL context
  31008. * @param effect defines the effect to bind
  31009. */
  31010. bindSamplers(effect: Effect): void;
  31011. private _activateCurrentTexture;
  31012. /** @hidden */
  31013. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31014. /** @hidden */
  31015. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31016. /**
  31017. * Unbind all textures from the webGL context
  31018. */
  31019. unbindAllTextures(): void;
  31020. /**
  31021. * Sets a texture to the according uniform.
  31022. * @param channel The texture channel
  31023. * @param uniform The uniform to set
  31024. * @param texture The texture to apply
  31025. */
  31026. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31027. private _bindSamplerUniformToChannel;
  31028. private _getTextureWrapMode;
  31029. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31030. /**
  31031. * Sets an array of texture to the webGL context
  31032. * @param channel defines the channel where the texture array must be set
  31033. * @param uniform defines the associated uniform location
  31034. * @param textures defines the array of textures to bind
  31035. */
  31036. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31037. /** @hidden */
  31038. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31039. private _setTextureParameterFloat;
  31040. private _setTextureParameterInteger;
  31041. /**
  31042. * Unbind all vertex attributes from the webGL context
  31043. */
  31044. unbindAllAttributes(): void;
  31045. /**
  31046. * 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
  31047. */
  31048. releaseEffects(): void;
  31049. /**
  31050. * Dispose and release all associated resources
  31051. */
  31052. dispose(): void;
  31053. /**
  31054. * Attach a new callback raised when context lost event is fired
  31055. * @param callback defines the callback to call
  31056. */
  31057. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31058. /**
  31059. * Attach a new callback raised when context restored event is fired
  31060. * @param callback defines the callback to call
  31061. */
  31062. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31063. /**
  31064. * Get the current error code of the webGL context
  31065. * @returns the error code
  31066. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31067. */
  31068. getError(): number;
  31069. private _canRenderToFloatFramebuffer;
  31070. private _canRenderToHalfFloatFramebuffer;
  31071. private _canRenderToFramebuffer;
  31072. /** @hidden */
  31073. _getWebGLTextureType(type: number): number;
  31074. /** @hidden */
  31075. _getInternalFormat(format: number): number;
  31076. /** @hidden */
  31077. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31078. /** @hidden */
  31079. _getRGBAMultiSampleBufferFormat(type: number): number;
  31080. /** @hidden */
  31081. _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;
  31082. /**
  31083. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31084. * @returns true if the engine can be created
  31085. * @ignorenaming
  31086. */
  31087. static isSupported(): boolean;
  31088. /**
  31089. * Find the next highest power of two.
  31090. * @param x Number to start search from.
  31091. * @return Next highest power of two.
  31092. */
  31093. static CeilingPOT(x: number): number;
  31094. /**
  31095. * Find the next lowest power of two.
  31096. * @param x Number to start search from.
  31097. * @return Next lowest power of two.
  31098. */
  31099. static FloorPOT(x: number): number;
  31100. /**
  31101. * Find the nearest power of two.
  31102. * @param x Number to start search from.
  31103. * @return Next nearest power of two.
  31104. */
  31105. static NearestPOT(x: number): number;
  31106. /**
  31107. * Get the closest exponent of two
  31108. * @param value defines the value to approximate
  31109. * @param max defines the maximum value to return
  31110. * @param mode defines how to define the closest value
  31111. * @returns closest exponent of two of the given value
  31112. */
  31113. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31114. /**
  31115. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31116. * @param func - the function to be called
  31117. * @param requester - the object that will request the next frame. Falls back to window.
  31118. * @returns frame number
  31119. */
  31120. static QueueNewFrame(func: () => void, requester?: any): number;
  31121. }
  31122. }
  31123. declare module "babylonjs/Maths/sphericalPolynomial" {
  31124. import { Vector3 } from "babylonjs/Maths/math.vector";
  31125. import { Color3 } from "babylonjs/Maths/math.color";
  31126. /**
  31127. * Class representing spherical harmonics coefficients to the 3rd degree
  31128. */
  31129. export class SphericalHarmonics {
  31130. /**
  31131. * Defines whether or not the harmonics have been prescaled for rendering.
  31132. */
  31133. preScaled: boolean;
  31134. /**
  31135. * The l0,0 coefficients of the spherical harmonics
  31136. */
  31137. l00: Vector3;
  31138. /**
  31139. * The l1,-1 coefficients of the spherical harmonics
  31140. */
  31141. l1_1: Vector3;
  31142. /**
  31143. * The l1,0 coefficients of the spherical harmonics
  31144. */
  31145. l10: Vector3;
  31146. /**
  31147. * The l1,1 coefficients of the spherical harmonics
  31148. */
  31149. l11: Vector3;
  31150. /**
  31151. * The l2,-2 coefficients of the spherical harmonics
  31152. */
  31153. l2_2: Vector3;
  31154. /**
  31155. * The l2,-1 coefficients of the spherical harmonics
  31156. */
  31157. l2_1: Vector3;
  31158. /**
  31159. * The l2,0 coefficients of the spherical harmonics
  31160. */
  31161. l20: Vector3;
  31162. /**
  31163. * The l2,1 coefficients of the spherical harmonics
  31164. */
  31165. l21: Vector3;
  31166. /**
  31167. * The l2,2 coefficients of the spherical harmonics
  31168. */
  31169. l22: Vector3;
  31170. /**
  31171. * Adds a light to the spherical harmonics
  31172. * @param direction the direction of the light
  31173. * @param color the color of the light
  31174. * @param deltaSolidAngle the delta solid angle of the light
  31175. */
  31176. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31177. /**
  31178. * Scales the spherical harmonics by the given amount
  31179. * @param scale the amount to scale
  31180. */
  31181. scaleInPlace(scale: number): void;
  31182. /**
  31183. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31184. *
  31185. * ```
  31186. * E_lm = A_l * L_lm
  31187. * ```
  31188. *
  31189. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31190. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31191. * the scaling factors are given in equation 9.
  31192. */
  31193. convertIncidentRadianceToIrradiance(): void;
  31194. /**
  31195. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31196. *
  31197. * ```
  31198. * L = (1/pi) * E * rho
  31199. * ```
  31200. *
  31201. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31202. */
  31203. convertIrradianceToLambertianRadiance(): void;
  31204. /**
  31205. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31206. * required operations at run time.
  31207. *
  31208. * This is simply done by scaling back the SH with Ylm constants parameter.
  31209. * The trigonometric part being applied by the shader at run time.
  31210. */
  31211. preScaleForRendering(): void;
  31212. /**
  31213. * Constructs a spherical harmonics from an array.
  31214. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31215. * @returns the spherical harmonics
  31216. */
  31217. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31218. /**
  31219. * Gets the spherical harmonics from polynomial
  31220. * @param polynomial the spherical polynomial
  31221. * @returns the spherical harmonics
  31222. */
  31223. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31224. }
  31225. /**
  31226. * Class representing spherical polynomial coefficients to the 3rd degree
  31227. */
  31228. export class SphericalPolynomial {
  31229. private _harmonics;
  31230. /**
  31231. * The spherical harmonics used to create the polynomials.
  31232. */
  31233. readonly preScaledHarmonics: SphericalHarmonics;
  31234. /**
  31235. * The x coefficients of the spherical polynomial
  31236. */
  31237. x: Vector3;
  31238. /**
  31239. * The y coefficients of the spherical polynomial
  31240. */
  31241. y: Vector3;
  31242. /**
  31243. * The z coefficients of the spherical polynomial
  31244. */
  31245. z: Vector3;
  31246. /**
  31247. * The xx coefficients of the spherical polynomial
  31248. */
  31249. xx: Vector3;
  31250. /**
  31251. * The yy coefficients of the spherical polynomial
  31252. */
  31253. yy: Vector3;
  31254. /**
  31255. * The zz coefficients of the spherical polynomial
  31256. */
  31257. zz: Vector3;
  31258. /**
  31259. * The xy coefficients of the spherical polynomial
  31260. */
  31261. xy: Vector3;
  31262. /**
  31263. * The yz coefficients of the spherical polynomial
  31264. */
  31265. yz: Vector3;
  31266. /**
  31267. * The zx coefficients of the spherical polynomial
  31268. */
  31269. zx: Vector3;
  31270. /**
  31271. * Adds an ambient color to the spherical polynomial
  31272. * @param color the color to add
  31273. */
  31274. addAmbient(color: Color3): void;
  31275. /**
  31276. * Scales the spherical polynomial by the given amount
  31277. * @param scale the amount to scale
  31278. */
  31279. scaleInPlace(scale: number): void;
  31280. /**
  31281. * Gets the spherical polynomial from harmonics
  31282. * @param harmonics the spherical harmonics
  31283. * @returns the spherical polynomial
  31284. */
  31285. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31286. /**
  31287. * Constructs a spherical polynomial from an array.
  31288. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31289. * @returns the spherical polynomial
  31290. */
  31291. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31292. }
  31293. }
  31294. declare module "babylonjs/Materials/Textures/internalTexture" {
  31295. import { Observable } from "babylonjs/Misc/observable";
  31296. import { Nullable, int } from "babylonjs/types";
  31297. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31299. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31300. /**
  31301. * Defines the source of the internal texture
  31302. */
  31303. export enum InternalTextureSource {
  31304. /**
  31305. * The source of the texture data is unknown
  31306. */
  31307. Unknown = 0,
  31308. /**
  31309. * Texture data comes from an URL
  31310. */
  31311. Url = 1,
  31312. /**
  31313. * Texture data is only used for temporary storage
  31314. */
  31315. Temp = 2,
  31316. /**
  31317. * Texture data comes from raw data (ArrayBuffer)
  31318. */
  31319. Raw = 3,
  31320. /**
  31321. * Texture content is dynamic (video or dynamic texture)
  31322. */
  31323. Dynamic = 4,
  31324. /**
  31325. * Texture content is generated by rendering to it
  31326. */
  31327. RenderTarget = 5,
  31328. /**
  31329. * Texture content is part of a multi render target process
  31330. */
  31331. MultiRenderTarget = 6,
  31332. /**
  31333. * Texture data comes from a cube data file
  31334. */
  31335. Cube = 7,
  31336. /**
  31337. * Texture data comes from a raw cube data
  31338. */
  31339. CubeRaw = 8,
  31340. /**
  31341. * Texture data come from a prefiltered cube data file
  31342. */
  31343. CubePrefiltered = 9,
  31344. /**
  31345. * Texture content is raw 3D data
  31346. */
  31347. Raw3D = 10,
  31348. /**
  31349. * Texture content is raw 2D array data
  31350. */
  31351. Raw2DArray = 11,
  31352. /**
  31353. * Texture content is a depth texture
  31354. */
  31355. Depth = 12,
  31356. /**
  31357. * Texture data comes from a raw cube data encoded with RGBD
  31358. */
  31359. CubeRawRGBD = 13
  31360. }
  31361. /**
  31362. * Class used to store data associated with WebGL texture data for the engine
  31363. * This class should not be used directly
  31364. */
  31365. export class InternalTexture {
  31366. /** @hidden */
  31367. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31368. /**
  31369. * Defines if the texture is ready
  31370. */
  31371. isReady: boolean;
  31372. /**
  31373. * Defines if the texture is a cube texture
  31374. */
  31375. isCube: boolean;
  31376. /**
  31377. * Defines if the texture contains 3D data
  31378. */
  31379. is3D: boolean;
  31380. /**
  31381. * Defines if the texture contains 2D array data
  31382. */
  31383. is2DArray: boolean;
  31384. /**
  31385. * Defines if the texture contains multiview data
  31386. */
  31387. isMultiview: boolean;
  31388. /**
  31389. * Gets the URL used to load this texture
  31390. */
  31391. url: string;
  31392. /**
  31393. * Gets the sampling mode of the texture
  31394. */
  31395. samplingMode: number;
  31396. /**
  31397. * Gets a boolean indicating if the texture needs mipmaps generation
  31398. */
  31399. generateMipMaps: boolean;
  31400. /**
  31401. * Gets the number of samples used by the texture (WebGL2+ only)
  31402. */
  31403. samples: number;
  31404. /**
  31405. * Gets the type of the texture (int, float...)
  31406. */
  31407. type: number;
  31408. /**
  31409. * Gets the format of the texture (RGB, RGBA...)
  31410. */
  31411. format: number;
  31412. /**
  31413. * Observable called when the texture is loaded
  31414. */
  31415. onLoadedObservable: Observable<InternalTexture>;
  31416. /**
  31417. * Gets the width of the texture
  31418. */
  31419. width: number;
  31420. /**
  31421. * Gets the height of the texture
  31422. */
  31423. height: number;
  31424. /**
  31425. * Gets the depth of the texture
  31426. */
  31427. depth: number;
  31428. /**
  31429. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31430. */
  31431. baseWidth: number;
  31432. /**
  31433. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31434. */
  31435. baseHeight: number;
  31436. /**
  31437. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31438. */
  31439. baseDepth: number;
  31440. /**
  31441. * Gets a boolean indicating if the texture is inverted on Y axis
  31442. */
  31443. invertY: boolean;
  31444. /** @hidden */
  31445. _invertVScale: boolean;
  31446. /** @hidden */
  31447. _associatedChannel: number;
  31448. /** @hidden */
  31449. _source: InternalTextureSource;
  31450. /** @hidden */
  31451. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31452. /** @hidden */
  31453. _bufferView: Nullable<ArrayBufferView>;
  31454. /** @hidden */
  31455. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31456. /** @hidden */
  31457. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31458. /** @hidden */
  31459. _size: number;
  31460. /** @hidden */
  31461. _extension: string;
  31462. /** @hidden */
  31463. _files: Nullable<string[]>;
  31464. /** @hidden */
  31465. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31466. /** @hidden */
  31467. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31468. /** @hidden */
  31469. _framebuffer: Nullable<WebGLFramebuffer>;
  31470. /** @hidden */
  31471. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31472. /** @hidden */
  31473. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31474. /** @hidden */
  31475. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31476. /** @hidden */
  31477. _attachments: Nullable<number[]>;
  31478. /** @hidden */
  31479. _cachedCoordinatesMode: Nullable<number>;
  31480. /** @hidden */
  31481. _cachedWrapU: Nullable<number>;
  31482. /** @hidden */
  31483. _cachedWrapV: Nullable<number>;
  31484. /** @hidden */
  31485. _cachedWrapR: Nullable<number>;
  31486. /** @hidden */
  31487. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31488. /** @hidden */
  31489. _isDisabled: boolean;
  31490. /** @hidden */
  31491. _compression: Nullable<string>;
  31492. /** @hidden */
  31493. _generateStencilBuffer: boolean;
  31494. /** @hidden */
  31495. _generateDepthBuffer: boolean;
  31496. /** @hidden */
  31497. _comparisonFunction: number;
  31498. /** @hidden */
  31499. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31500. /** @hidden */
  31501. _lodGenerationScale: number;
  31502. /** @hidden */
  31503. _lodGenerationOffset: number;
  31504. /** @hidden */
  31505. _colorTextureArray: Nullable<WebGLTexture>;
  31506. /** @hidden */
  31507. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31508. /** @hidden */
  31509. _lodTextureHigh: Nullable<BaseTexture>;
  31510. /** @hidden */
  31511. _lodTextureMid: Nullable<BaseTexture>;
  31512. /** @hidden */
  31513. _lodTextureLow: Nullable<BaseTexture>;
  31514. /** @hidden */
  31515. _isRGBD: boolean;
  31516. /** @hidden */
  31517. _linearSpecularLOD: boolean;
  31518. /** @hidden */
  31519. _irradianceTexture: Nullable<BaseTexture>;
  31520. /** @hidden */
  31521. _webGLTexture: Nullable<WebGLTexture>;
  31522. /** @hidden */
  31523. _references: number;
  31524. private _engine;
  31525. /**
  31526. * Gets the Engine the texture belongs to.
  31527. * @returns The babylon engine
  31528. */
  31529. getEngine(): ThinEngine;
  31530. /**
  31531. * Gets the data source type of the texture
  31532. */
  31533. readonly source: InternalTextureSource;
  31534. /**
  31535. * Creates a new InternalTexture
  31536. * @param engine defines the engine to use
  31537. * @param source defines the type of data that will be used
  31538. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31539. */
  31540. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31541. /**
  31542. * Increments the number of references (ie. the number of Texture that point to it)
  31543. */
  31544. incrementReferences(): void;
  31545. /**
  31546. * Change the size of the texture (not the size of the content)
  31547. * @param width defines the new width
  31548. * @param height defines the new height
  31549. * @param depth defines the new depth (1 by default)
  31550. */
  31551. updateSize(width: int, height: int, depth?: int): void;
  31552. /** @hidden */
  31553. _rebuild(): void;
  31554. /** @hidden */
  31555. _swapAndDie(target: InternalTexture): void;
  31556. /**
  31557. * Dispose the current allocated resources
  31558. */
  31559. dispose(): void;
  31560. }
  31561. }
  31562. declare module "babylonjs/Audio/analyser" {
  31563. import { Scene } from "babylonjs/scene";
  31564. /**
  31565. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31567. */
  31568. export class Analyser {
  31569. /**
  31570. * Gets or sets the smoothing
  31571. * @ignorenaming
  31572. */
  31573. SMOOTHING: number;
  31574. /**
  31575. * Gets or sets the FFT table size
  31576. * @ignorenaming
  31577. */
  31578. FFT_SIZE: number;
  31579. /**
  31580. * Gets or sets the bar graph amplitude
  31581. * @ignorenaming
  31582. */
  31583. BARGRAPHAMPLITUDE: number;
  31584. /**
  31585. * Gets or sets the position of the debug canvas
  31586. * @ignorenaming
  31587. */
  31588. DEBUGCANVASPOS: {
  31589. x: number;
  31590. y: number;
  31591. };
  31592. /**
  31593. * Gets or sets the debug canvas size
  31594. * @ignorenaming
  31595. */
  31596. DEBUGCANVASSIZE: {
  31597. width: number;
  31598. height: number;
  31599. };
  31600. private _byteFreqs;
  31601. private _byteTime;
  31602. private _floatFreqs;
  31603. private _webAudioAnalyser;
  31604. private _debugCanvas;
  31605. private _debugCanvasContext;
  31606. private _scene;
  31607. private _registerFunc;
  31608. private _audioEngine;
  31609. /**
  31610. * Creates a new analyser
  31611. * @param scene defines hosting scene
  31612. */
  31613. constructor(scene: Scene);
  31614. /**
  31615. * Get the number of data values you will have to play with for the visualization
  31616. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31617. * @returns a number
  31618. */
  31619. getFrequencyBinCount(): number;
  31620. /**
  31621. * Gets the current frequency data as a byte array
  31622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31623. * @returns a Uint8Array
  31624. */
  31625. getByteFrequencyData(): Uint8Array;
  31626. /**
  31627. * Gets the current waveform as a byte array
  31628. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31629. * @returns a Uint8Array
  31630. */
  31631. getByteTimeDomainData(): Uint8Array;
  31632. /**
  31633. * Gets the current frequency data as a float array
  31634. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31635. * @returns a Float32Array
  31636. */
  31637. getFloatFrequencyData(): Float32Array;
  31638. /**
  31639. * Renders the debug canvas
  31640. */
  31641. drawDebugCanvas(): void;
  31642. /**
  31643. * Stops rendering the debug canvas and removes it
  31644. */
  31645. stopDebugCanvas(): void;
  31646. /**
  31647. * Connects two audio nodes
  31648. * @param inputAudioNode defines first node to connect
  31649. * @param outputAudioNode defines second node to connect
  31650. */
  31651. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31652. /**
  31653. * Releases all associated resources
  31654. */
  31655. dispose(): void;
  31656. }
  31657. }
  31658. declare module "babylonjs/Audio/audioEngine" {
  31659. import { IDisposable } from "babylonjs/scene";
  31660. import { Analyser } from "babylonjs/Audio/analyser";
  31661. import { Nullable } from "babylonjs/types";
  31662. import { Observable } from "babylonjs/Misc/observable";
  31663. /**
  31664. * This represents an audio engine and it is responsible
  31665. * to play, synchronize and analyse sounds throughout the application.
  31666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31667. */
  31668. export interface IAudioEngine extends IDisposable {
  31669. /**
  31670. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31671. */
  31672. readonly canUseWebAudio: boolean;
  31673. /**
  31674. * Gets the current AudioContext if available.
  31675. */
  31676. readonly audioContext: Nullable<AudioContext>;
  31677. /**
  31678. * The master gain node defines the global audio volume of your audio engine.
  31679. */
  31680. readonly masterGain: GainNode;
  31681. /**
  31682. * Gets whether or not mp3 are supported by your browser.
  31683. */
  31684. readonly isMP3supported: boolean;
  31685. /**
  31686. * Gets whether or not ogg are supported by your browser.
  31687. */
  31688. readonly isOGGsupported: boolean;
  31689. /**
  31690. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31691. * @ignoreNaming
  31692. */
  31693. WarnedWebAudioUnsupported: boolean;
  31694. /**
  31695. * Defines if the audio engine relies on a custom unlocked button.
  31696. * In this case, the embedded button will not be displayed.
  31697. */
  31698. useCustomUnlockedButton: boolean;
  31699. /**
  31700. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31701. */
  31702. readonly unlocked: boolean;
  31703. /**
  31704. * Event raised when audio has been unlocked on the browser.
  31705. */
  31706. onAudioUnlockedObservable: Observable<AudioEngine>;
  31707. /**
  31708. * Event raised when audio has been locked on the browser.
  31709. */
  31710. onAudioLockedObservable: Observable<AudioEngine>;
  31711. /**
  31712. * Flags the audio engine in Locked state.
  31713. * This happens due to new browser policies preventing audio to autoplay.
  31714. */
  31715. lock(): void;
  31716. /**
  31717. * Unlocks the audio engine once a user action has been done on the dom.
  31718. * This is helpful to resume play once browser policies have been satisfied.
  31719. */
  31720. unlock(): void;
  31721. }
  31722. /**
  31723. * This represents the default audio engine used in babylon.
  31724. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31726. */
  31727. export class AudioEngine implements IAudioEngine {
  31728. private _audioContext;
  31729. private _audioContextInitialized;
  31730. private _muteButton;
  31731. private _hostElement;
  31732. /**
  31733. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31734. */
  31735. canUseWebAudio: boolean;
  31736. /**
  31737. * The master gain node defines the global audio volume of your audio engine.
  31738. */
  31739. masterGain: GainNode;
  31740. /**
  31741. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31742. * @ignoreNaming
  31743. */
  31744. WarnedWebAudioUnsupported: boolean;
  31745. /**
  31746. * Gets whether or not mp3 are supported by your browser.
  31747. */
  31748. isMP3supported: boolean;
  31749. /**
  31750. * Gets whether or not ogg are supported by your browser.
  31751. */
  31752. isOGGsupported: boolean;
  31753. /**
  31754. * Gets whether audio has been unlocked on the device.
  31755. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31756. * a user interaction has happened.
  31757. */
  31758. unlocked: boolean;
  31759. /**
  31760. * Defines if the audio engine relies on a custom unlocked button.
  31761. * In this case, the embedded button will not be displayed.
  31762. */
  31763. useCustomUnlockedButton: boolean;
  31764. /**
  31765. * Event raised when audio has been unlocked on the browser.
  31766. */
  31767. onAudioUnlockedObservable: Observable<AudioEngine>;
  31768. /**
  31769. * Event raised when audio has been locked on the browser.
  31770. */
  31771. onAudioLockedObservable: Observable<AudioEngine>;
  31772. /**
  31773. * Gets the current AudioContext if available.
  31774. */
  31775. readonly audioContext: Nullable<AudioContext>;
  31776. private _connectedAnalyser;
  31777. /**
  31778. * Instantiates a new audio engine.
  31779. *
  31780. * There should be only one per page as some browsers restrict the number
  31781. * of audio contexts you can create.
  31782. * @param hostElement defines the host element where to display the mute icon if necessary
  31783. */
  31784. constructor(hostElement?: Nullable<HTMLElement>);
  31785. /**
  31786. * Flags the audio engine in Locked state.
  31787. * This happens due to new browser policies preventing audio to autoplay.
  31788. */
  31789. lock(): void;
  31790. /**
  31791. * Unlocks the audio engine once a user action has been done on the dom.
  31792. * This is helpful to resume play once browser policies have been satisfied.
  31793. */
  31794. unlock(): void;
  31795. private _resumeAudioContext;
  31796. private _initializeAudioContext;
  31797. private _tryToRun;
  31798. private _triggerRunningState;
  31799. private _triggerSuspendedState;
  31800. private _displayMuteButton;
  31801. private _moveButtonToTopLeft;
  31802. private _onResize;
  31803. private _hideMuteButton;
  31804. /**
  31805. * Destroy and release the resources associated with the audio ccontext.
  31806. */
  31807. dispose(): void;
  31808. /**
  31809. * Gets the global volume sets on the master gain.
  31810. * @returns the global volume if set or -1 otherwise
  31811. */
  31812. getGlobalVolume(): number;
  31813. /**
  31814. * Sets the global volume of your experience (sets on the master gain).
  31815. * @param newVolume Defines the new global volume of the application
  31816. */
  31817. setGlobalVolume(newVolume: number): void;
  31818. /**
  31819. * Connect the audio engine to an audio analyser allowing some amazing
  31820. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31822. * @param analyser The analyser to connect to the engine
  31823. */
  31824. connectToAnalyser(analyser: Analyser): void;
  31825. }
  31826. }
  31827. declare module "babylonjs/Loading/loadingScreen" {
  31828. /**
  31829. * Interface used to present a loading screen while loading a scene
  31830. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31831. */
  31832. export interface ILoadingScreen {
  31833. /**
  31834. * Function called to display the loading screen
  31835. */
  31836. displayLoadingUI: () => void;
  31837. /**
  31838. * Function called to hide the loading screen
  31839. */
  31840. hideLoadingUI: () => void;
  31841. /**
  31842. * Gets or sets the color to use for the background
  31843. */
  31844. loadingUIBackgroundColor: string;
  31845. /**
  31846. * Gets or sets the text to display while loading
  31847. */
  31848. loadingUIText: string;
  31849. }
  31850. /**
  31851. * Class used for the default loading screen
  31852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31853. */
  31854. export class DefaultLoadingScreen implements ILoadingScreen {
  31855. private _renderingCanvas;
  31856. private _loadingText;
  31857. private _loadingDivBackgroundColor;
  31858. private _loadingDiv;
  31859. private _loadingTextDiv;
  31860. /** Gets or sets the logo url to use for the default loading screen */
  31861. static DefaultLogoUrl: string;
  31862. /** Gets or sets the spinner url to use for the default loading screen */
  31863. static DefaultSpinnerUrl: string;
  31864. /**
  31865. * Creates a new default loading screen
  31866. * @param _renderingCanvas defines the canvas used to render the scene
  31867. * @param _loadingText defines the default text to display
  31868. * @param _loadingDivBackgroundColor defines the default background color
  31869. */
  31870. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31871. /**
  31872. * Function called to display the loading screen
  31873. */
  31874. displayLoadingUI(): void;
  31875. /**
  31876. * Function called to hide the loading screen
  31877. */
  31878. hideLoadingUI(): void;
  31879. /**
  31880. * Gets or sets the text to display while loading
  31881. */
  31882. loadingUIText: string;
  31883. /**
  31884. * Gets or sets the color to use for the background
  31885. */
  31886. loadingUIBackgroundColor: string;
  31887. private _resizeLoadingUI;
  31888. }
  31889. }
  31890. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31891. /**
  31892. * Interface for any object that can request an animation frame
  31893. */
  31894. export interface ICustomAnimationFrameRequester {
  31895. /**
  31896. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31897. */
  31898. renderFunction?: Function;
  31899. /**
  31900. * Called to request the next frame to render to
  31901. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31902. */
  31903. requestAnimationFrame: Function;
  31904. /**
  31905. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31906. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31907. */
  31908. requestID?: number;
  31909. }
  31910. }
  31911. declare module "babylonjs/Misc/performanceMonitor" {
  31912. /**
  31913. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31914. */
  31915. export class PerformanceMonitor {
  31916. private _enabled;
  31917. private _rollingFrameTime;
  31918. private _lastFrameTimeMs;
  31919. /**
  31920. * constructor
  31921. * @param frameSampleSize The number of samples required to saturate the sliding window
  31922. */
  31923. constructor(frameSampleSize?: number);
  31924. /**
  31925. * Samples current frame
  31926. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31927. */
  31928. sampleFrame(timeMs?: number): void;
  31929. /**
  31930. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31931. */
  31932. readonly averageFrameTime: number;
  31933. /**
  31934. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31935. */
  31936. readonly averageFrameTimeVariance: number;
  31937. /**
  31938. * Returns the frame time of the most recent frame
  31939. */
  31940. readonly instantaneousFrameTime: number;
  31941. /**
  31942. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31943. */
  31944. readonly averageFPS: number;
  31945. /**
  31946. * Returns the average framerate in frames per second using the most recent frame time
  31947. */
  31948. readonly instantaneousFPS: number;
  31949. /**
  31950. * Returns true if enough samples have been taken to completely fill the sliding window
  31951. */
  31952. readonly isSaturated: boolean;
  31953. /**
  31954. * Enables contributions to the sliding window sample set
  31955. */
  31956. enable(): void;
  31957. /**
  31958. * Disables contributions to the sliding window sample set
  31959. * Samples will not be interpolated over the disabled period
  31960. */
  31961. disable(): void;
  31962. /**
  31963. * Returns true if sampling is enabled
  31964. */
  31965. readonly isEnabled: boolean;
  31966. /**
  31967. * Resets performance monitor
  31968. */
  31969. reset(): void;
  31970. }
  31971. /**
  31972. * RollingAverage
  31973. *
  31974. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31975. */
  31976. export class RollingAverage {
  31977. /**
  31978. * Current average
  31979. */
  31980. average: number;
  31981. /**
  31982. * Current variance
  31983. */
  31984. variance: number;
  31985. protected _samples: Array<number>;
  31986. protected _sampleCount: number;
  31987. protected _pos: number;
  31988. protected _m2: number;
  31989. /**
  31990. * constructor
  31991. * @param length The number of samples required to saturate the sliding window
  31992. */
  31993. constructor(length: number);
  31994. /**
  31995. * Adds a sample to the sample set
  31996. * @param v The sample value
  31997. */
  31998. add(v: number): void;
  31999. /**
  32000. * Returns previously added values or null if outside of history or outside the sliding window domain
  32001. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32002. * @return Value previously recorded with add() or null if outside of range
  32003. */
  32004. history(i: number): number;
  32005. /**
  32006. * Returns true if enough samples have been taken to completely fill the sliding window
  32007. * @return true if sample-set saturated
  32008. */
  32009. isSaturated(): boolean;
  32010. /**
  32011. * Resets the rolling average (equivalent to 0 samples taken so far)
  32012. */
  32013. reset(): void;
  32014. /**
  32015. * Wraps a value around the sample range boundaries
  32016. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32017. * @return Wrapped position in sample range
  32018. */
  32019. protected _wrapPosition(i: number): number;
  32020. }
  32021. }
  32022. declare module "babylonjs/Misc/perfCounter" {
  32023. /**
  32024. * This class is used to track a performance counter which is number based.
  32025. * The user has access to many properties which give statistics of different nature.
  32026. *
  32027. * The implementer can track two kinds of Performance Counter: time and count.
  32028. * 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.
  32029. * 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.
  32030. */
  32031. export class PerfCounter {
  32032. /**
  32033. * Gets or sets a global boolean to turn on and off all the counters
  32034. */
  32035. static Enabled: boolean;
  32036. /**
  32037. * Returns the smallest value ever
  32038. */
  32039. readonly min: number;
  32040. /**
  32041. * Returns the biggest value ever
  32042. */
  32043. readonly max: number;
  32044. /**
  32045. * Returns the average value since the performance counter is running
  32046. */
  32047. readonly average: number;
  32048. /**
  32049. * Returns the average value of the last second the counter was monitored
  32050. */
  32051. readonly lastSecAverage: number;
  32052. /**
  32053. * Returns the current value
  32054. */
  32055. readonly current: number;
  32056. /**
  32057. * Gets the accumulated total
  32058. */
  32059. readonly total: number;
  32060. /**
  32061. * Gets the total value count
  32062. */
  32063. readonly count: number;
  32064. /**
  32065. * Creates a new counter
  32066. */
  32067. constructor();
  32068. /**
  32069. * Call this method to start monitoring a new frame.
  32070. * 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.
  32071. */
  32072. fetchNewFrame(): void;
  32073. /**
  32074. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32075. * @param newCount the count value to add to the monitored count
  32076. * @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.
  32077. */
  32078. addCount(newCount: number, fetchResult: boolean): void;
  32079. /**
  32080. * Start monitoring this performance counter
  32081. */
  32082. beginMonitoring(): void;
  32083. /**
  32084. * Compute the time lapsed since the previous beginMonitoring() call.
  32085. * @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
  32086. */
  32087. endMonitoring(newFrame?: boolean): void;
  32088. private _fetchResult;
  32089. private _startMonitoringTime;
  32090. private _min;
  32091. private _max;
  32092. private _average;
  32093. private _current;
  32094. private _totalValueCount;
  32095. private _totalAccumulated;
  32096. private _lastSecAverage;
  32097. private _lastSecAccumulated;
  32098. private _lastSecTime;
  32099. private _lastSecValueCount;
  32100. }
  32101. }
  32102. declare module "babylonjs/Engines/engine" {
  32103. import { Observable } from "babylonjs/Misc/observable";
  32104. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32105. import { Scene } from "babylonjs/scene";
  32106. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32107. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32108. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32109. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32110. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32111. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32112. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32113. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32114. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32116. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32117. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32118. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32119. import { Material } from "babylonjs/Materials/material";
  32120. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32121. /**
  32122. * Defines the interface used by display changed events
  32123. */
  32124. export interface IDisplayChangedEventArgs {
  32125. /** Gets the vrDisplay object (if any) */
  32126. vrDisplay: Nullable<any>;
  32127. /** Gets a boolean indicating if webVR is supported */
  32128. vrSupported: boolean;
  32129. }
  32130. /**
  32131. * Defines the interface used by objects containing a viewport (like a camera)
  32132. */
  32133. interface IViewportOwnerLike {
  32134. /**
  32135. * Gets or sets the viewport
  32136. */
  32137. viewport: IViewportLike;
  32138. }
  32139. /**
  32140. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32141. */
  32142. export class Engine extends ThinEngine {
  32143. /** Defines that alpha blending is disabled */
  32144. static readonly ALPHA_DISABLE: number;
  32145. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32146. static readonly ALPHA_ADD: number;
  32147. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32148. static readonly ALPHA_COMBINE: number;
  32149. /** Defines that alpha blending to DEST - SRC * DEST */
  32150. static readonly ALPHA_SUBTRACT: number;
  32151. /** Defines that alpha blending to SRC * DEST */
  32152. static readonly ALPHA_MULTIPLY: number;
  32153. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32154. static readonly ALPHA_MAXIMIZED: number;
  32155. /** Defines that alpha blending to SRC + DEST */
  32156. static readonly ALPHA_ONEONE: number;
  32157. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32158. static readonly ALPHA_PREMULTIPLIED: number;
  32159. /**
  32160. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32161. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32162. */
  32163. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32164. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32165. static readonly ALPHA_INTERPOLATE: number;
  32166. /**
  32167. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32168. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32169. */
  32170. static readonly ALPHA_SCREENMODE: number;
  32171. /** Defines that the ressource is not delayed*/
  32172. static readonly DELAYLOADSTATE_NONE: number;
  32173. /** Defines that the ressource was successfully delay loaded */
  32174. static readonly DELAYLOADSTATE_LOADED: number;
  32175. /** Defines that the ressource is currently delay loading */
  32176. static readonly DELAYLOADSTATE_LOADING: number;
  32177. /** Defines that the ressource is delayed and has not started loading */
  32178. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32179. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32180. static readonly NEVER: number;
  32181. /** 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 */
  32182. static readonly ALWAYS: number;
  32183. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32184. static readonly LESS: number;
  32185. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32186. static readonly EQUAL: number;
  32187. /** 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 */
  32188. static readonly LEQUAL: number;
  32189. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32190. static readonly GREATER: number;
  32191. /** 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 */
  32192. static readonly GEQUAL: number;
  32193. /** 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 */
  32194. static readonly NOTEQUAL: number;
  32195. /** Passed to stencilOperation to specify that stencil value must be kept */
  32196. static readonly KEEP: number;
  32197. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32198. static readonly REPLACE: number;
  32199. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32200. static readonly INCR: number;
  32201. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32202. static readonly DECR: number;
  32203. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32204. static readonly INVERT: number;
  32205. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32206. static readonly INCR_WRAP: number;
  32207. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32208. static readonly DECR_WRAP: number;
  32209. /** Texture is not repeating outside of 0..1 UVs */
  32210. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32211. /** Texture is repeating outside of 0..1 UVs */
  32212. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32213. /** Texture is repeating and mirrored */
  32214. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32215. /** ALPHA */
  32216. static readonly TEXTUREFORMAT_ALPHA: number;
  32217. /** LUMINANCE */
  32218. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32219. /** LUMINANCE_ALPHA */
  32220. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32221. /** RGB */
  32222. static readonly TEXTUREFORMAT_RGB: number;
  32223. /** RGBA */
  32224. static readonly TEXTUREFORMAT_RGBA: number;
  32225. /** RED */
  32226. static readonly TEXTUREFORMAT_RED: number;
  32227. /** RED (2nd reference) */
  32228. static readonly TEXTUREFORMAT_R: number;
  32229. /** RG */
  32230. static readonly TEXTUREFORMAT_RG: number;
  32231. /** RED_INTEGER */
  32232. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32233. /** RED_INTEGER (2nd reference) */
  32234. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32235. /** RG_INTEGER */
  32236. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32237. /** RGB_INTEGER */
  32238. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32239. /** RGBA_INTEGER */
  32240. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32241. /** UNSIGNED_BYTE */
  32242. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32243. /** UNSIGNED_BYTE (2nd reference) */
  32244. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32245. /** FLOAT */
  32246. static readonly TEXTURETYPE_FLOAT: number;
  32247. /** HALF_FLOAT */
  32248. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32249. /** BYTE */
  32250. static readonly TEXTURETYPE_BYTE: number;
  32251. /** SHORT */
  32252. static readonly TEXTURETYPE_SHORT: number;
  32253. /** UNSIGNED_SHORT */
  32254. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32255. /** INT */
  32256. static readonly TEXTURETYPE_INT: number;
  32257. /** UNSIGNED_INT */
  32258. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32259. /** UNSIGNED_SHORT_4_4_4_4 */
  32260. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32261. /** UNSIGNED_SHORT_5_5_5_1 */
  32262. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32263. /** UNSIGNED_SHORT_5_6_5 */
  32264. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32265. /** UNSIGNED_INT_2_10_10_10_REV */
  32266. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32267. /** UNSIGNED_INT_24_8 */
  32268. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32269. /** UNSIGNED_INT_10F_11F_11F_REV */
  32270. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32271. /** UNSIGNED_INT_5_9_9_9_REV */
  32272. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32273. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32274. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32275. /** nearest is mag = nearest and min = nearest and mip = linear */
  32276. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32277. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32278. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32279. /** Trilinear is mag = linear and min = linear and mip = linear */
  32280. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32281. /** nearest is mag = nearest and min = nearest and mip = linear */
  32282. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32283. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32284. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32285. /** Trilinear is mag = linear and min = linear and mip = linear */
  32286. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32287. /** mag = nearest and min = nearest and mip = nearest */
  32288. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32289. /** mag = nearest and min = linear and mip = nearest */
  32290. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32291. /** mag = nearest and min = linear and mip = linear */
  32292. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32293. /** mag = nearest and min = linear and mip = none */
  32294. static readonly TEXTURE_NEAREST_LINEAR: number;
  32295. /** mag = nearest and min = nearest and mip = none */
  32296. static readonly TEXTURE_NEAREST_NEAREST: number;
  32297. /** mag = linear and min = nearest and mip = nearest */
  32298. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32299. /** mag = linear and min = nearest and mip = linear */
  32300. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32301. /** mag = linear and min = linear and mip = none */
  32302. static readonly TEXTURE_LINEAR_LINEAR: number;
  32303. /** mag = linear and min = nearest and mip = none */
  32304. static readonly TEXTURE_LINEAR_NEAREST: number;
  32305. /** Explicit coordinates mode */
  32306. static readonly TEXTURE_EXPLICIT_MODE: number;
  32307. /** Spherical coordinates mode */
  32308. static readonly TEXTURE_SPHERICAL_MODE: number;
  32309. /** Planar coordinates mode */
  32310. static readonly TEXTURE_PLANAR_MODE: number;
  32311. /** Cubic coordinates mode */
  32312. static readonly TEXTURE_CUBIC_MODE: number;
  32313. /** Projection coordinates mode */
  32314. static readonly TEXTURE_PROJECTION_MODE: number;
  32315. /** Skybox coordinates mode */
  32316. static readonly TEXTURE_SKYBOX_MODE: number;
  32317. /** Inverse Cubic coordinates mode */
  32318. static readonly TEXTURE_INVCUBIC_MODE: number;
  32319. /** Equirectangular coordinates mode */
  32320. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32321. /** Equirectangular Fixed coordinates mode */
  32322. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32323. /** Equirectangular Fixed Mirrored coordinates mode */
  32324. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32325. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32326. static readonly SCALEMODE_FLOOR: number;
  32327. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32328. static readonly SCALEMODE_NEAREST: number;
  32329. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32330. static readonly SCALEMODE_CEILING: number;
  32331. /**
  32332. * Returns the current npm package of the sdk
  32333. */
  32334. static readonly NpmPackage: string;
  32335. /**
  32336. * Returns the current version of the framework
  32337. */
  32338. static readonly Version: string;
  32339. /** Gets the list of created engines */
  32340. static readonly Instances: Engine[];
  32341. /**
  32342. * Gets the latest created engine
  32343. */
  32344. static readonly LastCreatedEngine: Nullable<Engine>;
  32345. /**
  32346. * Gets the latest created scene
  32347. */
  32348. static readonly LastCreatedScene: Nullable<Scene>;
  32349. /**
  32350. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32351. * @param flag defines which part of the materials must be marked as dirty
  32352. * @param predicate defines a predicate used to filter which materials should be affected
  32353. */
  32354. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32355. /**
  32356. * Method called to create the default loading screen.
  32357. * This can be overriden in your own app.
  32358. * @param canvas The rendering canvas element
  32359. * @returns The loading screen
  32360. */
  32361. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32362. /**
  32363. * Method called to create the default rescale post process on each engine.
  32364. */
  32365. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32366. /**
  32367. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32368. **/
  32369. enableOfflineSupport: boolean;
  32370. /**
  32371. * 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)
  32372. **/
  32373. disableManifestCheck: boolean;
  32374. /**
  32375. * Gets the list of created scenes
  32376. */
  32377. scenes: Scene[];
  32378. /**
  32379. * Event raised when a new scene is created
  32380. */
  32381. onNewSceneAddedObservable: Observable<Scene>;
  32382. /**
  32383. * Gets the list of created postprocesses
  32384. */
  32385. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32386. /**
  32387. * Gets a boolean indicating if the pointer is currently locked
  32388. */
  32389. isPointerLock: boolean;
  32390. /**
  32391. * Observable event triggered each time the rendering canvas is resized
  32392. */
  32393. onResizeObservable: Observable<Engine>;
  32394. /**
  32395. * Observable event triggered each time the canvas loses focus
  32396. */
  32397. onCanvasBlurObservable: Observable<Engine>;
  32398. /**
  32399. * Observable event triggered each time the canvas gains focus
  32400. */
  32401. onCanvasFocusObservable: Observable<Engine>;
  32402. /**
  32403. * Observable event triggered each time the canvas receives pointerout event
  32404. */
  32405. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32406. /**
  32407. * Observable raised when the engine begins a new frame
  32408. */
  32409. onBeginFrameObservable: Observable<Engine>;
  32410. /**
  32411. * If set, will be used to request the next animation frame for the render loop
  32412. */
  32413. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32414. /**
  32415. * Observable raised when the engine ends the current frame
  32416. */
  32417. onEndFrameObservable: Observable<Engine>;
  32418. /**
  32419. * Observable raised when the engine is about to compile a shader
  32420. */
  32421. onBeforeShaderCompilationObservable: Observable<Engine>;
  32422. /**
  32423. * Observable raised when the engine has jsut compiled a shader
  32424. */
  32425. onAfterShaderCompilationObservable: Observable<Engine>;
  32426. /**
  32427. * Gets the audio engine
  32428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32429. * @ignorenaming
  32430. */
  32431. static audioEngine: IAudioEngine;
  32432. /**
  32433. * Default AudioEngine factory responsible of creating the Audio Engine.
  32434. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32435. */
  32436. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32437. /**
  32438. * Default offline support factory responsible of creating a tool used to store data locally.
  32439. * By default, this will create a Database object if the workload has been embedded.
  32440. */
  32441. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32442. private _loadingScreen;
  32443. private _pointerLockRequested;
  32444. private _dummyFramebuffer;
  32445. private _rescalePostProcess;
  32446. /** @hidden */
  32447. protected _alphaMode: number;
  32448. /** @hidden */
  32449. protected _alphaEquation: number;
  32450. private _deterministicLockstep;
  32451. private _lockstepMaxSteps;
  32452. protected readonly _supportsHardwareTextureRescaling: boolean;
  32453. private _fps;
  32454. private _deltaTime;
  32455. /** @hidden */
  32456. _drawCalls: PerfCounter;
  32457. /**
  32458. * Turn this value on if you want to pause FPS computation when in background
  32459. */
  32460. disablePerformanceMonitorInBackground: boolean;
  32461. private _performanceMonitor;
  32462. /**
  32463. * Gets the performance monitor attached to this engine
  32464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32465. */
  32466. readonly performanceMonitor: PerformanceMonitor;
  32467. private _onFocus;
  32468. private _onBlur;
  32469. private _onCanvasPointerOut;
  32470. private _onCanvasBlur;
  32471. private _onCanvasFocus;
  32472. private _onFullscreenChange;
  32473. private _onPointerLockChange;
  32474. /**
  32475. * Gets the HTML element used to attach event listeners
  32476. * @returns a HTML element
  32477. */
  32478. getInputElement(): Nullable<HTMLElement>;
  32479. /**
  32480. * Creates a new engine
  32481. * @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
  32482. * @param antialias defines enable antialiasing (default: false)
  32483. * @param options defines further options to be sent to the getContext() function
  32484. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32485. */
  32486. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32487. /**
  32488. * Gets current aspect ratio
  32489. * @param viewportOwner defines the camera to use to get the aspect ratio
  32490. * @param useScreen defines if screen size must be used (or the current render target if any)
  32491. * @returns a number defining the aspect ratio
  32492. */
  32493. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32494. /**
  32495. * Gets current screen aspect ratio
  32496. * @returns a number defining the aspect ratio
  32497. */
  32498. getScreenAspectRatio(): number;
  32499. /**
  32500. * Gets host document
  32501. * @returns the host document object
  32502. */
  32503. getHostDocument(): Document;
  32504. /**
  32505. * Gets the client rect of the HTML canvas attached with the current webGL context
  32506. * @returns a client rectanglee
  32507. */
  32508. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32509. /**
  32510. * Gets the client rect of the HTML element used for events
  32511. * @returns a client rectanglee
  32512. */
  32513. getInputElementClientRect(): Nullable<ClientRect>;
  32514. /**
  32515. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32516. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32517. * @returns true if engine is in deterministic lock step mode
  32518. */
  32519. isDeterministicLockStep(): boolean;
  32520. /**
  32521. * Gets the max steps when engine is running in deterministic lock step
  32522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32523. * @returns the max steps
  32524. */
  32525. getLockstepMaxSteps(): number;
  32526. /**
  32527. * Force the mipmap generation for the given render target texture
  32528. * @param texture defines the render target texture to use
  32529. */
  32530. generateMipMapsForCubemap(texture: InternalTexture): void;
  32531. /** States */
  32532. /**
  32533. * Set various states to the webGL context
  32534. * @param culling defines backface culling state
  32535. * @param zOffset defines the value to apply to zOffset (0 by default)
  32536. * @param force defines if states must be applied even if cache is up to date
  32537. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32538. */
  32539. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32540. /**
  32541. * Set the z offset to apply to current rendering
  32542. * @param value defines the offset to apply
  32543. */
  32544. setZOffset(value: number): void;
  32545. /**
  32546. * Gets the current value of the zOffset
  32547. * @returns the current zOffset state
  32548. */
  32549. getZOffset(): number;
  32550. /**
  32551. * Enable or disable depth buffering
  32552. * @param enable defines the state to set
  32553. */
  32554. setDepthBuffer(enable: boolean): void;
  32555. /**
  32556. * Gets a boolean indicating if depth writing is enabled
  32557. * @returns the current depth writing state
  32558. */
  32559. getDepthWrite(): boolean;
  32560. /**
  32561. * Enable or disable depth writing
  32562. * @param enable defines the state to set
  32563. */
  32564. setDepthWrite(enable: boolean): void;
  32565. /**
  32566. * Enable or disable color writing
  32567. * @param enable defines the state to set
  32568. */
  32569. setColorWrite(enable: boolean): void;
  32570. /**
  32571. * Gets a boolean indicating if color writing is enabled
  32572. * @returns the current color writing state
  32573. */
  32574. getColorWrite(): boolean;
  32575. /**
  32576. * Sets alpha constants used by some alpha blending modes
  32577. * @param r defines the red component
  32578. * @param g defines the green component
  32579. * @param b defines the blue component
  32580. * @param a defines the alpha component
  32581. */
  32582. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32583. /**
  32584. * Sets the current alpha mode
  32585. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32586. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32587. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32588. */
  32589. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32590. /**
  32591. * Gets the current alpha mode
  32592. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32593. * @returns the current alpha mode
  32594. */
  32595. getAlphaMode(): number;
  32596. /**
  32597. * Sets the current alpha equation
  32598. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32599. */
  32600. setAlphaEquation(equation: number): void;
  32601. /**
  32602. * Gets the current alpha equation.
  32603. * @returns the current alpha equation
  32604. */
  32605. getAlphaEquation(): number;
  32606. /**
  32607. * Gets a boolean indicating if stencil buffer is enabled
  32608. * @returns the current stencil buffer state
  32609. */
  32610. getStencilBuffer(): boolean;
  32611. /**
  32612. * Enable or disable the stencil buffer
  32613. * @param enable defines if the stencil buffer must be enabled or disabled
  32614. */
  32615. setStencilBuffer(enable: boolean): void;
  32616. /**
  32617. * Gets the current stencil mask
  32618. * @returns a number defining the new stencil mask to use
  32619. */
  32620. getStencilMask(): number;
  32621. /**
  32622. * Sets the current stencil mask
  32623. * @param mask defines the new stencil mask to use
  32624. */
  32625. setStencilMask(mask: number): void;
  32626. /**
  32627. * Gets the current stencil function
  32628. * @returns a number defining the stencil function to use
  32629. */
  32630. getStencilFunction(): number;
  32631. /**
  32632. * Gets the current stencil reference value
  32633. * @returns a number defining the stencil reference value to use
  32634. */
  32635. getStencilFunctionReference(): number;
  32636. /**
  32637. * Gets the current stencil mask
  32638. * @returns a number defining the stencil mask to use
  32639. */
  32640. getStencilFunctionMask(): number;
  32641. /**
  32642. * Sets the current stencil function
  32643. * @param stencilFunc defines the new stencil function to use
  32644. */
  32645. setStencilFunction(stencilFunc: number): void;
  32646. /**
  32647. * Sets the current stencil reference
  32648. * @param reference defines the new stencil reference to use
  32649. */
  32650. setStencilFunctionReference(reference: number): void;
  32651. /**
  32652. * Sets the current stencil mask
  32653. * @param mask defines the new stencil mask to use
  32654. */
  32655. setStencilFunctionMask(mask: number): void;
  32656. /**
  32657. * Gets the current stencil operation when stencil fails
  32658. * @returns a number defining stencil operation to use when stencil fails
  32659. */
  32660. getStencilOperationFail(): number;
  32661. /**
  32662. * Gets the current stencil operation when depth fails
  32663. * @returns a number defining stencil operation to use when depth fails
  32664. */
  32665. getStencilOperationDepthFail(): number;
  32666. /**
  32667. * Gets the current stencil operation when stencil passes
  32668. * @returns a number defining stencil operation to use when stencil passes
  32669. */
  32670. getStencilOperationPass(): number;
  32671. /**
  32672. * Sets the stencil operation to use when stencil fails
  32673. * @param operation defines the stencil operation to use when stencil fails
  32674. */
  32675. setStencilOperationFail(operation: number): void;
  32676. /**
  32677. * Sets the stencil operation to use when depth fails
  32678. * @param operation defines the stencil operation to use when depth fails
  32679. */
  32680. setStencilOperationDepthFail(operation: number): void;
  32681. /**
  32682. * Sets the stencil operation to use when stencil passes
  32683. * @param operation defines the stencil operation to use when stencil passes
  32684. */
  32685. setStencilOperationPass(operation: number): void;
  32686. /**
  32687. * Sets a boolean indicating if the dithering state is enabled or disabled
  32688. * @param value defines the dithering state
  32689. */
  32690. setDitheringState(value: boolean): void;
  32691. /**
  32692. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32693. * @param value defines the rasterizer state
  32694. */
  32695. setRasterizerState(value: boolean): void;
  32696. /**
  32697. * Gets the current depth function
  32698. * @returns a number defining the depth function
  32699. */
  32700. getDepthFunction(): Nullable<number>;
  32701. /**
  32702. * Sets the current depth function
  32703. * @param depthFunc defines the function to use
  32704. */
  32705. setDepthFunction(depthFunc: number): void;
  32706. /**
  32707. * Sets the current depth function to GREATER
  32708. */
  32709. setDepthFunctionToGreater(): void;
  32710. /**
  32711. * Sets the current depth function to GEQUAL
  32712. */
  32713. setDepthFunctionToGreaterOrEqual(): void;
  32714. /**
  32715. * Sets the current depth function to LESS
  32716. */
  32717. setDepthFunctionToLess(): void;
  32718. /**
  32719. * Sets the current depth function to LEQUAL
  32720. */
  32721. setDepthFunctionToLessOrEqual(): void;
  32722. private _cachedStencilBuffer;
  32723. private _cachedStencilFunction;
  32724. private _cachedStencilMask;
  32725. private _cachedStencilOperationPass;
  32726. private _cachedStencilOperationFail;
  32727. private _cachedStencilOperationDepthFail;
  32728. private _cachedStencilReference;
  32729. /**
  32730. * Caches the the state of the stencil buffer
  32731. */
  32732. cacheStencilState(): void;
  32733. /**
  32734. * Restores the state of the stencil buffer
  32735. */
  32736. restoreStencilState(): void;
  32737. /**
  32738. * Directly set the WebGL Viewport
  32739. * @param x defines the x coordinate of the viewport (in screen space)
  32740. * @param y defines the y coordinate of the viewport (in screen space)
  32741. * @param width defines the width of the viewport (in screen space)
  32742. * @param height defines the height of the viewport (in screen space)
  32743. * @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
  32744. */
  32745. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32746. /**
  32747. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32748. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32749. * @param y defines the y-coordinate of the corner of the clear rectangle
  32750. * @param width defines the width of the clear rectangle
  32751. * @param height defines the height of the clear rectangle
  32752. * @param clearColor defines the clear color
  32753. */
  32754. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32755. /**
  32756. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32757. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32758. * @param y defines the y-coordinate of the corner of the clear rectangle
  32759. * @param width defines the width of the clear rectangle
  32760. * @param height defines the height of the clear rectangle
  32761. */
  32762. enableScissor(x: number, y: number, width: number, height: number): void;
  32763. /**
  32764. * Disable previously set scissor test rectangle
  32765. */
  32766. disableScissor(): void;
  32767. protected _reportDrawCall(): void;
  32768. /**
  32769. * Initializes a webVR display and starts listening to display change events
  32770. * The onVRDisplayChangedObservable will be notified upon these changes
  32771. * @returns The onVRDisplayChangedObservable
  32772. */
  32773. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32774. /** @hidden */
  32775. _prepareVRComponent(): void;
  32776. /** @hidden */
  32777. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32778. /** @hidden */
  32779. _submitVRFrame(): void;
  32780. /**
  32781. * Call this function to leave webVR mode
  32782. * Will do nothing if webVR is not supported or if there is no webVR device
  32783. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32784. */
  32785. disableVR(): void;
  32786. /**
  32787. * Gets a boolean indicating that the system is in VR mode and is presenting
  32788. * @returns true if VR mode is engaged
  32789. */
  32790. isVRPresenting(): boolean;
  32791. /** @hidden */
  32792. _requestVRFrame(): void;
  32793. /** @hidden */
  32794. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32795. /**
  32796. * Gets the source code of the vertex shader associated with a specific webGL program
  32797. * @param program defines the program to use
  32798. * @returns a string containing the source code of the vertex shader associated with the program
  32799. */
  32800. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32801. /**
  32802. * Gets the source code of the fragment shader associated with a specific webGL program
  32803. * @param program defines the program to use
  32804. * @returns a string containing the source code of the fragment shader associated with the program
  32805. */
  32806. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32807. /**
  32808. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32809. * @param x defines the x coordinate of the rectangle where pixels must be read
  32810. * @param y defines the y coordinate of the rectangle where pixels must be read
  32811. * @param width defines the width of the rectangle where pixels must be read
  32812. * @param height defines the height of the rectangle where pixels must be read
  32813. * @returns a Uint8Array containing RGBA colors
  32814. */
  32815. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32816. /**
  32817. * Sets a depth stencil texture from a render target to the according uniform.
  32818. * @param channel The texture channel
  32819. * @param uniform The uniform to set
  32820. * @param texture The render target texture containing the depth stencil texture to apply
  32821. */
  32822. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32823. /**
  32824. * Sets a texture to the webGL context from a postprocess
  32825. * @param channel defines the channel to use
  32826. * @param postProcess defines the source postprocess
  32827. */
  32828. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32829. /**
  32830. * Binds the output of the passed in post process to the texture channel specified
  32831. * @param channel The channel the texture should be bound to
  32832. * @param postProcess The post process which's output should be bound
  32833. */
  32834. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32835. /** @hidden */
  32836. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32837. protected _rebuildBuffers(): void;
  32838. /** @hidden */
  32839. _renderFrame(): void;
  32840. _renderLoop(): void;
  32841. /** @hidden */
  32842. _renderViews(): boolean;
  32843. /**
  32844. * Toggle full screen mode
  32845. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32846. */
  32847. switchFullscreen(requestPointerLock: boolean): void;
  32848. /**
  32849. * Enters full screen mode
  32850. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32851. */
  32852. enterFullscreen(requestPointerLock: boolean): void;
  32853. /**
  32854. * Exits full screen mode
  32855. */
  32856. exitFullscreen(): void;
  32857. /**
  32858. * Enters Pointerlock mode
  32859. */
  32860. enterPointerlock(): void;
  32861. /**
  32862. * Exits Pointerlock mode
  32863. */
  32864. exitPointerlock(): void;
  32865. /**
  32866. * Begin a new frame
  32867. */
  32868. beginFrame(): void;
  32869. /**
  32870. * Enf the current frame
  32871. */
  32872. endFrame(): void;
  32873. resize(): void;
  32874. /**
  32875. * Set the compressed texture format to use, based on the formats you have, and the formats
  32876. * supported by the hardware / browser.
  32877. *
  32878. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32879. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32880. * to API arguments needed to compressed textures. This puts the burden on the container
  32881. * generator to house the arcane code for determining these for current & future formats.
  32882. *
  32883. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32884. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32885. *
  32886. * Note: The result of this call is not taken into account when a texture is base64.
  32887. *
  32888. * @param formatsAvailable defines the list of those format families you have created
  32889. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32890. *
  32891. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32892. * @returns The extension selected.
  32893. */
  32894. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32895. /**
  32896. * Force a specific size of the canvas
  32897. * @param width defines the new canvas' width
  32898. * @param height defines the new canvas' height
  32899. */
  32900. setSize(width: number, height: number): void;
  32901. /**
  32902. * Updates a dynamic vertex buffer.
  32903. * @param vertexBuffer the vertex buffer to update
  32904. * @param data the data used to update the vertex buffer
  32905. * @param byteOffset the byte offset of the data
  32906. * @param byteLength the byte length of the data
  32907. */
  32908. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32909. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32910. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32911. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32912. _releaseTexture(texture: InternalTexture): void;
  32913. /**
  32914. * @hidden
  32915. * Rescales a texture
  32916. * @param source input texutre
  32917. * @param destination destination texture
  32918. * @param scene scene to use to render the resize
  32919. * @param internalFormat format to use when resizing
  32920. * @param onComplete callback to be called when resize has completed
  32921. */
  32922. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32923. /**
  32924. * Gets the current framerate
  32925. * @returns a number representing the framerate
  32926. */
  32927. getFps(): number;
  32928. /**
  32929. * Gets the time spent between current and previous frame
  32930. * @returns a number representing the delta time in ms
  32931. */
  32932. getDeltaTime(): number;
  32933. private _measureFps;
  32934. /** @hidden */
  32935. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32936. /**
  32937. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32938. * @param renderTarget The render target to set the frame buffer for
  32939. */
  32940. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32941. /**
  32942. * Update a dynamic index buffer
  32943. * @param indexBuffer defines the target index buffer
  32944. * @param indices defines the data to update
  32945. * @param offset defines the offset in the target index buffer where update should start
  32946. */
  32947. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32948. /**
  32949. * Updates the sample count of a render target texture
  32950. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32951. * @param texture defines the texture to update
  32952. * @param samples defines the sample count to set
  32953. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32954. */
  32955. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32956. /**
  32957. * Updates a depth texture Comparison Mode and Function.
  32958. * If the comparison Function is equal to 0, the mode will be set to none.
  32959. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32960. * @param texture The texture to set the comparison function for
  32961. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32962. */
  32963. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32964. /**
  32965. * Creates a webGL buffer to use with instanciation
  32966. * @param capacity defines the size of the buffer
  32967. * @returns the webGL buffer
  32968. */
  32969. createInstancesBuffer(capacity: number): DataBuffer;
  32970. /**
  32971. * Delete a webGL buffer used with instanciation
  32972. * @param buffer defines the webGL buffer to delete
  32973. */
  32974. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32975. /** @hidden */
  32976. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32977. dispose(): void;
  32978. private _disableTouchAction;
  32979. /**
  32980. * Display the loading screen
  32981. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32982. */
  32983. displayLoadingUI(): void;
  32984. /**
  32985. * Hide the loading screen
  32986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32987. */
  32988. hideLoadingUI(): void;
  32989. /**
  32990. * Gets the current loading screen object
  32991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32992. */
  32993. /**
  32994. * Sets the current loading screen object
  32995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32996. */
  32997. loadingScreen: ILoadingScreen;
  32998. /**
  32999. * Sets the current loading screen text
  33000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33001. */
  33002. loadingUIText: string;
  33003. /**
  33004. * Sets the current loading screen background color
  33005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33006. */
  33007. loadingUIBackgroundColor: string;
  33008. /** Pointerlock and fullscreen */
  33009. /**
  33010. * Ask the browser to promote the current element to pointerlock mode
  33011. * @param element defines the DOM element to promote
  33012. */
  33013. static _RequestPointerlock(element: HTMLElement): void;
  33014. /**
  33015. * Asks the browser to exit pointerlock mode
  33016. */
  33017. static _ExitPointerlock(): void;
  33018. /**
  33019. * Ask the browser to promote the current element to fullscreen rendering mode
  33020. * @param element defines the DOM element to promote
  33021. */
  33022. static _RequestFullscreen(element: HTMLElement): void;
  33023. /**
  33024. * Asks the browser to exit fullscreen mode
  33025. */
  33026. static _ExitFullscreen(): void;
  33027. }
  33028. }
  33029. declare module "babylonjs/Engines/engineStore" {
  33030. import { Nullable } from "babylonjs/types";
  33031. import { Engine } from "babylonjs/Engines/engine";
  33032. import { Scene } from "babylonjs/scene";
  33033. /**
  33034. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33035. * during the life time of the application.
  33036. */
  33037. export class EngineStore {
  33038. /** Gets the list of created engines */
  33039. static Instances: import("babylonjs/Engines/engine").Engine[];
  33040. /** @hidden */
  33041. static _LastCreatedScene: Nullable<Scene>;
  33042. /**
  33043. * Gets the latest created engine
  33044. */
  33045. static readonly LastCreatedEngine: Nullable<Engine>;
  33046. /**
  33047. * Gets the latest created scene
  33048. */
  33049. static readonly LastCreatedScene: Nullable<Scene>;
  33050. /**
  33051. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33052. * @ignorenaming
  33053. */
  33054. static UseFallbackTexture: boolean;
  33055. /**
  33056. * Texture content used if a texture cannot loaded
  33057. * @ignorenaming
  33058. */
  33059. static FallbackTexture: string;
  33060. }
  33061. }
  33062. declare module "babylonjs/Misc/promise" {
  33063. /**
  33064. * Helper class that provides a small promise polyfill
  33065. */
  33066. export class PromisePolyfill {
  33067. /**
  33068. * Static function used to check if the polyfill is required
  33069. * If this is the case then the function will inject the polyfill to window.Promise
  33070. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33071. */
  33072. static Apply(force?: boolean): void;
  33073. }
  33074. }
  33075. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33076. /**
  33077. * Interface for screenshot methods with describe argument called `size` as object with options
  33078. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33079. */
  33080. export interface IScreenshotSize {
  33081. /**
  33082. * number in pixels for canvas height
  33083. */
  33084. height?: number;
  33085. /**
  33086. * multiplier allowing render at a higher or lower resolution
  33087. * If value is defined then height and width will be ignored and taken from camera
  33088. */
  33089. precision?: number;
  33090. /**
  33091. * number in pixels for canvas width
  33092. */
  33093. width?: number;
  33094. }
  33095. }
  33096. declare module "babylonjs/Misc/tools" {
  33097. import { Nullable, float } from "babylonjs/types";
  33098. import { DomManagement } from "babylonjs/Misc/domManagement";
  33099. import { WebRequest } from "babylonjs/Misc/webRequest";
  33100. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33101. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33102. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33103. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33104. import { Camera } from "babylonjs/Cameras/camera";
  33105. import { Engine } from "babylonjs/Engines/engine";
  33106. interface IColor4Like {
  33107. r: float;
  33108. g: float;
  33109. b: float;
  33110. a: float;
  33111. }
  33112. /**
  33113. * Class containing a set of static utilities functions
  33114. */
  33115. export class Tools {
  33116. /**
  33117. * Gets or sets the base URL to use to load assets
  33118. */
  33119. static BaseUrl: string;
  33120. /**
  33121. * Enable/Disable Custom HTTP Request Headers globally.
  33122. * default = false
  33123. * @see CustomRequestHeaders
  33124. */
  33125. static UseCustomRequestHeaders: boolean;
  33126. /**
  33127. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33128. * i.e. when loading files, where the server/service expects an Authorization header
  33129. */
  33130. static CustomRequestHeaders: {
  33131. [key: string]: string;
  33132. };
  33133. /**
  33134. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33135. */
  33136. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33137. /**
  33138. * Default behaviour for cors in the application.
  33139. * It can be a string if the expected behavior is identical in the entire app.
  33140. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33141. */
  33142. static CorsBehavior: string | ((url: string | string[]) => string);
  33143. /**
  33144. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33145. * @ignorenaming
  33146. */
  33147. static UseFallbackTexture: boolean;
  33148. /**
  33149. * Use this object to register external classes like custom textures or material
  33150. * to allow the laoders to instantiate them
  33151. */
  33152. static RegisteredExternalClasses: {
  33153. [key: string]: Object;
  33154. };
  33155. /**
  33156. * Texture content used if a texture cannot loaded
  33157. * @ignorenaming
  33158. */
  33159. static fallbackTexture: string;
  33160. /**
  33161. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33162. * @param u defines the coordinate on X axis
  33163. * @param v defines the coordinate on Y axis
  33164. * @param width defines the width of the source data
  33165. * @param height defines the height of the source data
  33166. * @param pixels defines the source byte array
  33167. * @param color defines the output color
  33168. */
  33169. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33170. /**
  33171. * Interpolates between a and b via alpha
  33172. * @param a The lower value (returned when alpha = 0)
  33173. * @param b The upper value (returned when alpha = 1)
  33174. * @param alpha The interpolation-factor
  33175. * @return The mixed value
  33176. */
  33177. static Mix(a: number, b: number, alpha: number): number;
  33178. /**
  33179. * Tries to instantiate a new object from a given class name
  33180. * @param className defines the class name to instantiate
  33181. * @returns the new object or null if the system was not able to do the instantiation
  33182. */
  33183. static Instantiate(className: string): any;
  33184. /**
  33185. * Provides a slice function that will work even on IE
  33186. * @param data defines the array to slice
  33187. * @param start defines the start of the data (optional)
  33188. * @param end defines the end of the data (optional)
  33189. * @returns the new sliced array
  33190. */
  33191. static Slice<T>(data: T, start?: number, end?: number): T;
  33192. /**
  33193. * Polyfill for setImmediate
  33194. * @param action defines the action to execute after the current execution block
  33195. */
  33196. static SetImmediate(action: () => void): void;
  33197. /**
  33198. * Function indicating if a number is an exponent of 2
  33199. * @param value defines the value to test
  33200. * @returns true if the value is an exponent of 2
  33201. */
  33202. static IsExponentOfTwo(value: number): boolean;
  33203. private static _tmpFloatArray;
  33204. /**
  33205. * Returns the nearest 32-bit single precision float representation of a Number
  33206. * @param value A Number. If the parameter is of a different type, it will get converted
  33207. * to a number or to NaN if it cannot be converted
  33208. * @returns number
  33209. */
  33210. static FloatRound(value: number): number;
  33211. /**
  33212. * Extracts the filename from a path
  33213. * @param path defines the path to use
  33214. * @returns the filename
  33215. */
  33216. static GetFilename(path: string): string;
  33217. /**
  33218. * Extracts the "folder" part of a path (everything before the filename).
  33219. * @param uri The URI to extract the info from
  33220. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33221. * @returns The "folder" part of the path
  33222. */
  33223. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33224. /**
  33225. * Extracts text content from a DOM element hierarchy
  33226. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33227. */
  33228. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33229. /**
  33230. * Convert an angle in radians to degrees
  33231. * @param angle defines the angle to convert
  33232. * @returns the angle in degrees
  33233. */
  33234. static ToDegrees(angle: number): number;
  33235. /**
  33236. * Convert an angle in degrees to radians
  33237. * @param angle defines the angle to convert
  33238. * @returns the angle in radians
  33239. */
  33240. static ToRadians(angle: number): number;
  33241. /**
  33242. * Returns an array if obj is not an array
  33243. * @param obj defines the object to evaluate as an array
  33244. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33245. * @returns either obj directly if obj is an array or a new array containing obj
  33246. */
  33247. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33248. /**
  33249. * Gets the pointer prefix to use
  33250. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33251. */
  33252. static GetPointerPrefix(): string;
  33253. /**
  33254. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33255. * @param url define the url we are trying
  33256. * @param element define the dom element where to configure the cors policy
  33257. */
  33258. static SetCorsBehavior(url: string | string[], element: {
  33259. crossOrigin: string | null;
  33260. }): void;
  33261. /**
  33262. * Removes unwanted characters from an url
  33263. * @param url defines the url to clean
  33264. * @returns the cleaned url
  33265. */
  33266. static CleanUrl(url: string): string;
  33267. /**
  33268. * Gets or sets a function used to pre-process url before using them to load assets
  33269. */
  33270. static PreprocessUrl: (url: string) => string;
  33271. /**
  33272. * Loads an image as an HTMLImageElement.
  33273. * @param input url string, ArrayBuffer, or Blob to load
  33274. * @param onLoad callback called when the image successfully loads
  33275. * @param onError callback called when the image fails to load
  33276. * @param offlineProvider offline provider for caching
  33277. * @param mimeType optional mime type
  33278. * @returns the HTMLImageElement of the loaded image
  33279. */
  33280. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33281. /**
  33282. * Loads a file from a url
  33283. * @param url url string, ArrayBuffer, or Blob to load
  33284. * @param onSuccess callback called when the file successfully loads
  33285. * @param onProgress callback called while file is loading (if the server supports this mode)
  33286. * @param offlineProvider defines the offline provider for caching
  33287. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33288. * @param onError callback called when the file fails to load
  33289. * @returns a file request object
  33290. */
  33291. 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;
  33292. /**
  33293. * Loads a file from a url
  33294. * @param url the file url to load
  33295. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33296. */
  33297. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33298. /**
  33299. * Load a script (identified by an url). When the url returns, the
  33300. * content of this file is added into a new script element, attached to the DOM (body element)
  33301. * @param scriptUrl defines the url of the script to laod
  33302. * @param onSuccess defines the callback called when the script is loaded
  33303. * @param onError defines the callback to call if an error occurs
  33304. * @param scriptId defines the id of the script element
  33305. */
  33306. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33307. /**
  33308. * Load an asynchronous script (identified by an url). When the url returns, the
  33309. * content of this file is added into a new script element, attached to the DOM (body element)
  33310. * @param scriptUrl defines the url of the script to laod
  33311. * @param scriptId defines the id of the script element
  33312. * @returns a promise request object
  33313. */
  33314. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33315. /**
  33316. * Loads a file from a blob
  33317. * @param fileToLoad defines the blob to use
  33318. * @param callback defines the callback to call when data is loaded
  33319. * @param progressCallback defines the callback to call during loading process
  33320. * @returns a file request object
  33321. */
  33322. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33323. /**
  33324. * Reads a file from a File object
  33325. * @param file defines the file to load
  33326. * @param onSuccess defines the callback to call when data is loaded
  33327. * @param onProgress defines the callback to call during loading process
  33328. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33329. * @param onError defines the callback to call when an error occurs
  33330. * @returns a file request object
  33331. */
  33332. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33333. /**
  33334. * Creates a data url from a given string content
  33335. * @param content defines the content to convert
  33336. * @returns the new data url link
  33337. */
  33338. static FileAsURL(content: string): string;
  33339. /**
  33340. * Format the given number to a specific decimal format
  33341. * @param value defines the number to format
  33342. * @param decimals defines the number of decimals to use
  33343. * @returns the formatted string
  33344. */
  33345. static Format(value: number, decimals?: number): string;
  33346. /**
  33347. * Tries to copy an object by duplicating every property
  33348. * @param source defines the source object
  33349. * @param destination defines the target object
  33350. * @param doNotCopyList defines a list of properties to avoid
  33351. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33352. */
  33353. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33354. /**
  33355. * Gets a boolean indicating if the given object has no own property
  33356. * @param obj defines the object to test
  33357. * @returns true if object has no own property
  33358. */
  33359. static IsEmpty(obj: any): boolean;
  33360. /**
  33361. * Function used to register events at window level
  33362. * @param windowElement defines the Window object to use
  33363. * @param events defines the events to register
  33364. */
  33365. static RegisterTopRootEvents(windowElement: Window, events: {
  33366. name: string;
  33367. handler: Nullable<(e: FocusEvent) => any>;
  33368. }[]): void;
  33369. /**
  33370. * Function used to unregister events from window level
  33371. * @param windowElement defines the Window object to use
  33372. * @param events defines the events to unregister
  33373. */
  33374. static UnregisterTopRootEvents(windowElement: Window, events: {
  33375. name: string;
  33376. handler: Nullable<(e: FocusEvent) => any>;
  33377. }[]): void;
  33378. /**
  33379. * @ignore
  33380. */
  33381. static _ScreenshotCanvas: HTMLCanvasElement;
  33382. /**
  33383. * Dumps the current bound framebuffer
  33384. * @param width defines the rendering width
  33385. * @param height defines the rendering height
  33386. * @param engine defines the hosting engine
  33387. * @param successCallback defines the callback triggered once the data are available
  33388. * @param mimeType defines the mime type of the result
  33389. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33390. */
  33391. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33392. /**
  33393. * Converts the canvas data to blob.
  33394. * This acts as a polyfill for browsers not supporting the to blob function.
  33395. * @param canvas Defines the canvas to extract the data from
  33396. * @param successCallback Defines the callback triggered once the data are available
  33397. * @param mimeType Defines the mime type of the result
  33398. */
  33399. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33400. /**
  33401. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33402. * @param successCallback defines the callback triggered once the data are available
  33403. * @param mimeType defines the mime type of the result
  33404. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33405. */
  33406. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33407. /**
  33408. * Downloads a blob in the browser
  33409. * @param blob defines the blob to download
  33410. * @param fileName defines the name of the downloaded file
  33411. */
  33412. static Download(blob: Blob, fileName: string): void;
  33413. /**
  33414. * Captures a screenshot of the current rendering
  33415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33416. * @param engine defines the rendering engine
  33417. * @param camera defines the source camera
  33418. * @param size This parameter can be set to a single number or to an object with the
  33419. * following (optional) properties: precision, width, height. If a single number is passed,
  33420. * it will be used for both width and height. If an object is passed, the screenshot size
  33421. * will be derived from the parameters. The precision property is a multiplier allowing
  33422. * rendering at a higher or lower resolution
  33423. * @param successCallback defines the callback receives a single parameter which contains the
  33424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33425. * src parameter of an <img> to display it
  33426. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33427. * Check your browser for supported MIME types
  33428. */
  33429. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33430. /**
  33431. * Captures a screenshot of the current rendering
  33432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33433. * @param engine defines the rendering engine
  33434. * @param camera defines the source camera
  33435. * @param size This parameter can be set to a single number or to an object with the
  33436. * following (optional) properties: precision, width, height. If a single number is passed,
  33437. * it will be used for both width and height. If an object is passed, the screenshot size
  33438. * will be derived from the parameters. The precision property is a multiplier allowing
  33439. * rendering at a higher or lower resolution
  33440. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33441. * Check your browser for supported MIME types
  33442. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33443. * to the src parameter of an <img> to display it
  33444. */
  33445. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33446. /**
  33447. * Generates an image screenshot from the specified camera.
  33448. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33449. * @param engine The engine to use for rendering
  33450. * @param camera The camera to use for rendering
  33451. * @param size This parameter can be set to a single number or to an object with the
  33452. * following (optional) properties: precision, width, height. If a single number is passed,
  33453. * it will be used for both width and height. If an object is passed, the screenshot size
  33454. * will be derived from the parameters. The precision property is a multiplier allowing
  33455. * rendering at a higher or lower resolution
  33456. * @param successCallback The callback receives a single parameter which contains the
  33457. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33458. * src parameter of an <img> to display it
  33459. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33460. * Check your browser for supported MIME types
  33461. * @param samples Texture samples (default: 1)
  33462. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33463. * @param fileName A name for for the downloaded file.
  33464. */
  33465. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33466. /**
  33467. * Generates an image screenshot from the specified camera.
  33468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33469. * @param engine The engine to use for rendering
  33470. * @param camera The camera to use for rendering
  33471. * @param size This parameter can be set to a single number or to an object with the
  33472. * following (optional) properties: precision, width, height. If a single number is passed,
  33473. * it will be used for both width and height. If an object is passed, the screenshot size
  33474. * will be derived from the parameters. The precision property is a multiplier allowing
  33475. * rendering at a higher or lower resolution
  33476. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33477. * Check your browser for supported MIME types
  33478. * @param samples Texture samples (default: 1)
  33479. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33480. * @param fileName A name for for the downloaded file.
  33481. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33482. * to the src parameter of an <img> to display it
  33483. */
  33484. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33485. /**
  33486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33487. * Be aware Math.random() could cause collisions, but:
  33488. * "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"
  33489. * @returns a pseudo random id
  33490. */
  33491. static RandomId(): string;
  33492. /**
  33493. * Test if the given uri is a base64 string
  33494. * @param uri The uri to test
  33495. * @return True if the uri is a base64 string or false otherwise
  33496. */
  33497. static IsBase64(uri: string): boolean;
  33498. /**
  33499. * Decode the given base64 uri.
  33500. * @param uri The uri to decode
  33501. * @return The decoded base64 data.
  33502. */
  33503. static DecodeBase64(uri: string): ArrayBuffer;
  33504. /**
  33505. * Gets the absolute url.
  33506. * @param url the input url
  33507. * @return the absolute url
  33508. */
  33509. static GetAbsoluteUrl(url: string): string;
  33510. /**
  33511. * No log
  33512. */
  33513. static readonly NoneLogLevel: number;
  33514. /**
  33515. * Only message logs
  33516. */
  33517. static readonly MessageLogLevel: number;
  33518. /**
  33519. * Only warning logs
  33520. */
  33521. static readonly WarningLogLevel: number;
  33522. /**
  33523. * Only error logs
  33524. */
  33525. static readonly ErrorLogLevel: number;
  33526. /**
  33527. * All logs
  33528. */
  33529. static readonly AllLogLevel: number;
  33530. /**
  33531. * Gets a value indicating the number of loading errors
  33532. * @ignorenaming
  33533. */
  33534. static readonly errorsCount: number;
  33535. /**
  33536. * Callback called when a new log is added
  33537. */
  33538. static OnNewCacheEntry: (entry: string) => void;
  33539. /**
  33540. * Log a message to the console
  33541. * @param message defines the message to log
  33542. */
  33543. static Log(message: string): void;
  33544. /**
  33545. * Write a warning message to the console
  33546. * @param message defines the message to log
  33547. */
  33548. static Warn(message: string): void;
  33549. /**
  33550. * Write an error message to the console
  33551. * @param message defines the message to log
  33552. */
  33553. static Error(message: string): void;
  33554. /**
  33555. * Gets current log cache (list of logs)
  33556. */
  33557. static readonly LogCache: string;
  33558. /**
  33559. * Clears the log cache
  33560. */
  33561. static ClearLogCache(): void;
  33562. /**
  33563. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33564. */
  33565. static LogLevels: number;
  33566. /**
  33567. * Checks if the window object exists
  33568. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33569. */
  33570. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33571. /**
  33572. * No performance log
  33573. */
  33574. static readonly PerformanceNoneLogLevel: number;
  33575. /**
  33576. * Use user marks to log performance
  33577. */
  33578. static readonly PerformanceUserMarkLogLevel: number;
  33579. /**
  33580. * Log performance to the console
  33581. */
  33582. static readonly PerformanceConsoleLogLevel: number;
  33583. private static _performance;
  33584. /**
  33585. * Sets the current performance log level
  33586. */
  33587. static PerformanceLogLevel: number;
  33588. private static _StartPerformanceCounterDisabled;
  33589. private static _EndPerformanceCounterDisabled;
  33590. private static _StartUserMark;
  33591. private static _EndUserMark;
  33592. private static _StartPerformanceConsole;
  33593. private static _EndPerformanceConsole;
  33594. /**
  33595. * Starts a performance counter
  33596. */
  33597. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33598. /**
  33599. * Ends a specific performance coutner
  33600. */
  33601. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33602. /**
  33603. * Gets either window.performance.now() if supported or Date.now() else
  33604. */
  33605. static readonly Now: number;
  33606. /**
  33607. * This method will return the name of the class used to create the instance of the given object.
  33608. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33609. * @param object the object to get the class name from
  33610. * @param isType defines if the object is actually a type
  33611. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33612. */
  33613. static GetClassName(object: any, isType?: boolean): string;
  33614. /**
  33615. * Gets the first element of an array satisfying a given predicate
  33616. * @param array defines the array to browse
  33617. * @param predicate defines the predicate to use
  33618. * @returns null if not found or the element
  33619. */
  33620. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33621. /**
  33622. * This method will return the name of the full name of the class, including its owning module (if any).
  33623. * 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).
  33624. * @param object the object to get the class name from
  33625. * @param isType defines if the object is actually a type
  33626. * @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.
  33627. * @ignorenaming
  33628. */
  33629. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33630. /**
  33631. * Returns a promise that resolves after the given amount of time.
  33632. * @param delay Number of milliseconds to delay
  33633. * @returns Promise that resolves after the given amount of time
  33634. */
  33635. static DelayAsync(delay: number): Promise<void>;
  33636. }
  33637. /**
  33638. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33639. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33640. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33641. * @param name The name of the class, case should be preserved
  33642. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33643. */
  33644. export function className(name: string, module?: string): (target: Object) => void;
  33645. /**
  33646. * An implementation of a loop for asynchronous functions.
  33647. */
  33648. export class AsyncLoop {
  33649. /**
  33650. * Defines the number of iterations for the loop
  33651. */
  33652. iterations: number;
  33653. /**
  33654. * Defines the current index of the loop.
  33655. */
  33656. index: number;
  33657. private _done;
  33658. private _fn;
  33659. private _successCallback;
  33660. /**
  33661. * Constructor.
  33662. * @param iterations the number of iterations.
  33663. * @param func the function to run each iteration
  33664. * @param successCallback the callback that will be called upon succesful execution
  33665. * @param offset starting offset.
  33666. */
  33667. constructor(
  33668. /**
  33669. * Defines the number of iterations for the loop
  33670. */
  33671. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33672. /**
  33673. * Execute the next iteration. Must be called after the last iteration was finished.
  33674. */
  33675. executeNext(): void;
  33676. /**
  33677. * Break the loop and run the success callback.
  33678. */
  33679. breakLoop(): void;
  33680. /**
  33681. * Create and run an async loop.
  33682. * @param iterations the number of iterations.
  33683. * @param fn the function to run each iteration
  33684. * @param successCallback the callback that will be called upon succesful execution
  33685. * @param offset starting offset.
  33686. * @returns the created async loop object
  33687. */
  33688. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33689. /**
  33690. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33691. * @param iterations total number of iterations
  33692. * @param syncedIterations number of synchronous iterations in each async iteration.
  33693. * @param fn the function to call each iteration.
  33694. * @param callback a success call back that will be called when iterating stops.
  33695. * @param breakFunction a break condition (optional)
  33696. * @param timeout timeout settings for the setTimeout function. default - 0.
  33697. * @returns the created async loop object
  33698. */
  33699. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33700. }
  33701. }
  33702. declare module "babylonjs/Misc/stringDictionary" {
  33703. import { Nullable } from "babylonjs/types";
  33704. /**
  33705. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33706. * The underlying implementation relies on an associative array to ensure the best performances.
  33707. * The value can be anything including 'null' but except 'undefined'
  33708. */
  33709. export class StringDictionary<T> {
  33710. /**
  33711. * This will clear this dictionary and copy the content from the 'source' one.
  33712. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33713. * @param source the dictionary to take the content from and copy to this dictionary
  33714. */
  33715. copyFrom(source: StringDictionary<T>): void;
  33716. /**
  33717. * Get a value based from its key
  33718. * @param key the given key to get the matching value from
  33719. * @return the value if found, otherwise undefined is returned
  33720. */
  33721. get(key: string): T | undefined;
  33722. /**
  33723. * Get a value from its key or add it if it doesn't exist.
  33724. * This method will ensure you that a given key/data will be present in the dictionary.
  33725. * @param key the given key to get the matching value from
  33726. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33727. * The factory will only be invoked if there's no data for the given key.
  33728. * @return the value corresponding to the key.
  33729. */
  33730. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33731. /**
  33732. * Get a value from its key if present in the dictionary otherwise add it
  33733. * @param key the key to get the value from
  33734. * @param val if there's no such key/value pair in the dictionary add it with this value
  33735. * @return the value corresponding to the key
  33736. */
  33737. getOrAdd(key: string, val: T): T;
  33738. /**
  33739. * Check if there's a given key in the dictionary
  33740. * @param key the key to check for
  33741. * @return true if the key is present, false otherwise
  33742. */
  33743. contains(key: string): boolean;
  33744. /**
  33745. * Add a new key and its corresponding value
  33746. * @param key the key to add
  33747. * @param value the value corresponding to the key
  33748. * @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
  33749. */
  33750. add(key: string, value: T): boolean;
  33751. /**
  33752. * Update a specific value associated to a key
  33753. * @param key defines the key to use
  33754. * @param value defines the value to store
  33755. * @returns true if the value was updated (or false if the key was not found)
  33756. */
  33757. set(key: string, value: T): boolean;
  33758. /**
  33759. * Get the element of the given key and remove it from the dictionary
  33760. * @param key defines the key to search
  33761. * @returns the value associated with the key or null if not found
  33762. */
  33763. getAndRemove(key: string): Nullable<T>;
  33764. /**
  33765. * Remove a key/value from the dictionary.
  33766. * @param key the key to remove
  33767. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33768. */
  33769. remove(key: string): boolean;
  33770. /**
  33771. * Clear the whole content of the dictionary
  33772. */
  33773. clear(): void;
  33774. /**
  33775. * Gets the current count
  33776. */
  33777. readonly count: number;
  33778. /**
  33779. * Execute a callback on each key/val of the dictionary.
  33780. * Note that you can remove any element in this dictionary in the callback implementation
  33781. * @param callback the callback to execute on a given key/value pair
  33782. */
  33783. forEach(callback: (key: string, val: T) => void): void;
  33784. /**
  33785. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33786. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33787. * Note that you can remove any element in this dictionary in the callback implementation
  33788. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33789. * @returns the first item
  33790. */
  33791. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33792. private _count;
  33793. private _data;
  33794. }
  33795. }
  33796. declare module "babylonjs/Collisions/collisionCoordinator" {
  33797. import { Nullable } from "babylonjs/types";
  33798. import { Scene } from "babylonjs/scene";
  33799. import { Vector3 } from "babylonjs/Maths/math.vector";
  33800. import { Collider } from "babylonjs/Collisions/collider";
  33801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33802. /** @hidden */
  33803. export interface ICollisionCoordinator {
  33804. createCollider(): Collider;
  33805. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33806. init(scene: Scene): void;
  33807. }
  33808. /** @hidden */
  33809. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33810. private _scene;
  33811. private _scaledPosition;
  33812. private _scaledVelocity;
  33813. private _finalPosition;
  33814. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33815. createCollider(): Collider;
  33816. init(scene: Scene): void;
  33817. private _collideWithWorld;
  33818. }
  33819. }
  33820. declare module "babylonjs/Inputs/scene.inputManager" {
  33821. import { Nullable } from "babylonjs/types";
  33822. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33823. import { Vector2 } from "babylonjs/Maths/math.vector";
  33824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33825. import { Scene } from "babylonjs/scene";
  33826. /**
  33827. * Class used to manage all inputs for the scene.
  33828. */
  33829. export class InputManager {
  33830. /** The distance in pixel that you have to move to prevent some events */
  33831. static DragMovementThreshold: number;
  33832. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33833. static LongPressDelay: number;
  33834. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33835. static DoubleClickDelay: number;
  33836. /** If you need to check double click without raising a single click at first click, enable this flag */
  33837. static ExclusiveDoubleClickMode: boolean;
  33838. private _wheelEventName;
  33839. private _onPointerMove;
  33840. private _onPointerDown;
  33841. private _onPointerUp;
  33842. private _initClickEvent;
  33843. private _initActionManager;
  33844. private _delayedSimpleClick;
  33845. private _delayedSimpleClickTimeout;
  33846. private _previousDelayedSimpleClickTimeout;
  33847. private _meshPickProceed;
  33848. private _previousButtonPressed;
  33849. private _currentPickResult;
  33850. private _previousPickResult;
  33851. private _totalPointersPressed;
  33852. private _doubleClickOccured;
  33853. private _pointerOverMesh;
  33854. private _pickedDownMesh;
  33855. private _pickedUpMesh;
  33856. private _pointerX;
  33857. private _pointerY;
  33858. private _unTranslatedPointerX;
  33859. private _unTranslatedPointerY;
  33860. private _startingPointerPosition;
  33861. private _previousStartingPointerPosition;
  33862. private _startingPointerTime;
  33863. private _previousStartingPointerTime;
  33864. private _pointerCaptures;
  33865. private _onKeyDown;
  33866. private _onKeyUp;
  33867. private _onCanvasFocusObserver;
  33868. private _onCanvasBlurObserver;
  33869. private _scene;
  33870. /**
  33871. * Creates a new InputManager
  33872. * @param scene defines the hosting scene
  33873. */
  33874. constructor(scene: Scene);
  33875. /**
  33876. * Gets the mesh that is currently under the pointer
  33877. */
  33878. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33879. /**
  33880. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33881. */
  33882. readonly unTranslatedPointer: Vector2;
  33883. /**
  33884. * Gets or sets the current on-screen X position of the pointer
  33885. */
  33886. pointerX: number;
  33887. /**
  33888. * Gets or sets the current on-screen Y position of the pointer
  33889. */
  33890. pointerY: number;
  33891. private _updatePointerPosition;
  33892. private _processPointerMove;
  33893. private _setRayOnPointerInfo;
  33894. private _checkPrePointerObservable;
  33895. /**
  33896. * Use this method to simulate a pointer move on a mesh
  33897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33900. */
  33901. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33902. /**
  33903. * Use this method to simulate a pointer down on a mesh
  33904. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33905. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33906. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33907. */
  33908. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33909. private _processPointerDown;
  33910. /** @hidden */
  33911. _isPointerSwiping(): boolean;
  33912. /**
  33913. * Use this method to simulate a pointer up on a mesh
  33914. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33915. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33916. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33917. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33918. */
  33919. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33920. private _processPointerUp;
  33921. /**
  33922. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33923. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33924. * @returns true if the pointer was captured
  33925. */
  33926. isPointerCaptured(pointerId?: number): boolean;
  33927. /**
  33928. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33929. * @param attachUp defines if you want to attach events to pointerup
  33930. * @param attachDown defines if you want to attach events to pointerdown
  33931. * @param attachMove defines if you want to attach events to pointermove
  33932. */
  33933. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33934. /**
  33935. * Detaches all event handlers
  33936. */
  33937. detachControl(): void;
  33938. /**
  33939. * Force the value of meshUnderPointer
  33940. * @param mesh defines the mesh to use
  33941. */
  33942. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33943. /**
  33944. * Gets the mesh under the pointer
  33945. * @returns a Mesh or null if no mesh is under the pointer
  33946. */
  33947. getPointerOverMesh(): Nullable<AbstractMesh>;
  33948. }
  33949. }
  33950. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33951. /**
  33952. * Helper class used to generate session unique ID
  33953. */
  33954. export class UniqueIdGenerator {
  33955. private static _UniqueIdCounter;
  33956. /**
  33957. * Gets an unique (relatively to the current scene) Id
  33958. */
  33959. static readonly UniqueId: number;
  33960. }
  33961. }
  33962. declare module "babylonjs/Animations/animationGroup" {
  33963. import { Animatable } from "babylonjs/Animations/animatable";
  33964. import { Animation } from "babylonjs/Animations/animation";
  33965. import { Scene, IDisposable } from "babylonjs/scene";
  33966. import { Observable } from "babylonjs/Misc/observable";
  33967. import { Nullable } from "babylonjs/types";
  33968. import "babylonjs/Animations/animatable";
  33969. /**
  33970. * This class defines the direct association between an animation and a target
  33971. */
  33972. export class TargetedAnimation {
  33973. /**
  33974. * Animation to perform
  33975. */
  33976. animation: Animation;
  33977. /**
  33978. * Target to animate
  33979. */
  33980. target: any;
  33981. /**
  33982. * Serialize the object
  33983. * @returns the JSON object representing the current entity
  33984. */
  33985. serialize(): any;
  33986. }
  33987. /**
  33988. * Use this class to create coordinated animations on multiple targets
  33989. */
  33990. export class AnimationGroup implements IDisposable {
  33991. /** The name of the animation group */
  33992. name: string;
  33993. private _scene;
  33994. private _targetedAnimations;
  33995. private _animatables;
  33996. private _from;
  33997. private _to;
  33998. private _isStarted;
  33999. private _isPaused;
  34000. private _speedRatio;
  34001. private _loopAnimation;
  34002. /**
  34003. * Gets or sets the unique id of the node
  34004. */
  34005. uniqueId: number;
  34006. /**
  34007. * This observable will notify when one animation have ended
  34008. */
  34009. onAnimationEndObservable: Observable<TargetedAnimation>;
  34010. /**
  34011. * Observer raised when one animation loops
  34012. */
  34013. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34014. /**
  34015. * Observer raised when all animations have looped
  34016. */
  34017. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34018. /**
  34019. * This observable will notify when all animations have ended.
  34020. */
  34021. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34022. /**
  34023. * This observable will notify when all animations have paused.
  34024. */
  34025. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34026. /**
  34027. * This observable will notify when all animations are playing.
  34028. */
  34029. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34030. /**
  34031. * Gets the first frame
  34032. */
  34033. readonly from: number;
  34034. /**
  34035. * Gets the last frame
  34036. */
  34037. readonly to: number;
  34038. /**
  34039. * Define if the animations are started
  34040. */
  34041. readonly isStarted: boolean;
  34042. /**
  34043. * Gets a value indicating that the current group is playing
  34044. */
  34045. readonly isPlaying: boolean;
  34046. /**
  34047. * Gets or sets the speed ratio to use for all animations
  34048. */
  34049. /**
  34050. * Gets or sets the speed ratio to use for all animations
  34051. */
  34052. speedRatio: number;
  34053. /**
  34054. * Gets or sets if all animations should loop or not
  34055. */
  34056. loopAnimation: boolean;
  34057. /**
  34058. * Gets the targeted animations for this animation group
  34059. */
  34060. readonly targetedAnimations: Array<TargetedAnimation>;
  34061. /**
  34062. * returning the list of animatables controlled by this animation group.
  34063. */
  34064. readonly animatables: Array<Animatable>;
  34065. /**
  34066. * Instantiates a new Animation Group.
  34067. * This helps managing several animations at once.
  34068. * @see http://doc.babylonjs.com/how_to/group
  34069. * @param name Defines the name of the group
  34070. * @param scene Defines the scene the group belongs to
  34071. */
  34072. constructor(
  34073. /** The name of the animation group */
  34074. name: string, scene?: Nullable<Scene>);
  34075. /**
  34076. * Add an animation (with its target) in the group
  34077. * @param animation defines the animation we want to add
  34078. * @param target defines the target of the animation
  34079. * @returns the TargetedAnimation object
  34080. */
  34081. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34082. /**
  34083. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34084. * It can add constant keys at begin or end
  34085. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34086. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34087. * @returns the animation group
  34088. */
  34089. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34090. private _animationLoopCount;
  34091. private _animationLoopFlags;
  34092. private _processLoop;
  34093. /**
  34094. * Start all animations on given targets
  34095. * @param loop defines if animations must loop
  34096. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34097. * @param from defines the from key (optional)
  34098. * @param to defines the to key (optional)
  34099. * @returns the current animation group
  34100. */
  34101. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34102. /**
  34103. * Pause all animations
  34104. * @returns the animation group
  34105. */
  34106. pause(): AnimationGroup;
  34107. /**
  34108. * Play all animations to initial state
  34109. * This function will start() the animations if they were not started or will restart() them if they were paused
  34110. * @param loop defines if animations must loop
  34111. * @returns the animation group
  34112. */
  34113. play(loop?: boolean): AnimationGroup;
  34114. /**
  34115. * Reset all animations to initial state
  34116. * @returns the animation group
  34117. */
  34118. reset(): AnimationGroup;
  34119. /**
  34120. * Restart animations from key 0
  34121. * @returns the animation group
  34122. */
  34123. restart(): AnimationGroup;
  34124. /**
  34125. * Stop all animations
  34126. * @returns the animation group
  34127. */
  34128. stop(): AnimationGroup;
  34129. /**
  34130. * Set animation weight for all animatables
  34131. * @param weight defines the weight to use
  34132. * @return the animationGroup
  34133. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34134. */
  34135. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34136. /**
  34137. * Synchronize and normalize all animatables with a source animatable
  34138. * @param root defines the root animatable to synchronize with
  34139. * @return the animationGroup
  34140. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34141. */
  34142. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34143. /**
  34144. * Goes to a specific frame in this animation group
  34145. * @param frame the frame number to go to
  34146. * @return the animationGroup
  34147. */
  34148. goToFrame(frame: number): AnimationGroup;
  34149. /**
  34150. * Dispose all associated resources
  34151. */
  34152. dispose(): void;
  34153. private _checkAnimationGroupEnded;
  34154. /**
  34155. * Clone the current animation group and returns a copy
  34156. * @param newName defines the name of the new group
  34157. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34158. * @returns the new aniamtion group
  34159. */
  34160. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34161. /**
  34162. * Serializes the animationGroup to an object
  34163. * @returns Serialized object
  34164. */
  34165. serialize(): any;
  34166. /**
  34167. * Returns a new AnimationGroup object parsed from the source provided.
  34168. * @param parsedAnimationGroup defines the source
  34169. * @param scene defines the scene that will receive the animationGroup
  34170. * @returns a new AnimationGroup
  34171. */
  34172. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34173. /**
  34174. * Returns the string "AnimationGroup"
  34175. * @returns "AnimationGroup"
  34176. */
  34177. getClassName(): string;
  34178. /**
  34179. * Creates a detailled string about the object
  34180. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34181. * @returns a string representing the object
  34182. */
  34183. toString(fullDetails?: boolean): string;
  34184. }
  34185. }
  34186. declare module "babylonjs/scene" {
  34187. import { Nullable } from "babylonjs/types";
  34188. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34189. import { Observable } from "babylonjs/Misc/observable";
  34190. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34191. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34192. import { Geometry } from "babylonjs/Meshes/geometry";
  34193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34196. import { Mesh } from "babylonjs/Meshes/mesh";
  34197. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34198. import { Bone } from "babylonjs/Bones/bone";
  34199. import { Skeleton } from "babylonjs/Bones/skeleton";
  34200. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34201. import { Camera } from "babylonjs/Cameras/camera";
  34202. import { AbstractScene } from "babylonjs/abstractScene";
  34203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34205. import { Material } from "babylonjs/Materials/material";
  34206. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34207. import { Effect } from "babylonjs/Materials/effect";
  34208. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34209. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34210. import { Light } from "babylonjs/Lights/light";
  34211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34212. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34213. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34214. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34215. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34216. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34217. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34218. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34219. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34220. import { Engine } from "babylonjs/Engines/engine";
  34221. import { Node } from "babylonjs/node";
  34222. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34223. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34224. import { WebRequest } from "babylonjs/Misc/webRequest";
  34225. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34226. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34227. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34228. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34229. import { Plane } from "babylonjs/Maths/math.plane";
  34230. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34231. import { Ray } from "babylonjs/Culling/ray";
  34232. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34233. import { Animation } from "babylonjs/Animations/animation";
  34234. import { Animatable } from "babylonjs/Animations/animatable";
  34235. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34236. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34237. import { Collider } from "babylonjs/Collisions/collider";
  34238. /**
  34239. * Define an interface for all classes that will hold resources
  34240. */
  34241. export interface IDisposable {
  34242. /**
  34243. * Releases all held resources
  34244. */
  34245. dispose(): void;
  34246. }
  34247. /** Interface defining initialization parameters for Scene class */
  34248. export interface SceneOptions {
  34249. /**
  34250. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34251. * It will improve performance when the number of geometries becomes important.
  34252. */
  34253. useGeometryUniqueIdsMap?: boolean;
  34254. /**
  34255. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34256. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34257. */
  34258. useMaterialMeshMap?: boolean;
  34259. /**
  34260. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34261. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34262. */
  34263. useClonedMeshhMap?: boolean;
  34264. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34265. virtual?: boolean;
  34266. }
  34267. /**
  34268. * Represents a scene to be rendered by the engine.
  34269. * @see http://doc.babylonjs.com/features/scene
  34270. */
  34271. export class Scene extends AbstractScene implements IAnimatable {
  34272. /** The fog is deactivated */
  34273. static readonly FOGMODE_NONE: number;
  34274. /** The fog density is following an exponential function */
  34275. static readonly FOGMODE_EXP: number;
  34276. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34277. static readonly FOGMODE_EXP2: number;
  34278. /** The fog density is following a linear function. */
  34279. static readonly FOGMODE_LINEAR: number;
  34280. /**
  34281. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34282. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34283. */
  34284. static MinDeltaTime: number;
  34285. /**
  34286. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34287. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34288. */
  34289. static MaxDeltaTime: number;
  34290. /**
  34291. * Factory used to create the default material.
  34292. * @param name The name of the material to create
  34293. * @param scene The scene to create the material for
  34294. * @returns The default material
  34295. */
  34296. static DefaultMaterialFactory(scene: Scene): Material;
  34297. /**
  34298. * Factory used to create the a collision coordinator.
  34299. * @returns The collision coordinator
  34300. */
  34301. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34302. /** @hidden */
  34303. _inputManager: InputManager;
  34304. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34305. cameraToUseForPointers: Nullable<Camera>;
  34306. /** @hidden */
  34307. readonly _isScene: boolean;
  34308. /**
  34309. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34310. */
  34311. autoClear: boolean;
  34312. /**
  34313. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34314. */
  34315. autoClearDepthAndStencil: boolean;
  34316. /**
  34317. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34318. */
  34319. clearColor: Color4;
  34320. /**
  34321. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34322. */
  34323. ambientColor: Color3;
  34324. /**
  34325. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34326. * It should only be one of the following (if not the default embedded one):
  34327. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34328. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34329. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34330. * The material properties need to be setup according to the type of texture in use.
  34331. */
  34332. environmentBRDFTexture: BaseTexture;
  34333. /** @hidden */
  34334. protected _environmentTexture: Nullable<BaseTexture>;
  34335. /**
  34336. * Texture used in all pbr material as the reflection texture.
  34337. * As in the majority of the scene they are the same (exception for multi room and so on),
  34338. * this is easier to reference from here than from all the materials.
  34339. */
  34340. /**
  34341. * Texture used in all pbr material as the reflection texture.
  34342. * As in the majority of the scene they are the same (exception for multi room and so on),
  34343. * this is easier to set here than in all the materials.
  34344. */
  34345. environmentTexture: Nullable<BaseTexture>;
  34346. /** @hidden */
  34347. protected _environmentIntensity: number;
  34348. /**
  34349. * Intensity of the environment in all pbr material.
  34350. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34351. * As in the majority of the scene they are the same (exception for multi room and so on),
  34352. * this is easier to reference from here than from all the materials.
  34353. */
  34354. /**
  34355. * Intensity of the environment in all pbr material.
  34356. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34357. * As in the majority of the scene they are the same (exception for multi room and so on),
  34358. * this is easier to set here than in all the materials.
  34359. */
  34360. environmentIntensity: number;
  34361. /** @hidden */
  34362. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34363. /**
  34364. * Default image processing configuration used either in the rendering
  34365. * Forward main pass or through the imageProcessingPostProcess if present.
  34366. * As in the majority of the scene they are the same (exception for multi camera),
  34367. * this is easier to reference from here than from all the materials and post process.
  34368. *
  34369. * No setter as we it is a shared configuration, you can set the values instead.
  34370. */
  34371. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34372. private _forceWireframe;
  34373. /**
  34374. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34375. */
  34376. forceWireframe: boolean;
  34377. private _forcePointsCloud;
  34378. /**
  34379. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34380. */
  34381. forcePointsCloud: boolean;
  34382. /**
  34383. * Gets or sets the active clipplane 1
  34384. */
  34385. clipPlane: Nullable<Plane>;
  34386. /**
  34387. * Gets or sets the active clipplane 2
  34388. */
  34389. clipPlane2: Nullable<Plane>;
  34390. /**
  34391. * Gets or sets the active clipplane 3
  34392. */
  34393. clipPlane3: Nullable<Plane>;
  34394. /**
  34395. * Gets or sets the active clipplane 4
  34396. */
  34397. clipPlane4: Nullable<Plane>;
  34398. /**
  34399. * Gets or sets a boolean indicating if animations are enabled
  34400. */
  34401. animationsEnabled: boolean;
  34402. private _animationPropertiesOverride;
  34403. /**
  34404. * Gets or sets the animation properties override
  34405. */
  34406. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34407. /**
  34408. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34409. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34410. */
  34411. useConstantAnimationDeltaTime: boolean;
  34412. /**
  34413. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34414. * Please note that it requires to run a ray cast through the scene on every frame
  34415. */
  34416. constantlyUpdateMeshUnderPointer: boolean;
  34417. /**
  34418. * Defines the HTML cursor to use when hovering over interactive elements
  34419. */
  34420. hoverCursor: string;
  34421. /**
  34422. * Defines the HTML default cursor to use (empty by default)
  34423. */
  34424. defaultCursor: string;
  34425. /**
  34426. * Defines wether cursors are handled by the scene.
  34427. */
  34428. doNotHandleCursors: boolean;
  34429. /**
  34430. * This is used to call preventDefault() on pointer down
  34431. * in order to block unwanted artifacts like system double clicks
  34432. */
  34433. preventDefaultOnPointerDown: boolean;
  34434. /**
  34435. * This is used to call preventDefault() on pointer up
  34436. * in order to block unwanted artifacts like system double clicks
  34437. */
  34438. preventDefaultOnPointerUp: boolean;
  34439. /**
  34440. * Gets or sets user defined metadata
  34441. */
  34442. metadata: any;
  34443. /**
  34444. * For internal use only. Please do not use.
  34445. */
  34446. reservedDataStore: any;
  34447. /**
  34448. * Gets the name of the plugin used to load this scene (null by default)
  34449. */
  34450. loadingPluginName: string;
  34451. /**
  34452. * Use this array to add regular expressions used to disable offline support for specific urls
  34453. */
  34454. disableOfflineSupportExceptionRules: RegExp[];
  34455. /**
  34456. * An event triggered when the scene is disposed.
  34457. */
  34458. onDisposeObservable: Observable<Scene>;
  34459. private _onDisposeObserver;
  34460. /** Sets a function to be executed when this scene is disposed. */
  34461. onDispose: () => void;
  34462. /**
  34463. * An event triggered before rendering the scene (right after animations and physics)
  34464. */
  34465. onBeforeRenderObservable: Observable<Scene>;
  34466. private _onBeforeRenderObserver;
  34467. /** Sets a function to be executed before rendering this scene */
  34468. beforeRender: Nullable<() => void>;
  34469. /**
  34470. * An event triggered after rendering the scene
  34471. */
  34472. onAfterRenderObservable: Observable<Scene>;
  34473. /**
  34474. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34475. */
  34476. onAfterRenderCameraObservable: Observable<Camera>;
  34477. private _onAfterRenderObserver;
  34478. /** Sets a function to be executed after rendering this scene */
  34479. afterRender: Nullable<() => void>;
  34480. /**
  34481. * An event triggered before animating the scene
  34482. */
  34483. onBeforeAnimationsObservable: Observable<Scene>;
  34484. /**
  34485. * An event triggered after animations processing
  34486. */
  34487. onAfterAnimationsObservable: Observable<Scene>;
  34488. /**
  34489. * An event triggered before draw calls are ready to be sent
  34490. */
  34491. onBeforeDrawPhaseObservable: Observable<Scene>;
  34492. /**
  34493. * An event triggered after draw calls have been sent
  34494. */
  34495. onAfterDrawPhaseObservable: Observable<Scene>;
  34496. /**
  34497. * An event triggered when the scene is ready
  34498. */
  34499. onReadyObservable: Observable<Scene>;
  34500. /**
  34501. * An event triggered before rendering a camera
  34502. */
  34503. onBeforeCameraRenderObservable: Observable<Camera>;
  34504. private _onBeforeCameraRenderObserver;
  34505. /** Sets a function to be executed before rendering a camera*/
  34506. beforeCameraRender: () => void;
  34507. /**
  34508. * An event triggered after rendering a camera
  34509. */
  34510. onAfterCameraRenderObservable: Observable<Camera>;
  34511. private _onAfterCameraRenderObserver;
  34512. /** Sets a function to be executed after rendering a camera*/
  34513. afterCameraRender: () => void;
  34514. /**
  34515. * An event triggered when active meshes evaluation is about to start
  34516. */
  34517. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34518. /**
  34519. * An event triggered when active meshes evaluation is done
  34520. */
  34521. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34522. /**
  34523. * An event triggered when particles rendering is about to start
  34524. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34525. */
  34526. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34527. /**
  34528. * An event triggered when particles rendering is done
  34529. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34530. */
  34531. onAfterParticlesRenderingObservable: Observable<Scene>;
  34532. /**
  34533. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34534. */
  34535. onDataLoadedObservable: Observable<Scene>;
  34536. /**
  34537. * An event triggered when a camera is created
  34538. */
  34539. onNewCameraAddedObservable: Observable<Camera>;
  34540. /**
  34541. * An event triggered when a camera is removed
  34542. */
  34543. onCameraRemovedObservable: Observable<Camera>;
  34544. /**
  34545. * An event triggered when a light is created
  34546. */
  34547. onNewLightAddedObservable: Observable<Light>;
  34548. /**
  34549. * An event triggered when a light is removed
  34550. */
  34551. onLightRemovedObservable: Observable<Light>;
  34552. /**
  34553. * An event triggered when a geometry is created
  34554. */
  34555. onNewGeometryAddedObservable: Observable<Geometry>;
  34556. /**
  34557. * An event triggered when a geometry is removed
  34558. */
  34559. onGeometryRemovedObservable: Observable<Geometry>;
  34560. /**
  34561. * An event triggered when a transform node is created
  34562. */
  34563. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34564. /**
  34565. * An event triggered when a transform node is removed
  34566. */
  34567. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34568. /**
  34569. * An event triggered when a mesh is created
  34570. */
  34571. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34572. /**
  34573. * An event triggered when a mesh is removed
  34574. */
  34575. onMeshRemovedObservable: Observable<AbstractMesh>;
  34576. /**
  34577. * An event triggered when a skeleton is created
  34578. */
  34579. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34580. /**
  34581. * An event triggered when a skeleton is removed
  34582. */
  34583. onSkeletonRemovedObservable: Observable<Skeleton>;
  34584. /**
  34585. * An event triggered when a material is created
  34586. */
  34587. onNewMaterialAddedObservable: Observable<Material>;
  34588. /**
  34589. * An event triggered when a material is removed
  34590. */
  34591. onMaterialRemovedObservable: Observable<Material>;
  34592. /**
  34593. * An event triggered when a texture is created
  34594. */
  34595. onNewTextureAddedObservable: Observable<BaseTexture>;
  34596. /**
  34597. * An event triggered when a texture is removed
  34598. */
  34599. onTextureRemovedObservable: Observable<BaseTexture>;
  34600. /**
  34601. * An event triggered when render targets are about to be rendered
  34602. * Can happen multiple times per frame.
  34603. */
  34604. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34605. /**
  34606. * An event triggered when render targets were rendered.
  34607. * Can happen multiple times per frame.
  34608. */
  34609. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34610. /**
  34611. * An event triggered before calculating deterministic simulation step
  34612. */
  34613. onBeforeStepObservable: Observable<Scene>;
  34614. /**
  34615. * An event triggered after calculating deterministic simulation step
  34616. */
  34617. onAfterStepObservable: Observable<Scene>;
  34618. /**
  34619. * An event triggered when the activeCamera property is updated
  34620. */
  34621. onActiveCameraChanged: Observable<Scene>;
  34622. /**
  34623. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34624. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34625. * 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)
  34626. */
  34627. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34628. /**
  34629. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34630. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34631. * 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)
  34632. */
  34633. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34634. /**
  34635. * This Observable will when a mesh has been imported into the scene.
  34636. */
  34637. onMeshImportedObservable: Observable<AbstractMesh>;
  34638. /**
  34639. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34640. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34641. */
  34642. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34643. /** @hidden */
  34644. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34645. /**
  34646. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34647. */
  34648. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34649. /**
  34650. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34651. */
  34652. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34653. /**
  34654. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34655. */
  34656. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34657. /** Callback called when a pointer move is detected */
  34658. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34659. /** Callback called when a pointer down is detected */
  34660. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34661. /** Callback called when a pointer up is detected */
  34662. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34663. /** Callback called when a pointer pick is detected */
  34664. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34665. /**
  34666. * 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).
  34667. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34668. */
  34669. onPrePointerObservable: Observable<PointerInfoPre>;
  34670. /**
  34671. * Observable event triggered each time an input event is received from the rendering canvas
  34672. */
  34673. onPointerObservable: Observable<PointerInfo>;
  34674. /**
  34675. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34676. */
  34677. readonly unTranslatedPointer: Vector2;
  34678. /**
  34679. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34680. */
  34681. static DragMovementThreshold: number;
  34682. /**
  34683. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34684. */
  34685. static LongPressDelay: number;
  34686. /**
  34687. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34688. */
  34689. static DoubleClickDelay: number;
  34690. /** If you need to check double click without raising a single click at first click, enable this flag */
  34691. static ExclusiveDoubleClickMode: boolean;
  34692. /** @hidden */
  34693. _mirroredCameraPosition: Nullable<Vector3>;
  34694. /**
  34695. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34696. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34697. */
  34698. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34699. /**
  34700. * Observable event triggered each time an keyboard event is received from the hosting window
  34701. */
  34702. onKeyboardObservable: Observable<KeyboardInfo>;
  34703. private _useRightHandedSystem;
  34704. /**
  34705. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34706. */
  34707. useRightHandedSystem: boolean;
  34708. private _timeAccumulator;
  34709. private _currentStepId;
  34710. private _currentInternalStep;
  34711. /**
  34712. * Sets the step Id used by deterministic lock step
  34713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34714. * @param newStepId defines the step Id
  34715. */
  34716. setStepId(newStepId: number): void;
  34717. /**
  34718. * Gets the step Id used by deterministic lock step
  34719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34720. * @returns the step Id
  34721. */
  34722. getStepId(): number;
  34723. /**
  34724. * Gets the internal step used by deterministic lock step
  34725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34726. * @returns the internal step
  34727. */
  34728. getInternalStep(): number;
  34729. private _fogEnabled;
  34730. /**
  34731. * Gets or sets a boolean indicating if fog is enabled on this scene
  34732. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34733. * (Default is true)
  34734. */
  34735. fogEnabled: boolean;
  34736. private _fogMode;
  34737. /**
  34738. * Gets or sets the fog mode to use
  34739. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34740. * | mode | value |
  34741. * | --- | --- |
  34742. * | FOGMODE_NONE | 0 |
  34743. * | FOGMODE_EXP | 1 |
  34744. * | FOGMODE_EXP2 | 2 |
  34745. * | FOGMODE_LINEAR | 3 |
  34746. */
  34747. fogMode: number;
  34748. /**
  34749. * Gets or sets the fog color to use
  34750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34751. * (Default is Color3(0.2, 0.2, 0.3))
  34752. */
  34753. fogColor: Color3;
  34754. /**
  34755. * Gets or sets the fog density to use
  34756. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34757. * (Default is 0.1)
  34758. */
  34759. fogDensity: number;
  34760. /**
  34761. * Gets or sets the fog start distance to use
  34762. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34763. * (Default is 0)
  34764. */
  34765. fogStart: number;
  34766. /**
  34767. * Gets or sets the fog end distance to use
  34768. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34769. * (Default is 1000)
  34770. */
  34771. fogEnd: number;
  34772. private _shadowsEnabled;
  34773. /**
  34774. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34775. */
  34776. shadowsEnabled: boolean;
  34777. private _lightsEnabled;
  34778. /**
  34779. * Gets or sets a boolean indicating if lights are enabled on this scene
  34780. */
  34781. lightsEnabled: boolean;
  34782. /** All of the active cameras added to this scene. */
  34783. activeCameras: Camera[];
  34784. /** @hidden */
  34785. _activeCamera: Nullable<Camera>;
  34786. /** Gets or sets the current active camera */
  34787. activeCamera: Nullable<Camera>;
  34788. private _defaultMaterial;
  34789. /** The default material used on meshes when no material is affected */
  34790. /** The default material used on meshes when no material is affected */
  34791. defaultMaterial: Material;
  34792. private _texturesEnabled;
  34793. /**
  34794. * Gets or sets a boolean indicating if textures are enabled on this scene
  34795. */
  34796. texturesEnabled: boolean;
  34797. /**
  34798. * Gets or sets a boolean indicating if particles are enabled on this scene
  34799. */
  34800. particlesEnabled: boolean;
  34801. /**
  34802. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34803. */
  34804. spritesEnabled: boolean;
  34805. private _skeletonsEnabled;
  34806. /**
  34807. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34808. */
  34809. skeletonsEnabled: boolean;
  34810. /**
  34811. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34812. */
  34813. lensFlaresEnabled: boolean;
  34814. /**
  34815. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34817. */
  34818. collisionsEnabled: boolean;
  34819. private _collisionCoordinator;
  34820. /** @hidden */
  34821. readonly collisionCoordinator: ICollisionCoordinator;
  34822. /**
  34823. * Defines the gravity applied to this scene (used only for collisions)
  34824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34825. */
  34826. gravity: Vector3;
  34827. /**
  34828. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34829. */
  34830. postProcessesEnabled: boolean;
  34831. /**
  34832. * The list of postprocesses added to the scene
  34833. */
  34834. postProcesses: PostProcess[];
  34835. /**
  34836. * Gets the current postprocess manager
  34837. */
  34838. postProcessManager: PostProcessManager;
  34839. /**
  34840. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34841. */
  34842. renderTargetsEnabled: boolean;
  34843. /**
  34844. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34845. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34846. */
  34847. dumpNextRenderTargets: boolean;
  34848. /**
  34849. * The list of user defined render targets added to the scene
  34850. */
  34851. customRenderTargets: RenderTargetTexture[];
  34852. /**
  34853. * Defines if texture loading must be delayed
  34854. * If true, textures will only be loaded when they need to be rendered
  34855. */
  34856. useDelayedTextureLoading: boolean;
  34857. /**
  34858. * Gets the list of meshes imported to the scene through SceneLoader
  34859. */
  34860. importedMeshesFiles: String[];
  34861. /**
  34862. * Gets or sets a boolean indicating if probes are enabled on this scene
  34863. */
  34864. probesEnabled: boolean;
  34865. /**
  34866. * Gets or sets the current offline provider to use to store scene data
  34867. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34868. */
  34869. offlineProvider: IOfflineProvider;
  34870. /**
  34871. * Gets or sets the action manager associated with the scene
  34872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34873. */
  34874. actionManager: AbstractActionManager;
  34875. private _meshesForIntersections;
  34876. /**
  34877. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34878. */
  34879. proceduralTexturesEnabled: boolean;
  34880. private _engine;
  34881. private _totalVertices;
  34882. /** @hidden */
  34883. _activeIndices: PerfCounter;
  34884. /** @hidden */
  34885. _activeParticles: PerfCounter;
  34886. /** @hidden */
  34887. _activeBones: PerfCounter;
  34888. private _animationRatio;
  34889. /** @hidden */
  34890. _animationTimeLast: number;
  34891. /** @hidden */
  34892. _animationTime: number;
  34893. /**
  34894. * Gets or sets a general scale for animation speed
  34895. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34896. */
  34897. animationTimeScale: number;
  34898. /** @hidden */
  34899. _cachedMaterial: Nullable<Material>;
  34900. /** @hidden */
  34901. _cachedEffect: Nullable<Effect>;
  34902. /** @hidden */
  34903. _cachedVisibility: Nullable<number>;
  34904. private _renderId;
  34905. private _frameId;
  34906. private _executeWhenReadyTimeoutId;
  34907. private _intermediateRendering;
  34908. private _viewUpdateFlag;
  34909. private _projectionUpdateFlag;
  34910. /** @hidden */
  34911. _toBeDisposed: Nullable<IDisposable>[];
  34912. private _activeRequests;
  34913. /** @hidden */
  34914. _pendingData: any[];
  34915. private _isDisposed;
  34916. /**
  34917. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34918. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34919. */
  34920. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34921. private _activeMeshes;
  34922. private _processedMaterials;
  34923. private _renderTargets;
  34924. /** @hidden */
  34925. _activeParticleSystems: SmartArray<IParticleSystem>;
  34926. private _activeSkeletons;
  34927. private _softwareSkinnedMeshes;
  34928. private _renderingManager;
  34929. /** @hidden */
  34930. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34931. private _transformMatrix;
  34932. private _sceneUbo;
  34933. /** @hidden */
  34934. _viewMatrix: Matrix;
  34935. private _projectionMatrix;
  34936. /** @hidden */
  34937. _forcedViewPosition: Nullable<Vector3>;
  34938. /** @hidden */
  34939. _frustumPlanes: Plane[];
  34940. /**
  34941. * Gets the list of frustum planes (built from the active camera)
  34942. */
  34943. readonly frustumPlanes: Plane[];
  34944. /**
  34945. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34946. * This is useful if there are more lights that the maximum simulteanous authorized
  34947. */
  34948. requireLightSorting: boolean;
  34949. /** @hidden */
  34950. readonly useMaterialMeshMap: boolean;
  34951. /** @hidden */
  34952. readonly useClonedMeshhMap: boolean;
  34953. private _externalData;
  34954. private _uid;
  34955. /**
  34956. * @hidden
  34957. * Backing store of defined scene components.
  34958. */
  34959. _components: ISceneComponent[];
  34960. /**
  34961. * @hidden
  34962. * Backing store of defined scene components.
  34963. */
  34964. _serializableComponents: ISceneSerializableComponent[];
  34965. /**
  34966. * List of components to register on the next registration step.
  34967. */
  34968. private _transientComponents;
  34969. /**
  34970. * Registers the transient components if needed.
  34971. */
  34972. private _registerTransientComponents;
  34973. /**
  34974. * @hidden
  34975. * Add a component to the scene.
  34976. * Note that the ccomponent could be registered on th next frame if this is called after
  34977. * the register component stage.
  34978. * @param component Defines the component to add to the scene
  34979. */
  34980. _addComponent(component: ISceneComponent): void;
  34981. /**
  34982. * @hidden
  34983. * Gets a component from the scene.
  34984. * @param name defines the name of the component to retrieve
  34985. * @returns the component or null if not present
  34986. */
  34987. _getComponent(name: string): Nullable<ISceneComponent>;
  34988. /**
  34989. * @hidden
  34990. * Defines the actions happening before camera updates.
  34991. */
  34992. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34993. /**
  34994. * @hidden
  34995. * Defines the actions happening before clear the canvas.
  34996. */
  34997. _beforeClearStage: Stage<SimpleStageAction>;
  34998. /**
  34999. * @hidden
  35000. * Defines the actions when collecting render targets for the frame.
  35001. */
  35002. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35003. /**
  35004. * @hidden
  35005. * Defines the actions happening for one camera in the frame.
  35006. */
  35007. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35008. /**
  35009. * @hidden
  35010. * Defines the actions happening during the per mesh ready checks.
  35011. */
  35012. _isReadyForMeshStage: Stage<MeshStageAction>;
  35013. /**
  35014. * @hidden
  35015. * Defines the actions happening before evaluate active mesh checks.
  35016. */
  35017. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35018. /**
  35019. * @hidden
  35020. * Defines the actions happening during the evaluate sub mesh checks.
  35021. */
  35022. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35023. /**
  35024. * @hidden
  35025. * Defines the actions happening during the active mesh stage.
  35026. */
  35027. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35028. /**
  35029. * @hidden
  35030. * Defines the actions happening during the per camera render target step.
  35031. */
  35032. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35033. /**
  35034. * @hidden
  35035. * Defines the actions happening just before the active camera is drawing.
  35036. */
  35037. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35038. /**
  35039. * @hidden
  35040. * Defines the actions happening just before a render target is drawing.
  35041. */
  35042. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35043. /**
  35044. * @hidden
  35045. * Defines the actions happening just before a rendering group is drawing.
  35046. */
  35047. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35048. /**
  35049. * @hidden
  35050. * Defines the actions happening just before a mesh is drawing.
  35051. */
  35052. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35053. /**
  35054. * @hidden
  35055. * Defines the actions happening just after a mesh has been drawn.
  35056. */
  35057. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35058. /**
  35059. * @hidden
  35060. * Defines the actions happening just after a rendering group has been drawn.
  35061. */
  35062. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35063. /**
  35064. * @hidden
  35065. * Defines the actions happening just after the active camera has been drawn.
  35066. */
  35067. _afterCameraDrawStage: Stage<CameraStageAction>;
  35068. /**
  35069. * @hidden
  35070. * Defines the actions happening just after a render target has been drawn.
  35071. */
  35072. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35073. /**
  35074. * @hidden
  35075. * Defines the actions happening just after rendering all cameras and computing intersections.
  35076. */
  35077. _afterRenderStage: Stage<SimpleStageAction>;
  35078. /**
  35079. * @hidden
  35080. * Defines the actions happening when a pointer move event happens.
  35081. */
  35082. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35083. /**
  35084. * @hidden
  35085. * Defines the actions happening when a pointer down event happens.
  35086. */
  35087. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35088. /**
  35089. * @hidden
  35090. * Defines the actions happening when a pointer up event happens.
  35091. */
  35092. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35093. /**
  35094. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35095. */
  35096. private geometriesByUniqueId;
  35097. /**
  35098. * Creates a new Scene
  35099. * @param engine defines the engine to use to render this scene
  35100. * @param options defines the scene options
  35101. */
  35102. constructor(engine: Engine, options?: SceneOptions);
  35103. /**
  35104. * Gets a string idenfifying the name of the class
  35105. * @returns "Scene" string
  35106. */
  35107. getClassName(): string;
  35108. private _defaultMeshCandidates;
  35109. /**
  35110. * @hidden
  35111. */
  35112. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35113. private _defaultSubMeshCandidates;
  35114. /**
  35115. * @hidden
  35116. */
  35117. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35118. /**
  35119. * Sets the default candidate providers for the scene.
  35120. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35121. * and getCollidingSubMeshCandidates to their default function
  35122. */
  35123. setDefaultCandidateProviders(): void;
  35124. /**
  35125. * Gets the mesh that is currently under the pointer
  35126. */
  35127. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35128. /**
  35129. * Gets or sets the current on-screen X position of the pointer
  35130. */
  35131. pointerX: number;
  35132. /**
  35133. * Gets or sets the current on-screen Y position of the pointer
  35134. */
  35135. pointerY: number;
  35136. /**
  35137. * Gets the cached material (ie. the latest rendered one)
  35138. * @returns the cached material
  35139. */
  35140. getCachedMaterial(): Nullable<Material>;
  35141. /**
  35142. * Gets the cached effect (ie. the latest rendered one)
  35143. * @returns the cached effect
  35144. */
  35145. getCachedEffect(): Nullable<Effect>;
  35146. /**
  35147. * Gets the cached visibility state (ie. the latest rendered one)
  35148. * @returns the cached visibility state
  35149. */
  35150. getCachedVisibility(): Nullable<number>;
  35151. /**
  35152. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35153. * @param material defines the current material
  35154. * @param effect defines the current effect
  35155. * @param visibility defines the current visibility state
  35156. * @returns true if one parameter is not cached
  35157. */
  35158. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35159. /**
  35160. * Gets the engine associated with the scene
  35161. * @returns an Engine
  35162. */
  35163. getEngine(): Engine;
  35164. /**
  35165. * Gets the total number of vertices rendered per frame
  35166. * @returns the total number of vertices rendered per frame
  35167. */
  35168. getTotalVertices(): number;
  35169. /**
  35170. * Gets the performance counter for total vertices
  35171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35172. */
  35173. readonly totalVerticesPerfCounter: PerfCounter;
  35174. /**
  35175. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35176. * @returns the total number of active indices rendered per frame
  35177. */
  35178. getActiveIndices(): number;
  35179. /**
  35180. * Gets the performance counter for active indices
  35181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35182. */
  35183. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35184. /**
  35185. * Gets the total number of active particles rendered per frame
  35186. * @returns the total number of active particles rendered per frame
  35187. */
  35188. getActiveParticles(): number;
  35189. /**
  35190. * Gets the performance counter for active particles
  35191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35192. */
  35193. readonly activeParticlesPerfCounter: PerfCounter;
  35194. /**
  35195. * Gets the total number of active bones rendered per frame
  35196. * @returns the total number of active bones rendered per frame
  35197. */
  35198. getActiveBones(): number;
  35199. /**
  35200. * Gets the performance counter for active bones
  35201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35202. */
  35203. readonly activeBonesPerfCounter: PerfCounter;
  35204. /**
  35205. * Gets the array of active meshes
  35206. * @returns an array of AbstractMesh
  35207. */
  35208. getActiveMeshes(): SmartArray<AbstractMesh>;
  35209. /**
  35210. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35211. * @returns a number
  35212. */
  35213. getAnimationRatio(): number;
  35214. /**
  35215. * Gets an unique Id for the current render phase
  35216. * @returns a number
  35217. */
  35218. getRenderId(): number;
  35219. /**
  35220. * Gets an unique Id for the current frame
  35221. * @returns a number
  35222. */
  35223. getFrameId(): number;
  35224. /** Call this function if you want to manually increment the render Id*/
  35225. incrementRenderId(): void;
  35226. private _createUbo;
  35227. /**
  35228. * Use this method to simulate a pointer move on a mesh
  35229. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35230. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35231. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35232. * @returns the current scene
  35233. */
  35234. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35235. /**
  35236. * Use this method to simulate a pointer down on a mesh
  35237. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35238. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35239. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35240. * @returns the current scene
  35241. */
  35242. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35243. /**
  35244. * Use this method to simulate a pointer up on a mesh
  35245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35248. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35249. * @returns the current scene
  35250. */
  35251. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35252. /**
  35253. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35254. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35255. * @returns true if the pointer was captured
  35256. */
  35257. isPointerCaptured(pointerId?: number): boolean;
  35258. /**
  35259. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35260. * @param attachUp defines if you want to attach events to pointerup
  35261. * @param attachDown defines if you want to attach events to pointerdown
  35262. * @param attachMove defines if you want to attach events to pointermove
  35263. */
  35264. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35265. /** Detaches all event handlers*/
  35266. detachControl(): void;
  35267. /**
  35268. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35269. * Delay loaded resources are not taking in account
  35270. * @return true if all required resources are ready
  35271. */
  35272. isReady(): boolean;
  35273. /** Resets all cached information relative to material (including effect and visibility) */
  35274. resetCachedMaterial(): void;
  35275. /**
  35276. * Registers a function to be called before every frame render
  35277. * @param func defines the function to register
  35278. */
  35279. registerBeforeRender(func: () => void): void;
  35280. /**
  35281. * Unregisters a function called before every frame render
  35282. * @param func defines the function to unregister
  35283. */
  35284. unregisterBeforeRender(func: () => void): void;
  35285. /**
  35286. * Registers a function to be called after every frame render
  35287. * @param func defines the function to register
  35288. */
  35289. registerAfterRender(func: () => void): void;
  35290. /**
  35291. * Unregisters a function called after every frame render
  35292. * @param func defines the function to unregister
  35293. */
  35294. unregisterAfterRender(func: () => void): void;
  35295. private _executeOnceBeforeRender;
  35296. /**
  35297. * The provided function will run before render once and will be disposed afterwards.
  35298. * A timeout delay can be provided so that the function will be executed in N ms.
  35299. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35300. * @param func The function to be executed.
  35301. * @param timeout optional delay in ms
  35302. */
  35303. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35304. /** @hidden */
  35305. _addPendingData(data: any): void;
  35306. /** @hidden */
  35307. _removePendingData(data: any): void;
  35308. /**
  35309. * Returns the number of items waiting to be loaded
  35310. * @returns the number of items waiting to be loaded
  35311. */
  35312. getWaitingItemsCount(): number;
  35313. /**
  35314. * Returns a boolean indicating if the scene is still loading data
  35315. */
  35316. readonly isLoading: boolean;
  35317. /**
  35318. * Registers a function to be executed when the scene is ready
  35319. * @param {Function} func - the function to be executed
  35320. */
  35321. executeWhenReady(func: () => void): void;
  35322. /**
  35323. * Returns a promise that resolves when the scene is ready
  35324. * @returns A promise that resolves when the scene is ready
  35325. */
  35326. whenReadyAsync(): Promise<void>;
  35327. /** @hidden */
  35328. _checkIsReady(): void;
  35329. /**
  35330. * Gets all animatable attached to the scene
  35331. */
  35332. readonly animatables: Animatable[];
  35333. /**
  35334. * Resets the last animation time frame.
  35335. * Useful to override when animations start running when loading a scene for the first time.
  35336. */
  35337. resetLastAnimationTimeFrame(): void;
  35338. /**
  35339. * Gets the current view matrix
  35340. * @returns a Matrix
  35341. */
  35342. getViewMatrix(): Matrix;
  35343. /**
  35344. * Gets the current projection matrix
  35345. * @returns a Matrix
  35346. */
  35347. getProjectionMatrix(): Matrix;
  35348. /**
  35349. * Gets the current transform matrix
  35350. * @returns a Matrix made of View * Projection
  35351. */
  35352. getTransformMatrix(): Matrix;
  35353. /**
  35354. * Sets the current transform matrix
  35355. * @param viewL defines the View matrix to use
  35356. * @param projectionL defines the Projection matrix to use
  35357. * @param viewR defines the right View matrix to use (if provided)
  35358. * @param projectionR defines the right Projection matrix to use (if provided)
  35359. */
  35360. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35361. /**
  35362. * Gets the uniform buffer used to store scene data
  35363. * @returns a UniformBuffer
  35364. */
  35365. getSceneUniformBuffer(): UniformBuffer;
  35366. /**
  35367. * Gets an unique (relatively to the current scene) Id
  35368. * @returns an unique number for the scene
  35369. */
  35370. getUniqueId(): number;
  35371. /**
  35372. * Add a mesh to the list of scene's meshes
  35373. * @param newMesh defines the mesh to add
  35374. * @param recursive if all child meshes should also be added to the scene
  35375. */
  35376. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35377. /**
  35378. * Remove a mesh for the list of scene's meshes
  35379. * @param toRemove defines the mesh to remove
  35380. * @param recursive if all child meshes should also be removed from the scene
  35381. * @returns the index where the mesh was in the mesh list
  35382. */
  35383. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35384. /**
  35385. * Add a transform node to the list of scene's transform nodes
  35386. * @param newTransformNode defines the transform node to add
  35387. */
  35388. addTransformNode(newTransformNode: TransformNode): void;
  35389. /**
  35390. * Remove a transform node for the list of scene's transform nodes
  35391. * @param toRemove defines the transform node to remove
  35392. * @returns the index where the transform node was in the transform node list
  35393. */
  35394. removeTransformNode(toRemove: TransformNode): number;
  35395. /**
  35396. * Remove a skeleton for the list of scene's skeletons
  35397. * @param toRemove defines the skeleton to remove
  35398. * @returns the index where the skeleton was in the skeleton list
  35399. */
  35400. removeSkeleton(toRemove: Skeleton): number;
  35401. /**
  35402. * Remove a morph target for the list of scene's morph targets
  35403. * @param toRemove defines the morph target to remove
  35404. * @returns the index where the morph target was in the morph target list
  35405. */
  35406. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35407. /**
  35408. * Remove a light for the list of scene's lights
  35409. * @param toRemove defines the light to remove
  35410. * @returns the index where the light was in the light list
  35411. */
  35412. removeLight(toRemove: Light): number;
  35413. /**
  35414. * Remove a camera for the list of scene's cameras
  35415. * @param toRemove defines the camera to remove
  35416. * @returns the index where the camera was in the camera list
  35417. */
  35418. removeCamera(toRemove: Camera): number;
  35419. /**
  35420. * Remove a particle system for the list of scene's particle systems
  35421. * @param toRemove defines the particle system to remove
  35422. * @returns the index where the particle system was in the particle system list
  35423. */
  35424. removeParticleSystem(toRemove: IParticleSystem): number;
  35425. /**
  35426. * Remove a animation for the list of scene's animations
  35427. * @param toRemove defines the animation to remove
  35428. * @returns the index where the animation was in the animation list
  35429. */
  35430. removeAnimation(toRemove: Animation): number;
  35431. /**
  35432. * Will stop the animation of the given target
  35433. * @param target - the target
  35434. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35435. * @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)
  35436. */
  35437. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35438. /**
  35439. * Removes the given animation group from this scene.
  35440. * @param toRemove The animation group to remove
  35441. * @returns The index of the removed animation group
  35442. */
  35443. removeAnimationGroup(toRemove: AnimationGroup): number;
  35444. /**
  35445. * Removes the given multi-material from this scene.
  35446. * @param toRemove The multi-material to remove
  35447. * @returns The index of the removed multi-material
  35448. */
  35449. removeMultiMaterial(toRemove: MultiMaterial): number;
  35450. /**
  35451. * Removes the given material from this scene.
  35452. * @param toRemove The material to remove
  35453. * @returns The index of the removed material
  35454. */
  35455. removeMaterial(toRemove: Material): number;
  35456. /**
  35457. * Removes the given action manager from this scene.
  35458. * @param toRemove The action manager to remove
  35459. * @returns The index of the removed action manager
  35460. */
  35461. removeActionManager(toRemove: AbstractActionManager): number;
  35462. /**
  35463. * Removes the given texture from this scene.
  35464. * @param toRemove The texture to remove
  35465. * @returns The index of the removed texture
  35466. */
  35467. removeTexture(toRemove: BaseTexture): number;
  35468. /**
  35469. * Adds the given light to this scene
  35470. * @param newLight The light to add
  35471. */
  35472. addLight(newLight: Light): void;
  35473. /**
  35474. * Sorts the list list based on light priorities
  35475. */
  35476. sortLightsByPriority(): void;
  35477. /**
  35478. * Adds the given camera to this scene
  35479. * @param newCamera The camera to add
  35480. */
  35481. addCamera(newCamera: Camera): void;
  35482. /**
  35483. * Adds the given skeleton to this scene
  35484. * @param newSkeleton The skeleton to add
  35485. */
  35486. addSkeleton(newSkeleton: Skeleton): void;
  35487. /**
  35488. * Adds the given particle system to this scene
  35489. * @param newParticleSystem The particle system to add
  35490. */
  35491. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35492. /**
  35493. * Adds the given animation to this scene
  35494. * @param newAnimation The animation to add
  35495. */
  35496. addAnimation(newAnimation: Animation): void;
  35497. /**
  35498. * Adds the given animation group to this scene.
  35499. * @param newAnimationGroup The animation group to add
  35500. */
  35501. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35502. /**
  35503. * Adds the given multi-material to this scene
  35504. * @param newMultiMaterial The multi-material to add
  35505. */
  35506. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35507. /**
  35508. * Adds the given material to this scene
  35509. * @param newMaterial The material to add
  35510. */
  35511. addMaterial(newMaterial: Material): void;
  35512. /**
  35513. * Adds the given morph target to this scene
  35514. * @param newMorphTargetManager The morph target to add
  35515. */
  35516. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35517. /**
  35518. * Adds the given geometry to this scene
  35519. * @param newGeometry The geometry to add
  35520. */
  35521. addGeometry(newGeometry: Geometry): void;
  35522. /**
  35523. * Adds the given action manager to this scene
  35524. * @param newActionManager The action manager to add
  35525. */
  35526. addActionManager(newActionManager: AbstractActionManager): void;
  35527. /**
  35528. * Adds the given texture to this scene.
  35529. * @param newTexture The texture to add
  35530. */
  35531. addTexture(newTexture: BaseTexture): void;
  35532. /**
  35533. * Switch active camera
  35534. * @param newCamera defines the new active camera
  35535. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35536. */
  35537. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35538. /**
  35539. * sets the active camera of the scene using its ID
  35540. * @param id defines the camera's ID
  35541. * @return the new active camera or null if none found.
  35542. */
  35543. setActiveCameraByID(id: string): Nullable<Camera>;
  35544. /**
  35545. * sets the active camera of the scene using its name
  35546. * @param name defines the camera's name
  35547. * @returns the new active camera or null if none found.
  35548. */
  35549. setActiveCameraByName(name: string): Nullable<Camera>;
  35550. /**
  35551. * get an animation group using its name
  35552. * @param name defines the material's name
  35553. * @return the animation group or null if none found.
  35554. */
  35555. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35556. /**
  35557. * Get a material using its unique id
  35558. * @param uniqueId defines the material's unique id
  35559. * @return the material or null if none found.
  35560. */
  35561. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35562. /**
  35563. * get a material using its id
  35564. * @param id defines the material's ID
  35565. * @return the material or null if none found.
  35566. */
  35567. getMaterialByID(id: string): Nullable<Material>;
  35568. /**
  35569. * Gets a the last added material using a given id
  35570. * @param id defines the material's ID
  35571. * @return the last material with the given id or null if none found.
  35572. */
  35573. getLastMaterialByID(id: string): Nullable<Material>;
  35574. /**
  35575. * Gets a material using its name
  35576. * @param name defines the material's name
  35577. * @return the material or null if none found.
  35578. */
  35579. getMaterialByName(name: string): Nullable<Material>;
  35580. /**
  35581. * Get a texture using its unique id
  35582. * @param uniqueId defines the texture's unique id
  35583. * @return the texture or null if none found.
  35584. */
  35585. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35586. /**
  35587. * Gets a camera using its id
  35588. * @param id defines the id to look for
  35589. * @returns the camera or null if not found
  35590. */
  35591. getCameraByID(id: string): Nullable<Camera>;
  35592. /**
  35593. * Gets a camera using its unique id
  35594. * @param uniqueId defines the unique id to look for
  35595. * @returns the camera or null if not found
  35596. */
  35597. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35598. /**
  35599. * Gets a camera using its name
  35600. * @param name defines the camera's name
  35601. * @return the camera or null if none found.
  35602. */
  35603. getCameraByName(name: string): Nullable<Camera>;
  35604. /**
  35605. * Gets a bone using its id
  35606. * @param id defines the bone's id
  35607. * @return the bone or null if not found
  35608. */
  35609. getBoneByID(id: string): Nullable<Bone>;
  35610. /**
  35611. * Gets a bone using its id
  35612. * @param name defines the bone's name
  35613. * @return the bone or null if not found
  35614. */
  35615. getBoneByName(name: string): Nullable<Bone>;
  35616. /**
  35617. * Gets a light node using its name
  35618. * @param name defines the the light's name
  35619. * @return the light or null if none found.
  35620. */
  35621. getLightByName(name: string): Nullable<Light>;
  35622. /**
  35623. * Gets a light node using its id
  35624. * @param id defines the light's id
  35625. * @return the light or null if none found.
  35626. */
  35627. getLightByID(id: string): Nullable<Light>;
  35628. /**
  35629. * Gets a light node using its scene-generated unique ID
  35630. * @param uniqueId defines the light's unique id
  35631. * @return the light or null if none found.
  35632. */
  35633. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35634. /**
  35635. * Gets a particle system by id
  35636. * @param id defines the particle system id
  35637. * @return the corresponding system or null if none found
  35638. */
  35639. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35640. /**
  35641. * Gets a geometry using its ID
  35642. * @param id defines the geometry's id
  35643. * @return the geometry or null if none found.
  35644. */
  35645. getGeometryByID(id: string): Nullable<Geometry>;
  35646. private _getGeometryByUniqueID;
  35647. /**
  35648. * Add a new geometry to this scene
  35649. * @param geometry defines the geometry to be added to the scene.
  35650. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35651. * @return a boolean defining if the geometry was added or not
  35652. */
  35653. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35654. /**
  35655. * Removes an existing geometry
  35656. * @param geometry defines the geometry to be removed from the scene
  35657. * @return a boolean defining if the geometry was removed or not
  35658. */
  35659. removeGeometry(geometry: Geometry): boolean;
  35660. /**
  35661. * Gets the list of geometries attached to the scene
  35662. * @returns an array of Geometry
  35663. */
  35664. getGeometries(): Geometry[];
  35665. /**
  35666. * Gets the first added mesh found of a given ID
  35667. * @param id defines the id to search for
  35668. * @return the mesh found or null if not found at all
  35669. */
  35670. getMeshByID(id: string): Nullable<AbstractMesh>;
  35671. /**
  35672. * Gets a list of meshes using their id
  35673. * @param id defines the id to search for
  35674. * @returns a list of meshes
  35675. */
  35676. getMeshesByID(id: string): Array<AbstractMesh>;
  35677. /**
  35678. * Gets the first added transform node found of a given ID
  35679. * @param id defines the id to search for
  35680. * @return the found transform node or null if not found at all.
  35681. */
  35682. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35683. /**
  35684. * Gets a transform node with its auto-generated unique id
  35685. * @param uniqueId efines the unique id to search for
  35686. * @return the found transform node or null if not found at all.
  35687. */
  35688. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35689. /**
  35690. * Gets a list of transform nodes using their id
  35691. * @param id defines the id to search for
  35692. * @returns a list of transform nodes
  35693. */
  35694. getTransformNodesByID(id: string): Array<TransformNode>;
  35695. /**
  35696. * Gets a mesh with its auto-generated unique id
  35697. * @param uniqueId defines the unique id to search for
  35698. * @return the found mesh or null if not found at all.
  35699. */
  35700. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35701. /**
  35702. * Gets a the last added mesh using a given id
  35703. * @param id defines the id to search for
  35704. * @return the found mesh or null if not found at all.
  35705. */
  35706. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35707. /**
  35708. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35709. * @param id defines the id to search for
  35710. * @return the found node or null if not found at all
  35711. */
  35712. getLastEntryByID(id: string): Nullable<Node>;
  35713. /**
  35714. * Gets a node (Mesh, Camera, Light) using a given id
  35715. * @param id defines the id to search for
  35716. * @return the found node or null if not found at all
  35717. */
  35718. getNodeByID(id: string): Nullable<Node>;
  35719. /**
  35720. * Gets a node (Mesh, Camera, Light) using a given name
  35721. * @param name defines the name to search for
  35722. * @return the found node or null if not found at all.
  35723. */
  35724. getNodeByName(name: string): Nullable<Node>;
  35725. /**
  35726. * Gets a mesh using a given name
  35727. * @param name defines the name to search for
  35728. * @return the found mesh or null if not found at all.
  35729. */
  35730. getMeshByName(name: string): Nullable<AbstractMesh>;
  35731. /**
  35732. * Gets a transform node using a given name
  35733. * @param name defines the name to search for
  35734. * @return the found transform node or null if not found at all.
  35735. */
  35736. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35737. /**
  35738. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35739. * @param id defines the id to search for
  35740. * @return the found skeleton or null if not found at all.
  35741. */
  35742. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35743. /**
  35744. * Gets a skeleton using a given auto generated unique id
  35745. * @param uniqueId defines the unique id to search for
  35746. * @return the found skeleton or null if not found at all.
  35747. */
  35748. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35749. /**
  35750. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35751. * @param id defines the id to search for
  35752. * @return the found skeleton or null if not found at all.
  35753. */
  35754. getSkeletonById(id: string): Nullable<Skeleton>;
  35755. /**
  35756. * Gets a skeleton using a given name
  35757. * @param name defines the name to search for
  35758. * @return the found skeleton or null if not found at all.
  35759. */
  35760. getSkeletonByName(name: string): Nullable<Skeleton>;
  35761. /**
  35762. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35763. * @param id defines the id to search for
  35764. * @return the found morph target manager or null if not found at all.
  35765. */
  35766. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35767. /**
  35768. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35769. * @param id defines the id to search for
  35770. * @return the found morph target or null if not found at all.
  35771. */
  35772. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35773. /**
  35774. * Gets a boolean indicating if the given mesh is active
  35775. * @param mesh defines the mesh to look for
  35776. * @returns true if the mesh is in the active list
  35777. */
  35778. isActiveMesh(mesh: AbstractMesh): boolean;
  35779. /**
  35780. * Return a unique id as a string which can serve as an identifier for the scene
  35781. */
  35782. readonly uid: string;
  35783. /**
  35784. * Add an externaly attached data from its key.
  35785. * This method call will fail and return false, if such key already exists.
  35786. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35787. * @param key the unique key that identifies the data
  35788. * @param data the data object to associate to the key for this Engine instance
  35789. * @return true if no such key were already present and the data was added successfully, false otherwise
  35790. */
  35791. addExternalData<T>(key: string, data: T): boolean;
  35792. /**
  35793. * Get an externaly attached data from its key
  35794. * @param key the unique key that identifies the data
  35795. * @return the associated data, if present (can be null), or undefined if not present
  35796. */
  35797. getExternalData<T>(key: string): Nullable<T>;
  35798. /**
  35799. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35800. * @param key the unique key that identifies the data
  35801. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35802. * @return the associated data, can be null if the factory returned null.
  35803. */
  35804. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35805. /**
  35806. * Remove an externaly attached data from the Engine instance
  35807. * @param key the unique key that identifies the data
  35808. * @return true if the data was successfully removed, false if it doesn't exist
  35809. */
  35810. removeExternalData(key: string): boolean;
  35811. private _evaluateSubMesh;
  35812. /**
  35813. * Clear the processed materials smart array preventing retention point in material dispose.
  35814. */
  35815. freeProcessedMaterials(): void;
  35816. private _preventFreeActiveMeshesAndRenderingGroups;
  35817. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35818. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35819. * when disposing several meshes in a row or a hierarchy of meshes.
  35820. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35821. */
  35822. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35823. /**
  35824. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35825. */
  35826. freeActiveMeshes(): void;
  35827. /**
  35828. * Clear the info related to rendering groups preventing retention points during dispose.
  35829. */
  35830. freeRenderingGroups(): void;
  35831. /** @hidden */
  35832. _isInIntermediateRendering(): boolean;
  35833. /**
  35834. * Lambda returning the list of potentially active meshes.
  35835. */
  35836. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35837. /**
  35838. * Lambda returning the list of potentially active sub meshes.
  35839. */
  35840. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35841. /**
  35842. * Lambda returning the list of potentially intersecting sub meshes.
  35843. */
  35844. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35845. /**
  35846. * Lambda returning the list of potentially colliding sub meshes.
  35847. */
  35848. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35849. private _activeMeshesFrozen;
  35850. /**
  35851. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35852. * @returns the current scene
  35853. */
  35854. freezeActiveMeshes(): Scene;
  35855. /**
  35856. * Use this function to restart evaluating active meshes on every frame
  35857. * @returns the current scene
  35858. */
  35859. unfreezeActiveMeshes(): Scene;
  35860. private _evaluateActiveMeshes;
  35861. private _activeMesh;
  35862. /**
  35863. * Update the transform matrix to update from the current active camera
  35864. * @param force defines a boolean used to force the update even if cache is up to date
  35865. */
  35866. updateTransformMatrix(force?: boolean): void;
  35867. private _bindFrameBuffer;
  35868. /** @hidden */
  35869. _allowPostProcessClearColor: boolean;
  35870. /** @hidden */
  35871. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35872. private _processSubCameras;
  35873. private _checkIntersections;
  35874. /** @hidden */
  35875. _advancePhysicsEngineStep(step: number): void;
  35876. /**
  35877. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35878. */
  35879. getDeterministicFrameTime: () => number;
  35880. /** @hidden */
  35881. _animate(): void;
  35882. /** Execute all animations (for a frame) */
  35883. animate(): void;
  35884. /**
  35885. * Render the scene
  35886. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35887. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35888. */
  35889. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35890. /**
  35891. * Freeze all materials
  35892. * A frozen material will not be updatable but should be faster to render
  35893. */
  35894. freezeMaterials(): void;
  35895. /**
  35896. * Unfreeze all materials
  35897. * A frozen material will not be updatable but should be faster to render
  35898. */
  35899. unfreezeMaterials(): void;
  35900. /**
  35901. * Releases all held ressources
  35902. */
  35903. dispose(): void;
  35904. /**
  35905. * Gets if the scene is already disposed
  35906. */
  35907. readonly isDisposed: boolean;
  35908. /**
  35909. * Call this function to reduce memory footprint of the scene.
  35910. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35911. */
  35912. clearCachedVertexData(): void;
  35913. /**
  35914. * This function will remove the local cached buffer data from texture.
  35915. * It will save memory but will prevent the texture from being rebuilt
  35916. */
  35917. cleanCachedTextureBuffer(): void;
  35918. /**
  35919. * Get the world extend vectors with an optional filter
  35920. *
  35921. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35922. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35923. */
  35924. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35925. min: Vector3;
  35926. max: Vector3;
  35927. };
  35928. /**
  35929. * Creates a ray that can be used to pick in the scene
  35930. * @param x defines the x coordinate of the origin (on-screen)
  35931. * @param y defines the y coordinate of the origin (on-screen)
  35932. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35933. * @param camera defines the camera to use for the picking
  35934. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35935. * @returns a Ray
  35936. */
  35937. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35938. /**
  35939. * Creates a ray that can be used to pick in the scene
  35940. * @param x defines the x coordinate of the origin (on-screen)
  35941. * @param y defines the y coordinate of the origin (on-screen)
  35942. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35943. * @param result defines the ray where to store the picking ray
  35944. * @param camera defines the camera to use for the picking
  35945. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35946. * @returns the current scene
  35947. */
  35948. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35949. /**
  35950. * Creates a ray that can be used to pick in the scene
  35951. * @param x defines the x coordinate of the origin (on-screen)
  35952. * @param y defines the y coordinate of the origin (on-screen)
  35953. * @param camera defines the camera to use for the picking
  35954. * @returns a Ray
  35955. */
  35956. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35957. /**
  35958. * Creates a ray that can be used to pick in the scene
  35959. * @param x defines the x coordinate of the origin (on-screen)
  35960. * @param y defines the y coordinate of the origin (on-screen)
  35961. * @param result defines the ray where to store the picking ray
  35962. * @param camera defines the camera to use for the picking
  35963. * @returns the current scene
  35964. */
  35965. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35966. /** Launch a ray to try to pick a mesh in the scene
  35967. * @param x position on screen
  35968. * @param y position on screen
  35969. * @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
  35970. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35971. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35972. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35973. * @returns a PickingInfo
  35974. */
  35975. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35976. /** Use the given ray to pick a mesh in the scene
  35977. * @param ray The ray to use to pick meshes
  35978. * @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
  35979. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35980. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35981. * @returns a PickingInfo
  35982. */
  35983. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35984. /**
  35985. * Launch a ray to try to pick a mesh in the scene
  35986. * @param x X position on screen
  35987. * @param y Y position on screen
  35988. * @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
  35989. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35990. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35991. * @returns an array of PickingInfo
  35992. */
  35993. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35994. /**
  35995. * Launch a ray to try to pick a mesh in the scene
  35996. * @param ray Ray to use
  35997. * @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
  35998. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35999. * @returns an array of PickingInfo
  36000. */
  36001. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36002. /**
  36003. * Force the value of meshUnderPointer
  36004. * @param mesh defines the mesh to use
  36005. */
  36006. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36007. /**
  36008. * Gets the mesh under the pointer
  36009. * @returns a Mesh or null if no mesh is under the pointer
  36010. */
  36011. getPointerOverMesh(): Nullable<AbstractMesh>;
  36012. /** @hidden */
  36013. _rebuildGeometries(): void;
  36014. /** @hidden */
  36015. _rebuildTextures(): void;
  36016. private _getByTags;
  36017. /**
  36018. * Get a list of meshes by tags
  36019. * @param tagsQuery defines the tags query to use
  36020. * @param forEach defines a predicate used to filter results
  36021. * @returns an array of Mesh
  36022. */
  36023. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36024. /**
  36025. * Get a list of cameras by tags
  36026. * @param tagsQuery defines the tags query to use
  36027. * @param forEach defines a predicate used to filter results
  36028. * @returns an array of Camera
  36029. */
  36030. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36031. /**
  36032. * Get a list of lights by tags
  36033. * @param tagsQuery defines the tags query to use
  36034. * @param forEach defines a predicate used to filter results
  36035. * @returns an array of Light
  36036. */
  36037. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36038. /**
  36039. * Get a list of materials by tags
  36040. * @param tagsQuery defines the tags query to use
  36041. * @param forEach defines a predicate used to filter results
  36042. * @returns an array of Material
  36043. */
  36044. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36045. /**
  36046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36047. * This allowed control for front to back rendering or reversly depending of the special needs.
  36048. *
  36049. * @param renderingGroupId The rendering group id corresponding to its index
  36050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36053. */
  36054. 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;
  36055. /**
  36056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36057. *
  36058. * @param renderingGroupId The rendering group id corresponding to its index
  36059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36060. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36061. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36062. */
  36063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36064. /**
  36065. * Gets the current auto clear configuration for one rendering group of the rendering
  36066. * manager.
  36067. * @param index the rendering group index to get the information for
  36068. * @returns The auto clear setup for the requested rendering group
  36069. */
  36070. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36071. private _blockMaterialDirtyMechanism;
  36072. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36073. blockMaterialDirtyMechanism: boolean;
  36074. /**
  36075. * Will flag all materials as dirty to trigger new shader compilation
  36076. * @param flag defines the flag used to specify which material part must be marked as dirty
  36077. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36078. */
  36079. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36080. /** @hidden */
  36081. _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;
  36082. /** @hidden */
  36083. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36084. /** @hidden */
  36085. _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;
  36086. /** @hidden */
  36087. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36088. /** @hidden */
  36089. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36090. /** @hidden */
  36091. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36092. }
  36093. }
  36094. declare module "babylonjs/assetContainer" {
  36095. import { AbstractScene } from "babylonjs/abstractScene";
  36096. import { Scene } from "babylonjs/scene";
  36097. import { Mesh } from "babylonjs/Meshes/mesh";
  36098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36099. import { Skeleton } from "babylonjs/Bones/skeleton";
  36100. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36101. /**
  36102. * Set of assets to keep when moving a scene into an asset container.
  36103. */
  36104. export class KeepAssets extends AbstractScene {
  36105. }
  36106. /**
  36107. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36108. */
  36109. export class InstantiatedEntries {
  36110. /**
  36111. * List of new root nodes (eg. nodes with no parent)
  36112. */
  36113. rootNodes: TransformNode[];
  36114. /**
  36115. * List of new skeletons
  36116. */
  36117. skeletons: Skeleton[];
  36118. /**
  36119. * List of new animation groups
  36120. */
  36121. animationGroups: AnimationGroup[];
  36122. }
  36123. /**
  36124. * Container with a set of assets that can be added or removed from a scene.
  36125. */
  36126. export class AssetContainer extends AbstractScene {
  36127. /**
  36128. * The scene the AssetContainer belongs to.
  36129. */
  36130. scene: Scene;
  36131. /**
  36132. * Instantiates an AssetContainer.
  36133. * @param scene The scene the AssetContainer belongs to.
  36134. */
  36135. constructor(scene: Scene);
  36136. /**
  36137. * Instantiate or clone all meshes and add the new ones to the scene.
  36138. * Skeletons and animation groups will all be cloned
  36139. * @param nameFunction defines an optional function used to get new names for clones
  36140. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36141. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36142. */
  36143. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36144. /**
  36145. * Adds all the assets from the container to the scene.
  36146. */
  36147. addAllToScene(): void;
  36148. /**
  36149. * Removes all the assets in the container from the scene
  36150. */
  36151. removeAllFromScene(): void;
  36152. /**
  36153. * Disposes all the assets in the container
  36154. */
  36155. dispose(): void;
  36156. private _moveAssets;
  36157. /**
  36158. * Removes all the assets contained in the scene and adds them to the container.
  36159. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36160. */
  36161. moveAllFromScene(keepAssets?: KeepAssets): void;
  36162. /**
  36163. * 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.
  36164. * @returns the root mesh
  36165. */
  36166. createRootMesh(): Mesh;
  36167. }
  36168. }
  36169. declare module "babylonjs/abstractScene" {
  36170. import { Scene } from "babylonjs/scene";
  36171. import { Nullable } from "babylonjs/types";
  36172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36173. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36174. import { Geometry } from "babylonjs/Meshes/geometry";
  36175. import { Skeleton } from "babylonjs/Bones/skeleton";
  36176. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36177. import { AssetContainer } from "babylonjs/assetContainer";
  36178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36179. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36181. import { Material } from "babylonjs/Materials/material";
  36182. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36183. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36184. import { Camera } from "babylonjs/Cameras/camera";
  36185. import { Light } from "babylonjs/Lights/light";
  36186. import { Node } from "babylonjs/node";
  36187. import { Animation } from "babylonjs/Animations/animation";
  36188. /**
  36189. * Defines how the parser contract is defined.
  36190. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36191. */
  36192. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36193. /**
  36194. * Defines how the individual parser contract is defined.
  36195. * These parser can parse an individual asset
  36196. */
  36197. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36198. /**
  36199. * Base class of the scene acting as a container for the different elements composing a scene.
  36200. * This class is dynamically extended by the different components of the scene increasing
  36201. * flexibility and reducing coupling
  36202. */
  36203. export abstract class AbstractScene {
  36204. /**
  36205. * Stores the list of available parsers in the application.
  36206. */
  36207. private static _BabylonFileParsers;
  36208. /**
  36209. * Stores the list of available individual parsers in the application.
  36210. */
  36211. private static _IndividualBabylonFileParsers;
  36212. /**
  36213. * Adds a parser in the list of available ones
  36214. * @param name Defines the name of the parser
  36215. * @param parser Defines the parser to add
  36216. */
  36217. static AddParser(name: string, parser: BabylonFileParser): void;
  36218. /**
  36219. * Gets a general parser from the list of avaialble ones
  36220. * @param name Defines the name of the parser
  36221. * @returns the requested parser or null
  36222. */
  36223. static GetParser(name: string): Nullable<BabylonFileParser>;
  36224. /**
  36225. * Adds n individual parser in the list of available ones
  36226. * @param name Defines the name of the parser
  36227. * @param parser Defines the parser to add
  36228. */
  36229. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36230. /**
  36231. * Gets an individual parser from the list of avaialble ones
  36232. * @param name Defines the name of the parser
  36233. * @returns the requested parser or null
  36234. */
  36235. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36236. /**
  36237. * Parser json data and populate both a scene and its associated container object
  36238. * @param jsonData Defines the data to parse
  36239. * @param scene Defines the scene to parse the data for
  36240. * @param container Defines the container attached to the parsing sequence
  36241. * @param rootUrl Defines the root url of the data
  36242. */
  36243. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36244. /**
  36245. * Gets the list of root nodes (ie. nodes with no parent)
  36246. */
  36247. rootNodes: Node[];
  36248. /** All of the cameras added to this scene
  36249. * @see http://doc.babylonjs.com/babylon101/cameras
  36250. */
  36251. cameras: Camera[];
  36252. /**
  36253. * All of the lights added to this scene
  36254. * @see http://doc.babylonjs.com/babylon101/lights
  36255. */
  36256. lights: Light[];
  36257. /**
  36258. * All of the (abstract) meshes added to this scene
  36259. */
  36260. meshes: AbstractMesh[];
  36261. /**
  36262. * The list of skeletons added to the scene
  36263. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36264. */
  36265. skeletons: Skeleton[];
  36266. /**
  36267. * All of the particle systems added to this scene
  36268. * @see http://doc.babylonjs.com/babylon101/particles
  36269. */
  36270. particleSystems: IParticleSystem[];
  36271. /**
  36272. * Gets a list of Animations associated with the scene
  36273. */
  36274. animations: Animation[];
  36275. /**
  36276. * All of the animation groups added to this scene
  36277. * @see http://doc.babylonjs.com/how_to/group
  36278. */
  36279. animationGroups: AnimationGroup[];
  36280. /**
  36281. * All of the multi-materials added to this scene
  36282. * @see http://doc.babylonjs.com/how_to/multi_materials
  36283. */
  36284. multiMaterials: MultiMaterial[];
  36285. /**
  36286. * All of the materials added to this scene
  36287. * In the context of a Scene, it is not supposed to be modified manually.
  36288. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36289. * Note also that the order of the Material within the array is not significant and might change.
  36290. * @see http://doc.babylonjs.com/babylon101/materials
  36291. */
  36292. materials: Material[];
  36293. /**
  36294. * The list of morph target managers added to the scene
  36295. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36296. */
  36297. morphTargetManagers: MorphTargetManager[];
  36298. /**
  36299. * The list of geometries used in the scene.
  36300. */
  36301. geometries: Geometry[];
  36302. /**
  36303. * All of the tranform nodes added to this scene
  36304. * In the context of a Scene, it is not supposed to be modified manually.
  36305. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36306. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36307. * @see http://doc.babylonjs.com/how_to/transformnode
  36308. */
  36309. transformNodes: TransformNode[];
  36310. /**
  36311. * ActionManagers available on the scene.
  36312. */
  36313. actionManagers: AbstractActionManager[];
  36314. /**
  36315. * Textures to keep.
  36316. */
  36317. textures: BaseTexture[];
  36318. /**
  36319. * Environment texture for the scene
  36320. */
  36321. environmentTexture: Nullable<BaseTexture>;
  36322. }
  36323. }
  36324. declare module "babylonjs/Audio/sound" {
  36325. import { Observable } from "babylonjs/Misc/observable";
  36326. import { Vector3 } from "babylonjs/Maths/math.vector";
  36327. import { Nullable } from "babylonjs/types";
  36328. import { Scene } from "babylonjs/scene";
  36329. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36330. /**
  36331. * Interface used to define options for Sound class
  36332. */
  36333. export interface ISoundOptions {
  36334. /**
  36335. * Does the sound autoplay once loaded.
  36336. */
  36337. autoplay?: boolean;
  36338. /**
  36339. * Does the sound loop after it finishes playing once.
  36340. */
  36341. loop?: boolean;
  36342. /**
  36343. * Sound's volume
  36344. */
  36345. volume?: number;
  36346. /**
  36347. * Is it a spatial sound?
  36348. */
  36349. spatialSound?: boolean;
  36350. /**
  36351. * Maximum distance to hear that sound
  36352. */
  36353. maxDistance?: number;
  36354. /**
  36355. * Uses user defined attenuation function
  36356. */
  36357. useCustomAttenuation?: boolean;
  36358. /**
  36359. * Define the roll off factor of spatial sounds.
  36360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36361. */
  36362. rolloffFactor?: number;
  36363. /**
  36364. * Define the reference distance the sound should be heard perfectly.
  36365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36366. */
  36367. refDistance?: number;
  36368. /**
  36369. * Define the distance attenuation model the sound will follow.
  36370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36371. */
  36372. distanceModel?: string;
  36373. /**
  36374. * Defines the playback speed (1 by default)
  36375. */
  36376. playbackRate?: number;
  36377. /**
  36378. * Defines if the sound is from a streaming source
  36379. */
  36380. streaming?: boolean;
  36381. /**
  36382. * Defines an optional length (in seconds) inside the sound file
  36383. */
  36384. length?: number;
  36385. /**
  36386. * Defines an optional offset (in seconds) inside the sound file
  36387. */
  36388. offset?: number;
  36389. /**
  36390. * If true, URLs will not be required to state the audio file codec to use.
  36391. */
  36392. skipCodecCheck?: boolean;
  36393. }
  36394. /**
  36395. * Defines a sound that can be played in the application.
  36396. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36398. */
  36399. export class Sound {
  36400. /**
  36401. * The name of the sound in the scene.
  36402. */
  36403. name: string;
  36404. /**
  36405. * Does the sound autoplay once loaded.
  36406. */
  36407. autoplay: boolean;
  36408. /**
  36409. * Does the sound loop after it finishes playing once.
  36410. */
  36411. loop: boolean;
  36412. /**
  36413. * Does the sound use a custom attenuation curve to simulate the falloff
  36414. * happening when the source gets further away from the camera.
  36415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36416. */
  36417. useCustomAttenuation: boolean;
  36418. /**
  36419. * The sound track id this sound belongs to.
  36420. */
  36421. soundTrackId: number;
  36422. /**
  36423. * Is this sound currently played.
  36424. */
  36425. isPlaying: boolean;
  36426. /**
  36427. * Is this sound currently paused.
  36428. */
  36429. isPaused: boolean;
  36430. /**
  36431. * Does this sound enables spatial sound.
  36432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36433. */
  36434. spatialSound: boolean;
  36435. /**
  36436. * Define the reference distance the sound should be heard perfectly.
  36437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36438. */
  36439. refDistance: number;
  36440. /**
  36441. * Define the roll off factor of spatial sounds.
  36442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36443. */
  36444. rolloffFactor: number;
  36445. /**
  36446. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36448. */
  36449. maxDistance: number;
  36450. /**
  36451. * Define the distance attenuation model the sound will follow.
  36452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36453. */
  36454. distanceModel: string;
  36455. /**
  36456. * @hidden
  36457. * Back Compat
  36458. **/
  36459. onended: () => any;
  36460. /**
  36461. * Observable event when the current playing sound finishes.
  36462. */
  36463. onEndedObservable: Observable<Sound>;
  36464. private _panningModel;
  36465. private _playbackRate;
  36466. private _streaming;
  36467. private _startTime;
  36468. private _startOffset;
  36469. private _position;
  36470. /** @hidden */
  36471. _positionInEmitterSpace: boolean;
  36472. private _localDirection;
  36473. private _volume;
  36474. private _isReadyToPlay;
  36475. private _isDirectional;
  36476. private _readyToPlayCallback;
  36477. private _audioBuffer;
  36478. private _soundSource;
  36479. private _streamingSource;
  36480. private _soundPanner;
  36481. private _soundGain;
  36482. private _inputAudioNode;
  36483. private _outputAudioNode;
  36484. private _coneInnerAngle;
  36485. private _coneOuterAngle;
  36486. private _coneOuterGain;
  36487. private _scene;
  36488. private _connectedTransformNode;
  36489. private _customAttenuationFunction;
  36490. private _registerFunc;
  36491. private _isOutputConnected;
  36492. private _htmlAudioElement;
  36493. private _urlType;
  36494. private _length?;
  36495. private _offset?;
  36496. /** @hidden */
  36497. static _SceneComponentInitialization: (scene: Scene) => void;
  36498. /**
  36499. * Create a sound and attach it to a scene
  36500. * @param name Name of your sound
  36501. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36502. * @param scene defines the scene the sound belongs to
  36503. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36504. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36505. */
  36506. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36507. /**
  36508. * Release the sound and its associated resources
  36509. */
  36510. dispose(): void;
  36511. /**
  36512. * Gets if the sounds is ready to be played or not.
  36513. * @returns true if ready, otherwise false
  36514. */
  36515. isReady(): boolean;
  36516. private _soundLoaded;
  36517. /**
  36518. * Sets the data of the sound from an audiobuffer
  36519. * @param audioBuffer The audioBuffer containing the data
  36520. */
  36521. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36522. /**
  36523. * Updates the current sounds options such as maxdistance, loop...
  36524. * @param options A JSON object containing values named as the object properties
  36525. */
  36526. updateOptions(options: ISoundOptions): void;
  36527. private _createSpatialParameters;
  36528. private _updateSpatialParameters;
  36529. /**
  36530. * Switch the panning model to HRTF:
  36531. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36533. */
  36534. switchPanningModelToHRTF(): void;
  36535. /**
  36536. * Switch the panning model to Equal Power:
  36537. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36539. */
  36540. switchPanningModelToEqualPower(): void;
  36541. private _switchPanningModel;
  36542. /**
  36543. * Connect this sound to a sound track audio node like gain...
  36544. * @param soundTrackAudioNode the sound track audio node to connect to
  36545. */
  36546. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36547. /**
  36548. * Transform this sound into a directional source
  36549. * @param coneInnerAngle Size of the inner cone in degree
  36550. * @param coneOuterAngle Size of the outer cone in degree
  36551. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36552. */
  36553. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36554. /**
  36555. * Gets or sets the inner angle for the directional cone.
  36556. */
  36557. /**
  36558. * Gets or sets the inner angle for the directional cone.
  36559. */
  36560. directionalConeInnerAngle: number;
  36561. /**
  36562. * Gets or sets the outer angle for the directional cone.
  36563. */
  36564. /**
  36565. * Gets or sets the outer angle for the directional cone.
  36566. */
  36567. directionalConeOuterAngle: number;
  36568. /**
  36569. * Sets the position of the emitter if spatial sound is enabled
  36570. * @param newPosition Defines the new posisiton
  36571. */
  36572. setPosition(newPosition: Vector3): void;
  36573. /**
  36574. * Sets the local direction of the emitter if spatial sound is enabled
  36575. * @param newLocalDirection Defines the new local direction
  36576. */
  36577. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36578. private _updateDirection;
  36579. /** @hidden */
  36580. updateDistanceFromListener(): void;
  36581. /**
  36582. * Sets a new custom attenuation function for the sound.
  36583. * @param callback Defines the function used for the attenuation
  36584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36585. */
  36586. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36587. /**
  36588. * Play the sound
  36589. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36590. * @param offset (optional) Start the sound at a specific time in seconds
  36591. * @param length (optional) Sound duration (in seconds)
  36592. */
  36593. play(time?: number, offset?: number, length?: number): void;
  36594. private _onended;
  36595. /**
  36596. * Stop the sound
  36597. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36598. */
  36599. stop(time?: number): void;
  36600. /**
  36601. * Put the sound in pause
  36602. */
  36603. pause(): void;
  36604. /**
  36605. * Sets a dedicated volume for this sounds
  36606. * @param newVolume Define the new volume of the sound
  36607. * @param time Define time for gradual change to new volume
  36608. */
  36609. setVolume(newVolume: number, time?: number): void;
  36610. /**
  36611. * Set the sound play back rate
  36612. * @param newPlaybackRate Define the playback rate the sound should be played at
  36613. */
  36614. setPlaybackRate(newPlaybackRate: number): void;
  36615. /**
  36616. * Gets the volume of the sound.
  36617. * @returns the volume of the sound
  36618. */
  36619. getVolume(): number;
  36620. /**
  36621. * Attach the sound to a dedicated mesh
  36622. * @param transformNode The transform node to connect the sound with
  36623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36624. */
  36625. attachToMesh(transformNode: TransformNode): void;
  36626. /**
  36627. * Detach the sound from the previously attached mesh
  36628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36629. */
  36630. detachFromMesh(): void;
  36631. private _onRegisterAfterWorldMatrixUpdate;
  36632. /**
  36633. * Clone the current sound in the scene.
  36634. * @returns the new sound clone
  36635. */
  36636. clone(): Nullable<Sound>;
  36637. /**
  36638. * Gets the current underlying audio buffer containing the data
  36639. * @returns the audio buffer
  36640. */
  36641. getAudioBuffer(): Nullable<AudioBuffer>;
  36642. /**
  36643. * Serializes the Sound in a JSON representation
  36644. * @returns the JSON representation of the sound
  36645. */
  36646. serialize(): any;
  36647. /**
  36648. * Parse a JSON representation of a sound to innstantiate in a given scene
  36649. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36650. * @param scene Define the scene the new parsed sound should be created in
  36651. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36652. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36653. * @returns the newly parsed sound
  36654. */
  36655. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36656. }
  36657. }
  36658. declare module "babylonjs/Actions/directAudioActions" {
  36659. import { Action } from "babylonjs/Actions/action";
  36660. import { Condition } from "babylonjs/Actions/condition";
  36661. import { Sound } from "babylonjs/Audio/sound";
  36662. /**
  36663. * This defines an action helpful to play a defined sound on a triggered action.
  36664. */
  36665. export class PlaySoundAction extends Action {
  36666. private _sound;
  36667. /**
  36668. * Instantiate the action
  36669. * @param triggerOptions defines the trigger options
  36670. * @param sound defines the sound to play
  36671. * @param condition defines the trigger related conditions
  36672. */
  36673. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36674. /** @hidden */
  36675. _prepare(): void;
  36676. /**
  36677. * Execute the action and play the sound.
  36678. */
  36679. execute(): void;
  36680. /**
  36681. * Serializes the actions and its related information.
  36682. * @param parent defines the object to serialize in
  36683. * @returns the serialized object
  36684. */
  36685. serialize(parent: any): any;
  36686. }
  36687. /**
  36688. * This defines an action helpful to stop a defined sound on a triggered action.
  36689. */
  36690. export class StopSoundAction extends Action {
  36691. private _sound;
  36692. /**
  36693. * Instantiate the action
  36694. * @param triggerOptions defines the trigger options
  36695. * @param sound defines the sound to stop
  36696. * @param condition defines the trigger related conditions
  36697. */
  36698. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36699. /** @hidden */
  36700. _prepare(): void;
  36701. /**
  36702. * Execute the action and stop the sound.
  36703. */
  36704. execute(): void;
  36705. /**
  36706. * Serializes the actions and its related information.
  36707. * @param parent defines the object to serialize in
  36708. * @returns the serialized object
  36709. */
  36710. serialize(parent: any): any;
  36711. }
  36712. }
  36713. declare module "babylonjs/Actions/interpolateValueAction" {
  36714. import { Action } from "babylonjs/Actions/action";
  36715. import { Condition } from "babylonjs/Actions/condition";
  36716. import { Observable } from "babylonjs/Misc/observable";
  36717. /**
  36718. * This defines an action responsible to change the value of a property
  36719. * by interpolating between its current value and the newly set one once triggered.
  36720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36721. */
  36722. export class InterpolateValueAction extends Action {
  36723. /**
  36724. * Defines the path of the property where the value should be interpolated
  36725. */
  36726. propertyPath: string;
  36727. /**
  36728. * Defines the target value at the end of the interpolation.
  36729. */
  36730. value: any;
  36731. /**
  36732. * Defines the time it will take for the property to interpolate to the value.
  36733. */
  36734. duration: number;
  36735. /**
  36736. * Defines if the other scene animations should be stopped when the action has been triggered
  36737. */
  36738. stopOtherAnimations?: boolean;
  36739. /**
  36740. * Defines a callback raised once the interpolation animation has been done.
  36741. */
  36742. onInterpolationDone?: () => void;
  36743. /**
  36744. * Observable triggered once the interpolation animation has been done.
  36745. */
  36746. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36747. private _target;
  36748. private _effectiveTarget;
  36749. private _property;
  36750. /**
  36751. * Instantiate the action
  36752. * @param triggerOptions defines the trigger options
  36753. * @param target defines the object containing the value to interpolate
  36754. * @param propertyPath defines the path to the property in the target object
  36755. * @param value defines the target value at the end of the interpolation
  36756. * @param duration deines the time it will take for the property to interpolate to the value.
  36757. * @param condition defines the trigger related conditions
  36758. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36759. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36760. */
  36761. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36762. /** @hidden */
  36763. _prepare(): void;
  36764. /**
  36765. * Execute the action starts the value interpolation.
  36766. */
  36767. execute(): void;
  36768. /**
  36769. * Serializes the actions and its related information.
  36770. * @param parent defines the object to serialize in
  36771. * @returns the serialized object
  36772. */
  36773. serialize(parent: any): any;
  36774. }
  36775. }
  36776. declare module "babylonjs/Actions/index" {
  36777. export * from "babylonjs/Actions/abstractActionManager";
  36778. export * from "babylonjs/Actions/action";
  36779. export * from "babylonjs/Actions/actionEvent";
  36780. export * from "babylonjs/Actions/actionManager";
  36781. export * from "babylonjs/Actions/condition";
  36782. export * from "babylonjs/Actions/directActions";
  36783. export * from "babylonjs/Actions/directAudioActions";
  36784. export * from "babylonjs/Actions/interpolateValueAction";
  36785. }
  36786. declare module "babylonjs/Animations/index" {
  36787. export * from "babylonjs/Animations/animatable";
  36788. export * from "babylonjs/Animations/animation";
  36789. export * from "babylonjs/Animations/animationGroup";
  36790. export * from "babylonjs/Animations/animationPropertiesOverride";
  36791. export * from "babylonjs/Animations/easing";
  36792. export * from "babylonjs/Animations/runtimeAnimation";
  36793. export * from "babylonjs/Animations/animationEvent";
  36794. export * from "babylonjs/Animations/animationGroup";
  36795. export * from "babylonjs/Animations/animationKey";
  36796. export * from "babylonjs/Animations/animationRange";
  36797. export * from "babylonjs/Animations/animatable.interface";
  36798. }
  36799. declare module "babylonjs/Audio/soundTrack" {
  36800. import { Sound } from "babylonjs/Audio/sound";
  36801. import { Analyser } from "babylonjs/Audio/analyser";
  36802. import { Scene } from "babylonjs/scene";
  36803. /**
  36804. * Options allowed during the creation of a sound track.
  36805. */
  36806. export interface ISoundTrackOptions {
  36807. /**
  36808. * The volume the sound track should take during creation
  36809. */
  36810. volume?: number;
  36811. /**
  36812. * Define if the sound track is the main sound track of the scene
  36813. */
  36814. mainTrack?: boolean;
  36815. }
  36816. /**
  36817. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36818. * It will be also used in a future release to apply effects on a specific track.
  36819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36820. */
  36821. export class SoundTrack {
  36822. /**
  36823. * The unique identifier of the sound track in the scene.
  36824. */
  36825. id: number;
  36826. /**
  36827. * The list of sounds included in the sound track.
  36828. */
  36829. soundCollection: Array<Sound>;
  36830. private _outputAudioNode;
  36831. private _scene;
  36832. private _isMainTrack;
  36833. private _connectedAnalyser;
  36834. private _options;
  36835. private _isInitialized;
  36836. /**
  36837. * Creates a new sound track.
  36838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36839. * @param scene Define the scene the sound track belongs to
  36840. * @param options
  36841. */
  36842. constructor(scene: Scene, options?: ISoundTrackOptions);
  36843. private _initializeSoundTrackAudioGraph;
  36844. /**
  36845. * Release the sound track and its associated resources
  36846. */
  36847. dispose(): void;
  36848. /**
  36849. * Adds a sound to this sound track
  36850. * @param sound define the cound to add
  36851. * @ignoreNaming
  36852. */
  36853. AddSound(sound: Sound): void;
  36854. /**
  36855. * Removes a sound to this sound track
  36856. * @param sound define the cound to remove
  36857. * @ignoreNaming
  36858. */
  36859. RemoveSound(sound: Sound): void;
  36860. /**
  36861. * Set a global volume for the full sound track.
  36862. * @param newVolume Define the new volume of the sound track
  36863. */
  36864. setVolume(newVolume: number): void;
  36865. /**
  36866. * Switch the panning model to HRTF:
  36867. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36869. */
  36870. switchPanningModelToHRTF(): void;
  36871. /**
  36872. * Switch the panning model to Equal Power:
  36873. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36875. */
  36876. switchPanningModelToEqualPower(): void;
  36877. /**
  36878. * Connect the sound track to an audio analyser allowing some amazing
  36879. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36881. * @param analyser The analyser to connect to the engine
  36882. */
  36883. connectToAnalyser(analyser: Analyser): void;
  36884. }
  36885. }
  36886. declare module "babylonjs/Audio/audioSceneComponent" {
  36887. import { Sound } from "babylonjs/Audio/sound";
  36888. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36889. import { Nullable } from "babylonjs/types";
  36890. import { Vector3 } from "babylonjs/Maths/math.vector";
  36891. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36892. import { Scene } from "babylonjs/scene";
  36893. import { AbstractScene } from "babylonjs/abstractScene";
  36894. import "babylonjs/Audio/audioEngine";
  36895. module "babylonjs/abstractScene" {
  36896. interface AbstractScene {
  36897. /**
  36898. * The list of sounds used in the scene.
  36899. */
  36900. sounds: Nullable<Array<Sound>>;
  36901. }
  36902. }
  36903. module "babylonjs/scene" {
  36904. interface Scene {
  36905. /**
  36906. * @hidden
  36907. * Backing field
  36908. */
  36909. _mainSoundTrack: SoundTrack;
  36910. /**
  36911. * The main sound track played by the scene.
  36912. * It cotains your primary collection of sounds.
  36913. */
  36914. mainSoundTrack: SoundTrack;
  36915. /**
  36916. * The list of sound tracks added to the scene
  36917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36918. */
  36919. soundTracks: Nullable<Array<SoundTrack>>;
  36920. /**
  36921. * Gets a sound using a given name
  36922. * @param name defines the name to search for
  36923. * @return the found sound or null if not found at all.
  36924. */
  36925. getSoundByName(name: string): Nullable<Sound>;
  36926. /**
  36927. * Gets or sets if audio support is enabled
  36928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36929. */
  36930. audioEnabled: boolean;
  36931. /**
  36932. * Gets or sets if audio will be output to headphones
  36933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36934. */
  36935. headphone: boolean;
  36936. /**
  36937. * Gets or sets custom audio listener position provider
  36938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36939. */
  36940. audioListenerPositionProvider: Nullable<() => Vector3>;
  36941. /**
  36942. * Gets or sets a refresh rate when using 3D audio positioning
  36943. */
  36944. audioPositioningRefreshRate: number;
  36945. }
  36946. }
  36947. /**
  36948. * Defines the sound scene component responsible to manage any sounds
  36949. * in a given scene.
  36950. */
  36951. export class AudioSceneComponent implements ISceneSerializableComponent {
  36952. /**
  36953. * The component name helpfull to identify the component in the list of scene components.
  36954. */
  36955. readonly name: string;
  36956. /**
  36957. * The scene the component belongs to.
  36958. */
  36959. scene: Scene;
  36960. private _audioEnabled;
  36961. /**
  36962. * Gets whether audio is enabled or not.
  36963. * Please use related enable/disable method to switch state.
  36964. */
  36965. readonly audioEnabled: boolean;
  36966. private _headphone;
  36967. /**
  36968. * Gets whether audio is outputing to headphone or not.
  36969. * Please use the according Switch methods to change output.
  36970. */
  36971. readonly headphone: boolean;
  36972. /**
  36973. * Gets or sets a refresh rate when using 3D audio positioning
  36974. */
  36975. audioPositioningRefreshRate: number;
  36976. private _audioListenerPositionProvider;
  36977. /**
  36978. * Gets the current audio listener position provider
  36979. */
  36980. /**
  36981. * Sets a custom listener position for all sounds in the scene
  36982. * By default, this is the position of the first active camera
  36983. */
  36984. audioListenerPositionProvider: Nullable<() => Vector3>;
  36985. /**
  36986. * Creates a new instance of the component for the given scene
  36987. * @param scene Defines the scene to register the component in
  36988. */
  36989. constructor(scene: Scene);
  36990. /**
  36991. * Registers the component in a given scene
  36992. */
  36993. register(): void;
  36994. /**
  36995. * Rebuilds the elements related to this component in case of
  36996. * context lost for instance.
  36997. */
  36998. rebuild(): void;
  36999. /**
  37000. * Serializes the component data to the specified json object
  37001. * @param serializationObject The object to serialize to
  37002. */
  37003. serialize(serializationObject: any): void;
  37004. /**
  37005. * Adds all the elements from the container to the scene
  37006. * @param container the container holding the elements
  37007. */
  37008. addFromContainer(container: AbstractScene): void;
  37009. /**
  37010. * Removes all the elements in the container from the scene
  37011. * @param container contains the elements to remove
  37012. * @param dispose if the removed element should be disposed (default: false)
  37013. */
  37014. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37015. /**
  37016. * Disposes the component and the associated ressources.
  37017. */
  37018. dispose(): void;
  37019. /**
  37020. * Disables audio in the associated scene.
  37021. */
  37022. disableAudio(): void;
  37023. /**
  37024. * Enables audio in the associated scene.
  37025. */
  37026. enableAudio(): void;
  37027. /**
  37028. * Switch audio to headphone output.
  37029. */
  37030. switchAudioModeForHeadphones(): void;
  37031. /**
  37032. * Switch audio to normal speakers.
  37033. */
  37034. switchAudioModeForNormalSpeakers(): void;
  37035. private _cachedCameraDirection;
  37036. private _cachedCameraPosition;
  37037. private _lastCheck;
  37038. private _afterRender;
  37039. }
  37040. }
  37041. declare module "babylonjs/Audio/weightedsound" {
  37042. import { Sound } from "babylonjs/Audio/sound";
  37043. /**
  37044. * Wraps one or more Sound objects and selects one with random weight for playback.
  37045. */
  37046. export class WeightedSound {
  37047. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37048. loop: boolean;
  37049. private _coneInnerAngle;
  37050. private _coneOuterAngle;
  37051. private _volume;
  37052. /** A Sound is currently playing. */
  37053. isPlaying: boolean;
  37054. /** A Sound is currently paused. */
  37055. isPaused: boolean;
  37056. private _sounds;
  37057. private _weights;
  37058. private _currentIndex?;
  37059. /**
  37060. * Creates a new WeightedSound from the list of sounds given.
  37061. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37062. * @param sounds Array of Sounds that will be selected from.
  37063. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37064. */
  37065. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37066. /**
  37067. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37068. */
  37069. /**
  37070. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37071. */
  37072. directionalConeInnerAngle: number;
  37073. /**
  37074. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37075. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37076. */
  37077. /**
  37078. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37079. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37080. */
  37081. directionalConeOuterAngle: number;
  37082. /**
  37083. * Playback volume.
  37084. */
  37085. /**
  37086. * Playback volume.
  37087. */
  37088. volume: number;
  37089. private _onended;
  37090. /**
  37091. * Suspend playback
  37092. */
  37093. pause(): void;
  37094. /**
  37095. * Stop playback
  37096. */
  37097. stop(): void;
  37098. /**
  37099. * Start playback.
  37100. * @param startOffset Position the clip head at a specific time in seconds.
  37101. */
  37102. play(startOffset?: number): void;
  37103. }
  37104. }
  37105. declare module "babylonjs/Audio/index" {
  37106. export * from "babylonjs/Audio/analyser";
  37107. export * from "babylonjs/Audio/audioEngine";
  37108. export * from "babylonjs/Audio/audioSceneComponent";
  37109. export * from "babylonjs/Audio/sound";
  37110. export * from "babylonjs/Audio/soundTrack";
  37111. export * from "babylonjs/Audio/weightedsound";
  37112. }
  37113. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37114. import { Behavior } from "babylonjs/Behaviors/behavior";
  37115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37116. import { BackEase } from "babylonjs/Animations/easing";
  37117. /**
  37118. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37120. */
  37121. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37122. /**
  37123. * Gets the name of the behavior.
  37124. */
  37125. readonly name: string;
  37126. /**
  37127. * The easing function used by animations
  37128. */
  37129. static EasingFunction: BackEase;
  37130. /**
  37131. * The easing mode used by animations
  37132. */
  37133. static EasingMode: number;
  37134. /**
  37135. * The duration of the animation, in milliseconds
  37136. */
  37137. transitionDuration: number;
  37138. /**
  37139. * Length of the distance animated by the transition when lower radius is reached
  37140. */
  37141. lowerRadiusTransitionRange: number;
  37142. /**
  37143. * Length of the distance animated by the transition when upper radius is reached
  37144. */
  37145. upperRadiusTransitionRange: number;
  37146. private _autoTransitionRange;
  37147. /**
  37148. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37149. */
  37150. /**
  37151. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37152. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37153. */
  37154. autoTransitionRange: boolean;
  37155. private _attachedCamera;
  37156. private _onAfterCheckInputsObserver;
  37157. private _onMeshTargetChangedObserver;
  37158. /**
  37159. * Initializes the behavior.
  37160. */
  37161. init(): void;
  37162. /**
  37163. * Attaches the behavior to its arc rotate camera.
  37164. * @param camera Defines the camera to attach the behavior to
  37165. */
  37166. attach(camera: ArcRotateCamera): void;
  37167. /**
  37168. * Detaches the behavior from its current arc rotate camera.
  37169. */
  37170. detach(): void;
  37171. private _radiusIsAnimating;
  37172. private _radiusBounceTransition;
  37173. private _animatables;
  37174. private _cachedWheelPrecision;
  37175. /**
  37176. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37177. * @param radiusLimit The limit to check against.
  37178. * @return Bool to indicate if at limit.
  37179. */
  37180. private _isRadiusAtLimit;
  37181. /**
  37182. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37183. * @param radiusDelta The delta by which to animate to. Can be negative.
  37184. */
  37185. private _applyBoundRadiusAnimation;
  37186. /**
  37187. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37188. */
  37189. protected _clearAnimationLocks(): void;
  37190. /**
  37191. * Stops and removes all animations that have been applied to the camera
  37192. */
  37193. stopAllAnimations(): void;
  37194. }
  37195. }
  37196. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37197. import { Behavior } from "babylonjs/Behaviors/behavior";
  37198. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37199. import { ExponentialEase } from "babylonjs/Animations/easing";
  37200. import { Nullable } from "babylonjs/types";
  37201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37202. import { Vector3 } from "babylonjs/Maths/math.vector";
  37203. /**
  37204. * 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.
  37205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37206. */
  37207. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37208. /**
  37209. * Gets the name of the behavior.
  37210. */
  37211. readonly name: string;
  37212. private _mode;
  37213. private _radiusScale;
  37214. private _positionScale;
  37215. private _defaultElevation;
  37216. private _elevationReturnTime;
  37217. private _elevationReturnWaitTime;
  37218. private _zoomStopsAnimation;
  37219. private _framingTime;
  37220. /**
  37221. * The easing function used by animations
  37222. */
  37223. static EasingFunction: ExponentialEase;
  37224. /**
  37225. * The easing mode used by animations
  37226. */
  37227. static EasingMode: number;
  37228. /**
  37229. * Sets the current mode used by the behavior
  37230. */
  37231. /**
  37232. * Gets current mode used by the behavior.
  37233. */
  37234. mode: number;
  37235. /**
  37236. * Sets the scale applied to the radius (1 by default)
  37237. */
  37238. /**
  37239. * Gets the scale applied to the radius
  37240. */
  37241. radiusScale: number;
  37242. /**
  37243. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37244. */
  37245. /**
  37246. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37247. */
  37248. positionScale: number;
  37249. /**
  37250. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37251. * behaviour is triggered, in radians.
  37252. */
  37253. /**
  37254. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37255. * behaviour is triggered, in radians.
  37256. */
  37257. defaultElevation: number;
  37258. /**
  37259. * Sets the time (in milliseconds) taken to return to the default beta position.
  37260. * Negative value indicates camera should not return to default.
  37261. */
  37262. /**
  37263. * Gets the time (in milliseconds) taken to return to the default beta position.
  37264. * Negative value indicates camera should not return to default.
  37265. */
  37266. elevationReturnTime: number;
  37267. /**
  37268. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37269. */
  37270. /**
  37271. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37272. */
  37273. elevationReturnWaitTime: number;
  37274. /**
  37275. * Sets the flag that indicates if user zooming should stop animation.
  37276. */
  37277. /**
  37278. * Gets the flag that indicates if user zooming should stop animation.
  37279. */
  37280. zoomStopsAnimation: boolean;
  37281. /**
  37282. * Sets the transition time when framing the mesh, in milliseconds
  37283. */
  37284. /**
  37285. * Gets the transition time when framing the mesh, in milliseconds
  37286. */
  37287. framingTime: number;
  37288. /**
  37289. * Define if the behavior should automatically change the configured
  37290. * camera limits and sensibilities.
  37291. */
  37292. autoCorrectCameraLimitsAndSensibility: boolean;
  37293. private _onPrePointerObservableObserver;
  37294. private _onAfterCheckInputsObserver;
  37295. private _onMeshTargetChangedObserver;
  37296. private _attachedCamera;
  37297. private _isPointerDown;
  37298. private _lastInteractionTime;
  37299. /**
  37300. * Initializes the behavior.
  37301. */
  37302. init(): void;
  37303. /**
  37304. * Attaches the behavior to its arc rotate camera.
  37305. * @param camera Defines the camera to attach the behavior to
  37306. */
  37307. attach(camera: ArcRotateCamera): void;
  37308. /**
  37309. * Detaches the behavior from its current arc rotate camera.
  37310. */
  37311. detach(): void;
  37312. private _animatables;
  37313. private _betaIsAnimating;
  37314. private _betaTransition;
  37315. private _radiusTransition;
  37316. private _vectorTransition;
  37317. /**
  37318. * Targets the given mesh and updates zoom level accordingly.
  37319. * @param mesh The mesh to target.
  37320. * @param radius Optional. If a cached radius position already exists, overrides default.
  37321. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37322. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37323. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37324. */
  37325. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37326. /**
  37327. * Targets the given mesh with its children and updates zoom level accordingly.
  37328. * @param mesh The mesh to target.
  37329. * @param radius Optional. If a cached radius position already exists, overrides default.
  37330. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37331. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37332. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37333. */
  37334. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37335. /**
  37336. * Targets the given meshes with their children and updates zoom level accordingly.
  37337. * @param meshes The mesh to target.
  37338. * @param radius Optional. If a cached radius position already exists, overrides default.
  37339. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37340. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37341. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37342. */
  37343. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37344. /**
  37345. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37346. * @param minimumWorld Determines the smaller position of the bounding box extend
  37347. * @param maximumWorld Determines the bigger position of the bounding box extend
  37348. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37349. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37350. */
  37351. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37352. /**
  37353. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37354. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37355. * frustum width.
  37356. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37357. * to fully enclose the mesh in the viewing frustum.
  37358. */
  37359. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37360. /**
  37361. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37362. * is automatically returned to its default position (expected to be above ground plane).
  37363. */
  37364. private _maintainCameraAboveGround;
  37365. /**
  37366. * Returns the frustum slope based on the canvas ratio and camera FOV
  37367. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37368. */
  37369. private _getFrustumSlope;
  37370. /**
  37371. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37372. */
  37373. private _clearAnimationLocks;
  37374. /**
  37375. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37376. */
  37377. private _applyUserInteraction;
  37378. /**
  37379. * Stops and removes all animations that have been applied to the camera
  37380. */
  37381. stopAllAnimations(): void;
  37382. /**
  37383. * Gets a value indicating if the user is moving the camera
  37384. */
  37385. readonly isUserIsMoving: boolean;
  37386. /**
  37387. * The camera can move all the way towards the mesh.
  37388. */
  37389. static IgnoreBoundsSizeMode: number;
  37390. /**
  37391. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37392. */
  37393. static FitFrustumSidesMode: number;
  37394. }
  37395. }
  37396. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37397. import { Nullable } from "babylonjs/types";
  37398. import { Camera } from "babylonjs/Cameras/camera";
  37399. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37400. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37401. /**
  37402. * Base class for Camera Pointer Inputs.
  37403. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37404. * for example usage.
  37405. */
  37406. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37407. /**
  37408. * Defines the camera the input is attached to.
  37409. */
  37410. abstract camera: Camera;
  37411. /**
  37412. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37413. */
  37414. protected _altKey: boolean;
  37415. protected _ctrlKey: boolean;
  37416. protected _metaKey: boolean;
  37417. protected _shiftKey: boolean;
  37418. /**
  37419. * Which mouse buttons were pressed at time of last mouse event.
  37420. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37421. */
  37422. protected _buttonsPressed: number;
  37423. /**
  37424. * Defines the buttons associated with the input to handle camera move.
  37425. */
  37426. buttons: number[];
  37427. /**
  37428. * Attach the input controls to a specific dom element to get the input from.
  37429. * @param element Defines the element the controls should be listened from
  37430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37431. */
  37432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37433. /**
  37434. * Detach the current controls from the specified dom element.
  37435. * @param element Defines the element to stop listening the inputs from
  37436. */
  37437. detachControl(element: Nullable<HTMLElement>): void;
  37438. /**
  37439. * Gets the class name of the current input.
  37440. * @returns the class name
  37441. */
  37442. getClassName(): string;
  37443. /**
  37444. * Get the friendly name associated with the input class.
  37445. * @returns the input friendly name
  37446. */
  37447. getSimpleName(): string;
  37448. /**
  37449. * Called on pointer POINTERDOUBLETAP event.
  37450. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37451. */
  37452. protected onDoubleTap(type: string): void;
  37453. /**
  37454. * Called on pointer POINTERMOVE event if only a single touch is active.
  37455. * Override this method to provide functionality.
  37456. */
  37457. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37458. /**
  37459. * Called on pointer POINTERMOVE event if multiple touches are active.
  37460. * Override this method to provide functionality.
  37461. */
  37462. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37463. /**
  37464. * Called on JS contextmenu event.
  37465. * Override this method to provide functionality.
  37466. */
  37467. protected onContextMenu(evt: PointerEvent): void;
  37468. /**
  37469. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37470. * press.
  37471. * Override this method to provide functionality.
  37472. */
  37473. protected onButtonDown(evt: PointerEvent): void;
  37474. /**
  37475. * Called each time a new POINTERUP event occurs. Ie, for each button
  37476. * release.
  37477. * Override this method to provide functionality.
  37478. */
  37479. protected onButtonUp(evt: PointerEvent): void;
  37480. /**
  37481. * Called when window becomes inactive.
  37482. * Override this method to provide functionality.
  37483. */
  37484. protected onLostFocus(): void;
  37485. private _pointerInput;
  37486. private _observer;
  37487. private _onLostFocus;
  37488. private pointA;
  37489. private pointB;
  37490. }
  37491. }
  37492. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37493. import { Nullable } from "babylonjs/types";
  37494. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37495. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37496. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37497. /**
  37498. * Manage the pointers inputs to control an arc rotate camera.
  37499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37500. */
  37501. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37502. /**
  37503. * Defines the camera the input is attached to.
  37504. */
  37505. camera: ArcRotateCamera;
  37506. /**
  37507. * Gets the class name of the current input.
  37508. * @returns the class name
  37509. */
  37510. getClassName(): string;
  37511. /**
  37512. * Defines the buttons associated with the input to handle camera move.
  37513. */
  37514. buttons: number[];
  37515. /**
  37516. * Defines the pointer angular sensibility along the X axis or how fast is
  37517. * the camera rotating.
  37518. */
  37519. angularSensibilityX: number;
  37520. /**
  37521. * Defines the pointer angular sensibility along the Y axis or how fast is
  37522. * the camera rotating.
  37523. */
  37524. angularSensibilityY: number;
  37525. /**
  37526. * Defines the pointer pinch precision or how fast is the camera zooming.
  37527. */
  37528. pinchPrecision: number;
  37529. /**
  37530. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37531. * from 0.
  37532. * It defines the percentage of current camera.radius to use as delta when
  37533. * pinch zoom is used.
  37534. */
  37535. pinchDeltaPercentage: number;
  37536. /**
  37537. * Defines the pointer panning sensibility or how fast is the camera moving.
  37538. */
  37539. panningSensibility: number;
  37540. /**
  37541. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37542. */
  37543. multiTouchPanning: boolean;
  37544. /**
  37545. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37546. * zoom (pinch) through multitouch.
  37547. */
  37548. multiTouchPanAndZoom: boolean;
  37549. /**
  37550. * Revers pinch action direction.
  37551. */
  37552. pinchInwards: boolean;
  37553. private _isPanClick;
  37554. private _twoFingerActivityCount;
  37555. private _isPinching;
  37556. /**
  37557. * Called on pointer POINTERMOVE event if only a single touch is active.
  37558. */
  37559. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37560. /**
  37561. * Called on pointer POINTERDOUBLETAP event.
  37562. */
  37563. protected onDoubleTap(type: string): void;
  37564. /**
  37565. * Called on pointer POINTERMOVE event if multiple touches are active.
  37566. */
  37567. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37568. /**
  37569. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37570. * press.
  37571. */
  37572. protected onButtonDown(evt: PointerEvent): void;
  37573. /**
  37574. * Called each time a new POINTERUP event occurs. Ie, for each button
  37575. * release.
  37576. */
  37577. protected onButtonUp(evt: PointerEvent): void;
  37578. /**
  37579. * Called when window becomes inactive.
  37580. */
  37581. protected onLostFocus(): void;
  37582. }
  37583. }
  37584. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37585. import { Nullable } from "babylonjs/types";
  37586. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37587. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37588. /**
  37589. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37591. */
  37592. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37593. /**
  37594. * Defines the camera the input is attached to.
  37595. */
  37596. camera: ArcRotateCamera;
  37597. /**
  37598. * Defines the list of key codes associated with the up action (increase alpha)
  37599. */
  37600. keysUp: number[];
  37601. /**
  37602. * Defines the list of key codes associated with the down action (decrease alpha)
  37603. */
  37604. keysDown: number[];
  37605. /**
  37606. * Defines the list of key codes associated with the left action (increase beta)
  37607. */
  37608. keysLeft: number[];
  37609. /**
  37610. * Defines the list of key codes associated with the right action (decrease beta)
  37611. */
  37612. keysRight: number[];
  37613. /**
  37614. * Defines the list of key codes associated with the reset action.
  37615. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37616. */
  37617. keysReset: number[];
  37618. /**
  37619. * Defines the panning sensibility of the inputs.
  37620. * (How fast is the camera paning)
  37621. */
  37622. panningSensibility: number;
  37623. /**
  37624. * Defines the zooming sensibility of the inputs.
  37625. * (How fast is the camera zooming)
  37626. */
  37627. zoomingSensibility: number;
  37628. /**
  37629. * Defines wether maintaining the alt key down switch the movement mode from
  37630. * orientation to zoom.
  37631. */
  37632. useAltToZoom: boolean;
  37633. /**
  37634. * Rotation speed of the camera
  37635. */
  37636. angularSpeed: number;
  37637. private _keys;
  37638. private _ctrlPressed;
  37639. private _altPressed;
  37640. private _onCanvasBlurObserver;
  37641. private _onKeyboardObserver;
  37642. private _engine;
  37643. private _scene;
  37644. /**
  37645. * Attach the input controls to a specific dom element to get the input from.
  37646. * @param element Defines the element the controls should be listened from
  37647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37648. */
  37649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37650. /**
  37651. * Detach the current controls from the specified dom element.
  37652. * @param element Defines the element to stop listening the inputs from
  37653. */
  37654. detachControl(element: Nullable<HTMLElement>): void;
  37655. /**
  37656. * Update the current camera state depending on the inputs that have been used this frame.
  37657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37658. */
  37659. checkInputs(): void;
  37660. /**
  37661. * Gets the class name of the current intput.
  37662. * @returns the class name
  37663. */
  37664. getClassName(): string;
  37665. /**
  37666. * Get the friendly name associated with the input class.
  37667. * @returns the input friendly name
  37668. */
  37669. getSimpleName(): string;
  37670. }
  37671. }
  37672. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37673. import { Nullable } from "babylonjs/types";
  37674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37675. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37676. /**
  37677. * Manage the mouse wheel inputs to control an arc rotate camera.
  37678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37679. */
  37680. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37681. /**
  37682. * Defines the camera the input is attached to.
  37683. */
  37684. camera: ArcRotateCamera;
  37685. /**
  37686. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37687. */
  37688. wheelPrecision: number;
  37689. /**
  37690. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37691. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37692. */
  37693. wheelDeltaPercentage: number;
  37694. private _wheel;
  37695. private _observer;
  37696. private computeDeltaFromMouseWheelLegacyEvent;
  37697. /**
  37698. * Attach the input controls to a specific dom element to get the input from.
  37699. * @param element Defines the element the controls should be listened from
  37700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37701. */
  37702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37703. /**
  37704. * Detach the current controls from the specified dom element.
  37705. * @param element Defines the element to stop listening the inputs from
  37706. */
  37707. detachControl(element: Nullable<HTMLElement>): void;
  37708. /**
  37709. * Gets the class name of the current intput.
  37710. * @returns the class name
  37711. */
  37712. getClassName(): string;
  37713. /**
  37714. * Get the friendly name associated with the input class.
  37715. * @returns the input friendly name
  37716. */
  37717. getSimpleName(): string;
  37718. }
  37719. }
  37720. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37721. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37722. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37723. /**
  37724. * Default Inputs manager for the ArcRotateCamera.
  37725. * It groups all the default supported inputs for ease of use.
  37726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37727. */
  37728. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37729. /**
  37730. * Instantiates a new ArcRotateCameraInputsManager.
  37731. * @param camera Defines the camera the inputs belong to
  37732. */
  37733. constructor(camera: ArcRotateCamera);
  37734. /**
  37735. * Add mouse wheel input support to the input manager.
  37736. * @returns the current input manager
  37737. */
  37738. addMouseWheel(): ArcRotateCameraInputsManager;
  37739. /**
  37740. * Add pointers input support to the input manager.
  37741. * @returns the current input manager
  37742. */
  37743. addPointers(): ArcRotateCameraInputsManager;
  37744. /**
  37745. * Add keyboard input support to the input manager.
  37746. * @returns the current input manager
  37747. */
  37748. addKeyboard(): ArcRotateCameraInputsManager;
  37749. }
  37750. }
  37751. declare module "babylonjs/Cameras/arcRotateCamera" {
  37752. import { Observable } from "babylonjs/Misc/observable";
  37753. import { Nullable } from "babylonjs/types";
  37754. import { Scene } from "babylonjs/scene";
  37755. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37757. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37758. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37759. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37760. import { Camera } from "babylonjs/Cameras/camera";
  37761. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37762. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37763. import { Collider } from "babylonjs/Collisions/collider";
  37764. /**
  37765. * This represents an orbital type of camera.
  37766. *
  37767. * 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.
  37768. * 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.
  37769. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37770. */
  37771. export class ArcRotateCamera extends TargetCamera {
  37772. /**
  37773. * Defines the rotation angle of the camera along the longitudinal axis.
  37774. */
  37775. alpha: number;
  37776. /**
  37777. * Defines the rotation angle of the camera along the latitudinal axis.
  37778. */
  37779. beta: number;
  37780. /**
  37781. * Defines the radius of the camera from it s target point.
  37782. */
  37783. radius: number;
  37784. protected _target: Vector3;
  37785. protected _targetHost: Nullable<AbstractMesh>;
  37786. /**
  37787. * Defines the target point of the camera.
  37788. * The camera looks towards it form the radius distance.
  37789. */
  37790. target: Vector3;
  37791. /**
  37792. * Define the current local position of the camera in the scene
  37793. */
  37794. position: Vector3;
  37795. protected _upVector: Vector3;
  37796. protected _upToYMatrix: Matrix;
  37797. protected _YToUpMatrix: Matrix;
  37798. /**
  37799. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37800. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37801. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37802. */
  37803. upVector: Vector3;
  37804. /**
  37805. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37806. */
  37807. setMatUp(): void;
  37808. /**
  37809. * Current inertia value on the longitudinal axis.
  37810. * The bigger this number the longer it will take for the camera to stop.
  37811. */
  37812. inertialAlphaOffset: number;
  37813. /**
  37814. * Current inertia value on the latitudinal axis.
  37815. * The bigger this number the longer it will take for the camera to stop.
  37816. */
  37817. inertialBetaOffset: number;
  37818. /**
  37819. * Current inertia value on the radius axis.
  37820. * The bigger this number the longer it will take for the camera to stop.
  37821. */
  37822. inertialRadiusOffset: number;
  37823. /**
  37824. * Minimum allowed angle on the longitudinal axis.
  37825. * This can help limiting how the Camera is able to move in the scene.
  37826. */
  37827. lowerAlphaLimit: Nullable<number>;
  37828. /**
  37829. * Maximum allowed angle on the longitudinal axis.
  37830. * This can help limiting how the Camera is able to move in the scene.
  37831. */
  37832. upperAlphaLimit: Nullable<number>;
  37833. /**
  37834. * Minimum allowed angle on the latitudinal axis.
  37835. * This can help limiting how the Camera is able to move in the scene.
  37836. */
  37837. lowerBetaLimit: number;
  37838. /**
  37839. * Maximum allowed angle on the latitudinal axis.
  37840. * This can help limiting how the Camera is able to move in the scene.
  37841. */
  37842. upperBetaLimit: number;
  37843. /**
  37844. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37845. * This can help limiting how the Camera is able to move in the scene.
  37846. */
  37847. lowerRadiusLimit: Nullable<number>;
  37848. /**
  37849. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37850. * This can help limiting how the Camera is able to move in the scene.
  37851. */
  37852. upperRadiusLimit: Nullable<number>;
  37853. /**
  37854. * Defines the current inertia value used during panning of the camera along the X axis.
  37855. */
  37856. inertialPanningX: number;
  37857. /**
  37858. * Defines the current inertia value used during panning of the camera along the Y axis.
  37859. */
  37860. inertialPanningY: number;
  37861. /**
  37862. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37863. * Basically if your fingers moves away from more than this distance you will be considered
  37864. * in pinch mode.
  37865. */
  37866. pinchToPanMaxDistance: number;
  37867. /**
  37868. * Defines the maximum distance the camera can pan.
  37869. * This could help keeping the cammera always in your scene.
  37870. */
  37871. panningDistanceLimit: Nullable<number>;
  37872. /**
  37873. * Defines the target of the camera before paning.
  37874. */
  37875. panningOriginTarget: Vector3;
  37876. /**
  37877. * Defines the value of the inertia used during panning.
  37878. * 0 would mean stop inertia and one would mean no decelleration at all.
  37879. */
  37880. panningInertia: number;
  37881. /**
  37882. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37883. */
  37884. angularSensibilityX: number;
  37885. /**
  37886. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37887. */
  37888. angularSensibilityY: number;
  37889. /**
  37890. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37891. */
  37892. pinchPrecision: number;
  37893. /**
  37894. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37895. * It will be used instead of pinchDeltaPrecision if different from 0.
  37896. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37897. */
  37898. pinchDeltaPercentage: number;
  37899. /**
  37900. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37901. */
  37902. panningSensibility: number;
  37903. /**
  37904. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37905. */
  37906. keysUp: number[];
  37907. /**
  37908. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37909. */
  37910. keysDown: number[];
  37911. /**
  37912. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37913. */
  37914. keysLeft: number[];
  37915. /**
  37916. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37917. */
  37918. keysRight: number[];
  37919. /**
  37920. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37921. */
  37922. wheelPrecision: number;
  37923. /**
  37924. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37925. * It will be used instead of pinchDeltaPrecision if different from 0.
  37926. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37927. */
  37928. wheelDeltaPercentage: number;
  37929. /**
  37930. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37931. */
  37932. zoomOnFactor: number;
  37933. /**
  37934. * Defines a screen offset for the camera position.
  37935. */
  37936. targetScreenOffset: Vector2;
  37937. /**
  37938. * Allows the camera to be completely reversed.
  37939. * If false the camera can not arrive upside down.
  37940. */
  37941. allowUpsideDown: boolean;
  37942. /**
  37943. * Define if double tap/click is used to restore the previously saved state of the camera.
  37944. */
  37945. useInputToRestoreState: boolean;
  37946. /** @hidden */
  37947. _viewMatrix: Matrix;
  37948. /** @hidden */
  37949. _useCtrlForPanning: boolean;
  37950. /** @hidden */
  37951. _panningMouseButton: number;
  37952. /**
  37953. * Defines the input associated to the camera.
  37954. */
  37955. inputs: ArcRotateCameraInputsManager;
  37956. /** @hidden */
  37957. _reset: () => void;
  37958. /**
  37959. * Defines the allowed panning axis.
  37960. */
  37961. panningAxis: Vector3;
  37962. protected _localDirection: Vector3;
  37963. protected _transformedDirection: Vector3;
  37964. private _bouncingBehavior;
  37965. /**
  37966. * Gets the bouncing behavior of the camera if it has been enabled.
  37967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37968. */
  37969. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37970. /**
  37971. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37972. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37973. */
  37974. useBouncingBehavior: boolean;
  37975. private _framingBehavior;
  37976. /**
  37977. * Gets the framing behavior of the camera if it has been enabled.
  37978. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37979. */
  37980. readonly framingBehavior: Nullable<FramingBehavior>;
  37981. /**
  37982. * Defines if the framing behavior of the camera is enabled on the camera.
  37983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37984. */
  37985. useFramingBehavior: boolean;
  37986. private _autoRotationBehavior;
  37987. /**
  37988. * Gets the auto rotation behavior of the camera if it has been enabled.
  37989. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37990. */
  37991. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37992. /**
  37993. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37995. */
  37996. useAutoRotationBehavior: boolean;
  37997. /**
  37998. * Observable triggered when the mesh target has been changed on the camera.
  37999. */
  38000. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38001. /**
  38002. * Event raised when the camera is colliding with a mesh.
  38003. */
  38004. onCollide: (collidedMesh: AbstractMesh) => void;
  38005. /**
  38006. * Defines whether the camera should check collision with the objects oh the scene.
  38007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38008. */
  38009. checkCollisions: boolean;
  38010. /**
  38011. * Defines the collision radius of the camera.
  38012. * This simulates a sphere around the camera.
  38013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38014. */
  38015. collisionRadius: Vector3;
  38016. protected _collider: Collider;
  38017. protected _previousPosition: Vector3;
  38018. protected _collisionVelocity: Vector3;
  38019. protected _newPosition: Vector3;
  38020. protected _previousAlpha: number;
  38021. protected _previousBeta: number;
  38022. protected _previousRadius: number;
  38023. protected _collisionTriggered: boolean;
  38024. protected _targetBoundingCenter: Nullable<Vector3>;
  38025. private _computationVector;
  38026. /**
  38027. * Instantiates a new ArcRotateCamera in a given scene
  38028. * @param name Defines the name of the camera
  38029. * @param alpha Defines the camera rotation along the logitudinal axis
  38030. * @param beta Defines the camera rotation along the latitudinal axis
  38031. * @param radius Defines the camera distance from its target
  38032. * @param target Defines the camera target
  38033. * @param scene Defines the scene the camera belongs to
  38034. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38035. */
  38036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38037. /** @hidden */
  38038. _initCache(): void;
  38039. /** @hidden */
  38040. _updateCache(ignoreParentClass?: boolean): void;
  38041. protected _getTargetPosition(): Vector3;
  38042. private _storedAlpha;
  38043. private _storedBeta;
  38044. private _storedRadius;
  38045. private _storedTarget;
  38046. private _storedTargetScreenOffset;
  38047. /**
  38048. * Stores the current state of the camera (alpha, beta, radius and target)
  38049. * @returns the camera itself
  38050. */
  38051. storeState(): Camera;
  38052. /**
  38053. * @hidden
  38054. * Restored camera state. You must call storeState() first
  38055. */
  38056. _restoreStateValues(): boolean;
  38057. /** @hidden */
  38058. _isSynchronizedViewMatrix(): boolean;
  38059. /**
  38060. * Attached controls to the current camera.
  38061. * @param element Defines the element the controls should be listened from
  38062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38063. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38064. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38065. */
  38066. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38067. /**
  38068. * Detach the current controls from the camera.
  38069. * The camera will stop reacting to inputs.
  38070. * @param element Defines the element to stop listening the inputs from
  38071. */
  38072. detachControl(element: HTMLElement): void;
  38073. /** @hidden */
  38074. _checkInputs(): void;
  38075. protected _checkLimits(): void;
  38076. /**
  38077. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38078. */
  38079. rebuildAnglesAndRadius(): void;
  38080. /**
  38081. * Use a position to define the current camera related information like alpha, beta and radius
  38082. * @param position Defines the position to set the camera at
  38083. */
  38084. setPosition(position: Vector3): void;
  38085. /**
  38086. * Defines the target the camera should look at.
  38087. * This will automatically adapt alpha beta and radius to fit within the new target.
  38088. * @param target Defines the new target as a Vector or a mesh
  38089. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38090. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38091. */
  38092. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38093. /** @hidden */
  38094. _getViewMatrix(): Matrix;
  38095. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38096. /**
  38097. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38098. * @param meshes Defines the mesh to zoom on
  38099. * @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)
  38100. */
  38101. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38102. /**
  38103. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38104. * The target will be changed but the radius
  38105. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38106. * @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)
  38107. */
  38108. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38109. min: Vector3;
  38110. max: Vector3;
  38111. distance: number;
  38112. }, doNotUpdateMaxZ?: boolean): void;
  38113. /**
  38114. * @override
  38115. * Override Camera.createRigCamera
  38116. */
  38117. createRigCamera(name: string, cameraIndex: number): Camera;
  38118. /**
  38119. * @hidden
  38120. * @override
  38121. * Override Camera._updateRigCameras
  38122. */
  38123. _updateRigCameras(): void;
  38124. /**
  38125. * Destroy the camera and release the current resources hold by it.
  38126. */
  38127. dispose(): void;
  38128. /**
  38129. * Gets the current object class name.
  38130. * @return the class name
  38131. */
  38132. getClassName(): string;
  38133. }
  38134. }
  38135. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38136. import { Behavior } from "babylonjs/Behaviors/behavior";
  38137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38138. /**
  38139. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38141. */
  38142. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38143. /**
  38144. * Gets the name of the behavior.
  38145. */
  38146. readonly name: string;
  38147. private _zoomStopsAnimation;
  38148. private _idleRotationSpeed;
  38149. private _idleRotationWaitTime;
  38150. private _idleRotationSpinupTime;
  38151. /**
  38152. * Sets the flag that indicates if user zooming should stop animation.
  38153. */
  38154. /**
  38155. * Gets the flag that indicates if user zooming should stop animation.
  38156. */
  38157. zoomStopsAnimation: boolean;
  38158. /**
  38159. * Sets the default speed at which the camera rotates around the model.
  38160. */
  38161. /**
  38162. * Gets the default speed at which the camera rotates around the model.
  38163. */
  38164. idleRotationSpeed: number;
  38165. /**
  38166. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38167. */
  38168. /**
  38169. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38170. */
  38171. idleRotationWaitTime: number;
  38172. /**
  38173. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38174. */
  38175. /**
  38176. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38177. */
  38178. idleRotationSpinupTime: number;
  38179. /**
  38180. * Gets a value indicating if the camera is currently rotating because of this behavior
  38181. */
  38182. readonly rotationInProgress: boolean;
  38183. private _onPrePointerObservableObserver;
  38184. private _onAfterCheckInputsObserver;
  38185. private _attachedCamera;
  38186. private _isPointerDown;
  38187. private _lastFrameTime;
  38188. private _lastInteractionTime;
  38189. private _cameraRotationSpeed;
  38190. /**
  38191. * Initializes the behavior.
  38192. */
  38193. init(): void;
  38194. /**
  38195. * Attaches the behavior to its arc rotate camera.
  38196. * @param camera Defines the camera to attach the behavior to
  38197. */
  38198. attach(camera: ArcRotateCamera): void;
  38199. /**
  38200. * Detaches the behavior from its current arc rotate camera.
  38201. */
  38202. detach(): void;
  38203. /**
  38204. * Returns true if user is scrolling.
  38205. * @return true if user is scrolling.
  38206. */
  38207. private _userIsZooming;
  38208. private _lastFrameRadius;
  38209. private _shouldAnimationStopForInteraction;
  38210. /**
  38211. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38212. */
  38213. private _applyUserInteraction;
  38214. private _userIsMoving;
  38215. }
  38216. }
  38217. declare module "babylonjs/Behaviors/Cameras/index" {
  38218. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38219. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38220. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38221. }
  38222. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38223. import { Mesh } from "babylonjs/Meshes/mesh";
  38224. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38225. import { Behavior } from "babylonjs/Behaviors/behavior";
  38226. /**
  38227. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38228. */
  38229. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38230. private ui;
  38231. /**
  38232. * The name of the behavior
  38233. */
  38234. name: string;
  38235. /**
  38236. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38237. */
  38238. distanceAwayFromFace: number;
  38239. /**
  38240. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38241. */
  38242. distanceAwayFromBottomOfFace: number;
  38243. private _faceVectors;
  38244. private _target;
  38245. private _scene;
  38246. private _onRenderObserver;
  38247. private _tmpMatrix;
  38248. private _tmpVector;
  38249. /**
  38250. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38251. * @param ui The transform node that should be attched to the mesh
  38252. */
  38253. constructor(ui: TransformNode);
  38254. /**
  38255. * Initializes the behavior
  38256. */
  38257. init(): void;
  38258. private _closestFace;
  38259. private _zeroVector;
  38260. private _lookAtTmpMatrix;
  38261. private _lookAtToRef;
  38262. /**
  38263. * Attaches the AttachToBoxBehavior to the passed in mesh
  38264. * @param target The mesh that the specified node will be attached to
  38265. */
  38266. attach(target: Mesh): void;
  38267. /**
  38268. * Detaches the behavior from the mesh
  38269. */
  38270. detach(): void;
  38271. }
  38272. }
  38273. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38274. import { Behavior } from "babylonjs/Behaviors/behavior";
  38275. import { Mesh } from "babylonjs/Meshes/mesh";
  38276. /**
  38277. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38278. */
  38279. export class FadeInOutBehavior implements Behavior<Mesh> {
  38280. /**
  38281. * Time in milliseconds to delay before fading in (Default: 0)
  38282. */
  38283. delay: number;
  38284. /**
  38285. * Time in milliseconds for the mesh to fade in (Default: 300)
  38286. */
  38287. fadeInTime: number;
  38288. private _millisecondsPerFrame;
  38289. private _hovered;
  38290. private _hoverValue;
  38291. private _ownerNode;
  38292. /**
  38293. * Instatiates the FadeInOutBehavior
  38294. */
  38295. constructor();
  38296. /**
  38297. * The name of the behavior
  38298. */
  38299. readonly name: string;
  38300. /**
  38301. * Initializes the behavior
  38302. */
  38303. init(): void;
  38304. /**
  38305. * Attaches the fade behavior on the passed in mesh
  38306. * @param ownerNode The mesh that will be faded in/out once attached
  38307. */
  38308. attach(ownerNode: Mesh): void;
  38309. /**
  38310. * Detaches the behavior from the mesh
  38311. */
  38312. detach(): void;
  38313. /**
  38314. * Triggers the mesh to begin fading in or out
  38315. * @param value if the object should fade in or out (true to fade in)
  38316. */
  38317. fadeIn(value: boolean): void;
  38318. private _update;
  38319. private _setAllVisibility;
  38320. }
  38321. }
  38322. declare module "babylonjs/Misc/pivotTools" {
  38323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38324. /**
  38325. * Class containing a set of static utilities functions for managing Pivots
  38326. * @hidden
  38327. */
  38328. export class PivotTools {
  38329. private static _PivotCached;
  38330. private static _OldPivotPoint;
  38331. private static _PivotTranslation;
  38332. private static _PivotTmpVector;
  38333. /** @hidden */
  38334. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38335. /** @hidden */
  38336. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38337. }
  38338. }
  38339. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38340. import { Scene } from "babylonjs/scene";
  38341. import { Vector4 } from "babylonjs/Maths/math.vector";
  38342. import { Mesh } from "babylonjs/Meshes/mesh";
  38343. import { Nullable } from "babylonjs/types";
  38344. import { Plane } from "babylonjs/Maths/math.plane";
  38345. /**
  38346. * Class containing static functions to help procedurally build meshes
  38347. */
  38348. export class PlaneBuilder {
  38349. /**
  38350. * Creates a plane mesh
  38351. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38352. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38353. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38357. * @param name defines the name of the mesh
  38358. * @param options defines the options used to create the mesh
  38359. * @param scene defines the hosting scene
  38360. * @returns the plane mesh
  38361. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38362. */
  38363. static CreatePlane(name: string, options: {
  38364. size?: number;
  38365. width?: number;
  38366. height?: number;
  38367. sideOrientation?: number;
  38368. frontUVs?: Vector4;
  38369. backUVs?: Vector4;
  38370. updatable?: boolean;
  38371. sourcePlane?: Plane;
  38372. }, scene?: Nullable<Scene>): Mesh;
  38373. }
  38374. }
  38375. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38376. import { Behavior } from "babylonjs/Behaviors/behavior";
  38377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38378. import { Observable } from "babylonjs/Misc/observable";
  38379. import { Vector3 } from "babylonjs/Maths/math.vector";
  38380. import { Ray } from "babylonjs/Culling/ray";
  38381. import "babylonjs/Meshes/Builders/planeBuilder";
  38382. /**
  38383. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38384. */
  38385. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38386. private static _AnyMouseID;
  38387. /**
  38388. * Abstract mesh the behavior is set on
  38389. */
  38390. attachedNode: AbstractMesh;
  38391. private _dragPlane;
  38392. private _scene;
  38393. private _pointerObserver;
  38394. private _beforeRenderObserver;
  38395. private static _planeScene;
  38396. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38397. /**
  38398. * 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)
  38399. */
  38400. maxDragAngle: number;
  38401. /**
  38402. * @hidden
  38403. */
  38404. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38405. /**
  38406. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38407. */
  38408. currentDraggingPointerID: number;
  38409. /**
  38410. * The last position where the pointer hit the drag plane in world space
  38411. */
  38412. lastDragPosition: Vector3;
  38413. /**
  38414. * If the behavior is currently in a dragging state
  38415. */
  38416. dragging: boolean;
  38417. /**
  38418. * 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)
  38419. */
  38420. dragDeltaRatio: number;
  38421. /**
  38422. * If the drag plane orientation should be updated during the dragging (Default: true)
  38423. */
  38424. updateDragPlane: boolean;
  38425. private _debugMode;
  38426. private _moving;
  38427. /**
  38428. * Fires each time the attached mesh is dragged with the pointer
  38429. * * delta between last drag position and current drag position in world space
  38430. * * dragDistance along the drag axis
  38431. * * dragPlaneNormal normal of the current drag plane used during the drag
  38432. * * dragPlanePoint in world space where the drag intersects the drag plane
  38433. */
  38434. onDragObservable: Observable<{
  38435. delta: Vector3;
  38436. dragPlanePoint: Vector3;
  38437. dragPlaneNormal: Vector3;
  38438. dragDistance: number;
  38439. pointerId: number;
  38440. }>;
  38441. /**
  38442. * Fires each time a drag begins (eg. mouse down on mesh)
  38443. */
  38444. onDragStartObservable: Observable<{
  38445. dragPlanePoint: Vector3;
  38446. pointerId: number;
  38447. }>;
  38448. /**
  38449. * Fires each time a drag ends (eg. mouse release after drag)
  38450. */
  38451. onDragEndObservable: Observable<{
  38452. dragPlanePoint: Vector3;
  38453. pointerId: number;
  38454. }>;
  38455. /**
  38456. * If the attached mesh should be moved when dragged
  38457. */
  38458. moveAttached: boolean;
  38459. /**
  38460. * If the drag behavior will react to drag events (Default: true)
  38461. */
  38462. enabled: boolean;
  38463. /**
  38464. * If pointer events should start and release the drag (Default: true)
  38465. */
  38466. startAndReleaseDragOnPointerEvents: boolean;
  38467. /**
  38468. * If camera controls should be detached during the drag
  38469. */
  38470. detachCameraControls: boolean;
  38471. /**
  38472. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38473. */
  38474. useObjectOrienationForDragging: boolean;
  38475. private _options;
  38476. /**
  38477. * Creates a pointer drag behavior that can be attached to a mesh
  38478. * @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)
  38479. */
  38480. constructor(options?: {
  38481. dragAxis?: Vector3;
  38482. dragPlaneNormal?: Vector3;
  38483. });
  38484. /**
  38485. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38486. */
  38487. validateDrag: (targetPosition: Vector3) => boolean;
  38488. /**
  38489. * The name of the behavior
  38490. */
  38491. readonly name: string;
  38492. /**
  38493. * Initializes the behavior
  38494. */
  38495. init(): void;
  38496. private _tmpVector;
  38497. private _alternatePickedPoint;
  38498. private _worldDragAxis;
  38499. private _targetPosition;
  38500. private _attachedElement;
  38501. /**
  38502. * Attaches the drag behavior the passed in mesh
  38503. * @param ownerNode The mesh that will be dragged around once attached
  38504. * @param predicate Predicate to use for pick filtering
  38505. */
  38506. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38507. /**
  38508. * Force relase the drag action by code.
  38509. */
  38510. releaseDrag(): void;
  38511. private _startDragRay;
  38512. private _lastPointerRay;
  38513. /**
  38514. * Simulates the start of a pointer drag event on the behavior
  38515. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38516. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38517. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38518. */
  38519. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38520. private _startDrag;
  38521. private _dragDelta;
  38522. private _moveDrag;
  38523. private _pickWithRayOnDragPlane;
  38524. private _pointA;
  38525. private _pointB;
  38526. private _pointC;
  38527. private _lineA;
  38528. private _lineB;
  38529. private _localAxis;
  38530. private _lookAt;
  38531. private _updateDragPlanePosition;
  38532. /**
  38533. * Detaches the behavior from the mesh
  38534. */
  38535. detach(): void;
  38536. }
  38537. }
  38538. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38539. import { Mesh } from "babylonjs/Meshes/mesh";
  38540. import { Behavior } from "babylonjs/Behaviors/behavior";
  38541. /**
  38542. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38543. */
  38544. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38545. private _dragBehaviorA;
  38546. private _dragBehaviorB;
  38547. private _startDistance;
  38548. private _initialScale;
  38549. private _targetScale;
  38550. private _ownerNode;
  38551. private _sceneRenderObserver;
  38552. /**
  38553. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38554. */
  38555. constructor();
  38556. /**
  38557. * The name of the behavior
  38558. */
  38559. readonly name: string;
  38560. /**
  38561. * Initializes the behavior
  38562. */
  38563. init(): void;
  38564. private _getCurrentDistance;
  38565. /**
  38566. * Attaches the scale behavior the passed in mesh
  38567. * @param ownerNode The mesh that will be scaled around once attached
  38568. */
  38569. attach(ownerNode: Mesh): void;
  38570. /**
  38571. * Detaches the behavior from the mesh
  38572. */
  38573. detach(): void;
  38574. }
  38575. }
  38576. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38577. import { Behavior } from "babylonjs/Behaviors/behavior";
  38578. import { Mesh } from "babylonjs/Meshes/mesh";
  38579. import { Observable } from "babylonjs/Misc/observable";
  38580. /**
  38581. * 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
  38582. */
  38583. export class SixDofDragBehavior implements Behavior<Mesh> {
  38584. private static _virtualScene;
  38585. private _ownerNode;
  38586. private _sceneRenderObserver;
  38587. private _scene;
  38588. private _targetPosition;
  38589. private _virtualOriginMesh;
  38590. private _virtualDragMesh;
  38591. private _pointerObserver;
  38592. private _moving;
  38593. private _startingOrientation;
  38594. /**
  38595. * 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)
  38596. */
  38597. private zDragFactor;
  38598. /**
  38599. * If the object should rotate to face the drag origin
  38600. */
  38601. rotateDraggedObject: boolean;
  38602. /**
  38603. * If the behavior is currently in a dragging state
  38604. */
  38605. dragging: boolean;
  38606. /**
  38607. * 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)
  38608. */
  38609. dragDeltaRatio: number;
  38610. /**
  38611. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38612. */
  38613. currentDraggingPointerID: number;
  38614. /**
  38615. * If camera controls should be detached during the drag
  38616. */
  38617. detachCameraControls: boolean;
  38618. /**
  38619. * Fires each time a drag starts
  38620. */
  38621. onDragStartObservable: Observable<{}>;
  38622. /**
  38623. * Fires each time a drag ends (eg. mouse release after drag)
  38624. */
  38625. onDragEndObservable: Observable<{}>;
  38626. /**
  38627. * 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
  38628. */
  38629. constructor();
  38630. /**
  38631. * The name of the behavior
  38632. */
  38633. readonly name: string;
  38634. /**
  38635. * Initializes the behavior
  38636. */
  38637. init(): void;
  38638. /**
  38639. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38640. */
  38641. private readonly _pointerCamera;
  38642. /**
  38643. * Attaches the scale behavior the passed in mesh
  38644. * @param ownerNode The mesh that will be scaled around once attached
  38645. */
  38646. attach(ownerNode: Mesh): void;
  38647. /**
  38648. * Detaches the behavior from the mesh
  38649. */
  38650. detach(): void;
  38651. }
  38652. }
  38653. declare module "babylonjs/Behaviors/Meshes/index" {
  38654. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38655. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38656. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38657. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38658. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38659. }
  38660. declare module "babylonjs/Behaviors/index" {
  38661. export * from "babylonjs/Behaviors/behavior";
  38662. export * from "babylonjs/Behaviors/Cameras/index";
  38663. export * from "babylonjs/Behaviors/Meshes/index";
  38664. }
  38665. declare module "babylonjs/Bones/boneIKController" {
  38666. import { Bone } from "babylonjs/Bones/bone";
  38667. import { Vector3 } from "babylonjs/Maths/math.vector";
  38668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38669. import { Nullable } from "babylonjs/types";
  38670. /**
  38671. * Class used to apply inverse kinematics to bones
  38672. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38673. */
  38674. export class BoneIKController {
  38675. private static _tmpVecs;
  38676. private static _tmpQuat;
  38677. private static _tmpMats;
  38678. /**
  38679. * Gets or sets the target mesh
  38680. */
  38681. targetMesh: AbstractMesh;
  38682. /** Gets or sets the mesh used as pole */
  38683. poleTargetMesh: AbstractMesh;
  38684. /**
  38685. * Gets or sets the bone used as pole
  38686. */
  38687. poleTargetBone: Nullable<Bone>;
  38688. /**
  38689. * Gets or sets the target position
  38690. */
  38691. targetPosition: Vector3;
  38692. /**
  38693. * Gets or sets the pole target position
  38694. */
  38695. poleTargetPosition: Vector3;
  38696. /**
  38697. * Gets or sets the pole target local offset
  38698. */
  38699. poleTargetLocalOffset: Vector3;
  38700. /**
  38701. * Gets or sets the pole angle
  38702. */
  38703. poleAngle: number;
  38704. /**
  38705. * Gets or sets the mesh associated with the controller
  38706. */
  38707. mesh: AbstractMesh;
  38708. /**
  38709. * 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)
  38710. */
  38711. slerpAmount: number;
  38712. private _bone1Quat;
  38713. private _bone1Mat;
  38714. private _bone2Ang;
  38715. private _bone1;
  38716. private _bone2;
  38717. private _bone1Length;
  38718. private _bone2Length;
  38719. private _maxAngle;
  38720. private _maxReach;
  38721. private _rightHandedSystem;
  38722. private _bendAxis;
  38723. private _slerping;
  38724. private _adjustRoll;
  38725. /**
  38726. * Gets or sets maximum allowed angle
  38727. */
  38728. maxAngle: number;
  38729. /**
  38730. * Creates a new BoneIKController
  38731. * @param mesh defines the mesh to control
  38732. * @param bone defines the bone to control
  38733. * @param options defines options to set up the controller
  38734. */
  38735. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38736. targetMesh?: AbstractMesh;
  38737. poleTargetMesh?: AbstractMesh;
  38738. poleTargetBone?: Bone;
  38739. poleTargetLocalOffset?: Vector3;
  38740. poleAngle?: number;
  38741. bendAxis?: Vector3;
  38742. maxAngle?: number;
  38743. slerpAmount?: number;
  38744. });
  38745. private _setMaxAngle;
  38746. /**
  38747. * Force the controller to update the bones
  38748. */
  38749. update(): void;
  38750. }
  38751. }
  38752. declare module "babylonjs/Bones/boneLookController" {
  38753. import { Vector3 } from "babylonjs/Maths/math.vector";
  38754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38755. import { Bone } from "babylonjs/Bones/bone";
  38756. import { Space } from "babylonjs/Maths/math.axis";
  38757. /**
  38758. * Class used to make a bone look toward a point in space
  38759. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38760. */
  38761. export class BoneLookController {
  38762. private static _tmpVecs;
  38763. private static _tmpQuat;
  38764. private static _tmpMats;
  38765. /**
  38766. * The target Vector3 that the bone will look at
  38767. */
  38768. target: Vector3;
  38769. /**
  38770. * The mesh that the bone is attached to
  38771. */
  38772. mesh: AbstractMesh;
  38773. /**
  38774. * The bone that will be looking to the target
  38775. */
  38776. bone: Bone;
  38777. /**
  38778. * The up axis of the coordinate system that is used when the bone is rotated
  38779. */
  38780. upAxis: Vector3;
  38781. /**
  38782. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38783. */
  38784. upAxisSpace: Space;
  38785. /**
  38786. * Used to make an adjustment to the yaw of the bone
  38787. */
  38788. adjustYaw: number;
  38789. /**
  38790. * Used to make an adjustment to the pitch of the bone
  38791. */
  38792. adjustPitch: number;
  38793. /**
  38794. * Used to make an adjustment to the roll of the bone
  38795. */
  38796. adjustRoll: number;
  38797. /**
  38798. * 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)
  38799. */
  38800. slerpAmount: number;
  38801. private _minYaw;
  38802. private _maxYaw;
  38803. private _minPitch;
  38804. private _maxPitch;
  38805. private _minYawSin;
  38806. private _minYawCos;
  38807. private _maxYawSin;
  38808. private _maxYawCos;
  38809. private _midYawConstraint;
  38810. private _minPitchTan;
  38811. private _maxPitchTan;
  38812. private _boneQuat;
  38813. private _slerping;
  38814. private _transformYawPitch;
  38815. private _transformYawPitchInv;
  38816. private _firstFrameSkipped;
  38817. private _yawRange;
  38818. private _fowardAxis;
  38819. /**
  38820. * Gets or sets the minimum yaw angle that the bone can look to
  38821. */
  38822. minYaw: number;
  38823. /**
  38824. * Gets or sets the maximum yaw angle that the bone can look to
  38825. */
  38826. maxYaw: number;
  38827. /**
  38828. * Gets or sets the minimum pitch angle that the bone can look to
  38829. */
  38830. minPitch: number;
  38831. /**
  38832. * Gets or sets the maximum pitch angle that the bone can look to
  38833. */
  38834. maxPitch: number;
  38835. /**
  38836. * Create a BoneLookController
  38837. * @param mesh the mesh that the bone belongs to
  38838. * @param bone the bone that will be looking to the target
  38839. * @param target the target Vector3 to look at
  38840. * @param options optional settings:
  38841. * * maxYaw: the maximum angle the bone will yaw to
  38842. * * minYaw: the minimum angle the bone will yaw to
  38843. * * maxPitch: the maximum angle the bone will pitch to
  38844. * * minPitch: the minimum angle the bone will yaw to
  38845. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38846. * * upAxis: the up axis of the coordinate system
  38847. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38848. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38849. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38850. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38851. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38852. * * adjustRoll: used to make an adjustment to the roll of the bone
  38853. **/
  38854. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38855. maxYaw?: number;
  38856. minYaw?: number;
  38857. maxPitch?: number;
  38858. minPitch?: number;
  38859. slerpAmount?: number;
  38860. upAxis?: Vector3;
  38861. upAxisSpace?: Space;
  38862. yawAxis?: Vector3;
  38863. pitchAxis?: Vector3;
  38864. adjustYaw?: number;
  38865. adjustPitch?: number;
  38866. adjustRoll?: number;
  38867. });
  38868. /**
  38869. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38870. */
  38871. update(): void;
  38872. private _getAngleDiff;
  38873. private _getAngleBetween;
  38874. private _isAngleBetween;
  38875. }
  38876. }
  38877. declare module "babylonjs/Bones/index" {
  38878. export * from "babylonjs/Bones/bone";
  38879. export * from "babylonjs/Bones/boneIKController";
  38880. export * from "babylonjs/Bones/boneLookController";
  38881. export * from "babylonjs/Bones/skeleton";
  38882. }
  38883. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38884. import { Nullable } from "babylonjs/types";
  38885. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38886. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38887. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38888. /**
  38889. * Manage the gamepad inputs to control an arc rotate camera.
  38890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38891. */
  38892. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38893. /**
  38894. * Defines the camera the input is attached to.
  38895. */
  38896. camera: ArcRotateCamera;
  38897. /**
  38898. * Defines the gamepad the input is gathering event from.
  38899. */
  38900. gamepad: Nullable<Gamepad>;
  38901. /**
  38902. * Defines the gamepad rotation sensiblity.
  38903. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38904. */
  38905. gamepadRotationSensibility: number;
  38906. /**
  38907. * Defines the gamepad move sensiblity.
  38908. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38909. */
  38910. gamepadMoveSensibility: number;
  38911. private _yAxisScale;
  38912. /**
  38913. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38914. */
  38915. invertYAxis: boolean;
  38916. private _onGamepadConnectedObserver;
  38917. private _onGamepadDisconnectedObserver;
  38918. /**
  38919. * Attach the input controls to a specific dom element to get the input from.
  38920. * @param element Defines the element the controls should be listened from
  38921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38922. */
  38923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38924. /**
  38925. * Detach the current controls from the specified dom element.
  38926. * @param element Defines the element to stop listening the inputs from
  38927. */
  38928. detachControl(element: Nullable<HTMLElement>): void;
  38929. /**
  38930. * Update the current camera state depending on the inputs that have been used this frame.
  38931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38932. */
  38933. checkInputs(): void;
  38934. /**
  38935. * Gets the class name of the current intput.
  38936. * @returns the class name
  38937. */
  38938. getClassName(): string;
  38939. /**
  38940. * Get the friendly name associated with the input class.
  38941. * @returns the input friendly name
  38942. */
  38943. getSimpleName(): string;
  38944. }
  38945. }
  38946. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38947. import { Nullable } from "babylonjs/types";
  38948. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38949. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38950. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38951. interface ArcRotateCameraInputsManager {
  38952. /**
  38953. * Add orientation input support to the input manager.
  38954. * @returns the current input manager
  38955. */
  38956. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38957. }
  38958. }
  38959. /**
  38960. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38962. */
  38963. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38964. /**
  38965. * Defines the camera the input is attached to.
  38966. */
  38967. camera: ArcRotateCamera;
  38968. /**
  38969. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38970. */
  38971. alphaCorrection: number;
  38972. /**
  38973. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38974. */
  38975. gammaCorrection: number;
  38976. private _alpha;
  38977. private _gamma;
  38978. private _dirty;
  38979. private _deviceOrientationHandler;
  38980. /**
  38981. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38982. */
  38983. constructor();
  38984. /**
  38985. * Attach the input controls to a specific dom element to get the input from.
  38986. * @param element Defines the element the controls should be listened from
  38987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38988. */
  38989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38990. /** @hidden */
  38991. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38992. /**
  38993. * Update the current camera state depending on the inputs that have been used this frame.
  38994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38995. */
  38996. checkInputs(): void;
  38997. /**
  38998. * Detach the current controls from the specified dom element.
  38999. * @param element Defines the element to stop listening the inputs from
  39000. */
  39001. detachControl(element: Nullable<HTMLElement>): void;
  39002. /**
  39003. * Gets the class name of the current intput.
  39004. * @returns the class name
  39005. */
  39006. getClassName(): string;
  39007. /**
  39008. * Get the friendly name associated with the input class.
  39009. * @returns the input friendly name
  39010. */
  39011. getSimpleName(): string;
  39012. }
  39013. }
  39014. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39015. import { Nullable } from "babylonjs/types";
  39016. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39017. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39018. /**
  39019. * Listen to mouse events to control the camera.
  39020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39021. */
  39022. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39023. /**
  39024. * Defines the camera the input is attached to.
  39025. */
  39026. camera: FlyCamera;
  39027. /**
  39028. * Defines if touch is enabled. (Default is true.)
  39029. */
  39030. touchEnabled: boolean;
  39031. /**
  39032. * Defines the buttons associated with the input to handle camera rotation.
  39033. */
  39034. buttons: number[];
  39035. /**
  39036. * Assign buttons for Yaw control.
  39037. */
  39038. buttonsYaw: number[];
  39039. /**
  39040. * Assign buttons for Pitch control.
  39041. */
  39042. buttonsPitch: number[];
  39043. /**
  39044. * Assign buttons for Roll control.
  39045. */
  39046. buttonsRoll: number[];
  39047. /**
  39048. * Detect if any button is being pressed while mouse is moved.
  39049. * -1 = Mouse locked.
  39050. * 0 = Left button.
  39051. * 1 = Middle Button.
  39052. * 2 = Right Button.
  39053. */
  39054. activeButton: number;
  39055. /**
  39056. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39057. * Higher values reduce its sensitivity.
  39058. */
  39059. angularSensibility: number;
  39060. private _mousemoveCallback;
  39061. private _observer;
  39062. private _rollObserver;
  39063. private previousPosition;
  39064. private noPreventDefault;
  39065. private element;
  39066. /**
  39067. * Listen to mouse events to control the camera.
  39068. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39070. */
  39071. constructor(touchEnabled?: boolean);
  39072. /**
  39073. * Attach the mouse control to the HTML DOM element.
  39074. * @param element Defines the element that listens to the input events.
  39075. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39076. */
  39077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39078. /**
  39079. * Detach the current controls from the specified dom element.
  39080. * @param element Defines the element to stop listening the inputs from
  39081. */
  39082. detachControl(element: Nullable<HTMLElement>): void;
  39083. /**
  39084. * Gets the class name of the current input.
  39085. * @returns the class name.
  39086. */
  39087. getClassName(): string;
  39088. /**
  39089. * Get the friendly name associated with the input class.
  39090. * @returns the input's friendly name.
  39091. */
  39092. getSimpleName(): string;
  39093. private _pointerInput;
  39094. private _onMouseMove;
  39095. /**
  39096. * Rotate camera by mouse offset.
  39097. */
  39098. private rotateCamera;
  39099. }
  39100. }
  39101. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39102. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39103. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39104. /**
  39105. * Default Inputs manager for the FlyCamera.
  39106. * It groups all the default supported inputs for ease of use.
  39107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39108. */
  39109. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39110. /**
  39111. * Instantiates a new FlyCameraInputsManager.
  39112. * @param camera Defines the camera the inputs belong to.
  39113. */
  39114. constructor(camera: FlyCamera);
  39115. /**
  39116. * Add keyboard input support to the input manager.
  39117. * @returns the new FlyCameraKeyboardMoveInput().
  39118. */
  39119. addKeyboard(): FlyCameraInputsManager;
  39120. /**
  39121. * Add mouse input support to the input manager.
  39122. * @param touchEnabled Enable touch screen support.
  39123. * @returns the new FlyCameraMouseInput().
  39124. */
  39125. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39126. }
  39127. }
  39128. declare module "babylonjs/Cameras/flyCamera" {
  39129. import { Scene } from "babylonjs/scene";
  39130. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39132. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39133. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39134. /**
  39135. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39136. * such as in a 3D Space Shooter or a Flight Simulator.
  39137. */
  39138. export class FlyCamera extends TargetCamera {
  39139. /**
  39140. * Define the collision ellipsoid of the camera.
  39141. * This is helpful for simulating a camera body, like a player's body.
  39142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39143. */
  39144. ellipsoid: Vector3;
  39145. /**
  39146. * Define an offset for the position of the ellipsoid around the camera.
  39147. * This can be helpful if the camera is attached away from the player's body center,
  39148. * such as at its head.
  39149. */
  39150. ellipsoidOffset: Vector3;
  39151. /**
  39152. * Enable or disable collisions of the camera with the rest of the scene objects.
  39153. */
  39154. checkCollisions: boolean;
  39155. /**
  39156. * Enable or disable gravity on the camera.
  39157. */
  39158. applyGravity: boolean;
  39159. /**
  39160. * Define the current direction the camera is moving to.
  39161. */
  39162. cameraDirection: Vector3;
  39163. /**
  39164. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39165. * This overrides and empties cameraRotation.
  39166. */
  39167. rotationQuaternion: Quaternion;
  39168. /**
  39169. * Track Roll to maintain the wanted Rolling when looking around.
  39170. */
  39171. _trackRoll: number;
  39172. /**
  39173. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39174. */
  39175. rollCorrect: number;
  39176. /**
  39177. * Mimic a banked turn, Rolling the camera when Yawing.
  39178. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39179. */
  39180. bankedTurn: boolean;
  39181. /**
  39182. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39183. */
  39184. bankedTurnLimit: number;
  39185. /**
  39186. * Value of 0 disables the banked Roll.
  39187. * Value of 1 is equal to the Yaw angle in radians.
  39188. */
  39189. bankedTurnMultiplier: number;
  39190. /**
  39191. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39192. */
  39193. inputs: FlyCameraInputsManager;
  39194. /**
  39195. * Gets the input sensibility for mouse input.
  39196. * Higher values reduce sensitivity.
  39197. */
  39198. /**
  39199. * Sets the input sensibility for a mouse input.
  39200. * Higher values reduce sensitivity.
  39201. */
  39202. angularSensibility: number;
  39203. /**
  39204. * Get the keys for camera movement forward.
  39205. */
  39206. /**
  39207. * Set the keys for camera movement forward.
  39208. */
  39209. keysForward: number[];
  39210. /**
  39211. * Get the keys for camera movement backward.
  39212. */
  39213. keysBackward: number[];
  39214. /**
  39215. * Get the keys for camera movement up.
  39216. */
  39217. /**
  39218. * Set the keys for camera movement up.
  39219. */
  39220. keysUp: number[];
  39221. /**
  39222. * Get the keys for camera movement down.
  39223. */
  39224. /**
  39225. * Set the keys for camera movement down.
  39226. */
  39227. keysDown: number[];
  39228. /**
  39229. * Get the keys for camera movement left.
  39230. */
  39231. /**
  39232. * Set the keys for camera movement left.
  39233. */
  39234. keysLeft: number[];
  39235. /**
  39236. * Set the keys for camera movement right.
  39237. */
  39238. /**
  39239. * Set the keys for camera movement right.
  39240. */
  39241. keysRight: number[];
  39242. /**
  39243. * Event raised when the camera collides with a mesh in the scene.
  39244. */
  39245. onCollide: (collidedMesh: AbstractMesh) => void;
  39246. private _collider;
  39247. private _needMoveForGravity;
  39248. private _oldPosition;
  39249. private _diffPosition;
  39250. private _newPosition;
  39251. /** @hidden */
  39252. _localDirection: Vector3;
  39253. /** @hidden */
  39254. _transformedDirection: Vector3;
  39255. /**
  39256. * Instantiates a FlyCamera.
  39257. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39258. * such as in a 3D Space Shooter or a Flight Simulator.
  39259. * @param name Define the name of the camera in the scene.
  39260. * @param position Define the starting position of the camera in the scene.
  39261. * @param scene Define the scene the camera belongs to.
  39262. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39263. */
  39264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39265. /**
  39266. * Attach a control to the HTML DOM element.
  39267. * @param element Defines the element that listens to the input events.
  39268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39269. */
  39270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39271. /**
  39272. * Detach a control from the HTML DOM element.
  39273. * The camera will stop reacting to that input.
  39274. * @param element Defines the element that listens to the input events.
  39275. */
  39276. detachControl(element: HTMLElement): void;
  39277. private _collisionMask;
  39278. /**
  39279. * Get the mask that the camera ignores in collision events.
  39280. */
  39281. /**
  39282. * Set the mask that the camera ignores in collision events.
  39283. */
  39284. collisionMask: number;
  39285. /** @hidden */
  39286. _collideWithWorld(displacement: Vector3): void;
  39287. /** @hidden */
  39288. private _onCollisionPositionChange;
  39289. /** @hidden */
  39290. _checkInputs(): void;
  39291. /** @hidden */
  39292. _decideIfNeedsToMove(): boolean;
  39293. /** @hidden */
  39294. _updatePosition(): void;
  39295. /**
  39296. * Restore the Roll to its target value at the rate specified.
  39297. * @param rate - Higher means slower restoring.
  39298. * @hidden
  39299. */
  39300. restoreRoll(rate: number): void;
  39301. /**
  39302. * Destroy the camera and release the current resources held by it.
  39303. */
  39304. dispose(): void;
  39305. /**
  39306. * Get the current object class name.
  39307. * @returns the class name.
  39308. */
  39309. getClassName(): string;
  39310. }
  39311. }
  39312. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39313. import { Nullable } from "babylonjs/types";
  39314. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39315. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39316. /**
  39317. * Listen to keyboard events to control the camera.
  39318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39319. */
  39320. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39321. /**
  39322. * Defines the camera the input is attached to.
  39323. */
  39324. camera: FlyCamera;
  39325. /**
  39326. * The list of keyboard keys used to control the forward move of the camera.
  39327. */
  39328. keysForward: number[];
  39329. /**
  39330. * The list of keyboard keys used to control the backward move of the camera.
  39331. */
  39332. keysBackward: number[];
  39333. /**
  39334. * The list of keyboard keys used to control the forward move of the camera.
  39335. */
  39336. keysUp: number[];
  39337. /**
  39338. * The list of keyboard keys used to control the backward move of the camera.
  39339. */
  39340. keysDown: number[];
  39341. /**
  39342. * The list of keyboard keys used to control the right strafe move of the camera.
  39343. */
  39344. keysRight: number[];
  39345. /**
  39346. * The list of keyboard keys used to control the left strafe move of the camera.
  39347. */
  39348. keysLeft: number[];
  39349. private _keys;
  39350. private _onCanvasBlurObserver;
  39351. private _onKeyboardObserver;
  39352. private _engine;
  39353. private _scene;
  39354. /**
  39355. * Attach the input controls to a specific dom element to get the input from.
  39356. * @param element Defines the element the controls should be listened from
  39357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39358. */
  39359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39360. /**
  39361. * Detach the current controls from the specified dom element.
  39362. * @param element Defines the element to stop listening the inputs from
  39363. */
  39364. detachControl(element: Nullable<HTMLElement>): void;
  39365. /**
  39366. * Gets the class name of the current intput.
  39367. * @returns the class name
  39368. */
  39369. getClassName(): string;
  39370. /** @hidden */
  39371. _onLostFocus(e: FocusEvent): void;
  39372. /**
  39373. * Get the friendly name associated with the input class.
  39374. * @returns the input friendly name
  39375. */
  39376. getSimpleName(): string;
  39377. /**
  39378. * Update the current camera state depending on the inputs that have been used this frame.
  39379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39380. */
  39381. checkInputs(): void;
  39382. }
  39383. }
  39384. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39385. import { Nullable } from "babylonjs/types";
  39386. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39387. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39388. /**
  39389. * Manage the mouse wheel inputs to control a follow camera.
  39390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39391. */
  39392. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39393. /**
  39394. * Defines the camera the input is attached to.
  39395. */
  39396. camera: FollowCamera;
  39397. /**
  39398. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39399. */
  39400. axisControlRadius: boolean;
  39401. /**
  39402. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39403. */
  39404. axisControlHeight: boolean;
  39405. /**
  39406. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39407. */
  39408. axisControlRotation: boolean;
  39409. /**
  39410. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39411. * relation to mouseWheel events.
  39412. */
  39413. wheelPrecision: number;
  39414. /**
  39415. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39416. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39417. */
  39418. wheelDeltaPercentage: number;
  39419. private _wheel;
  39420. private _observer;
  39421. /**
  39422. * Attach the input controls to a specific dom element to get the input from.
  39423. * @param element Defines the element the controls should be listened from
  39424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39425. */
  39426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39427. /**
  39428. * Detach the current controls from the specified dom element.
  39429. * @param element Defines the element to stop listening the inputs from
  39430. */
  39431. detachControl(element: Nullable<HTMLElement>): void;
  39432. /**
  39433. * Gets the class name of the current intput.
  39434. * @returns the class name
  39435. */
  39436. getClassName(): string;
  39437. /**
  39438. * Get the friendly name associated with the input class.
  39439. * @returns the input friendly name
  39440. */
  39441. getSimpleName(): string;
  39442. }
  39443. }
  39444. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39445. import { Nullable } from "babylonjs/types";
  39446. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39447. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39448. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39449. /**
  39450. * Manage the pointers inputs to control an follow camera.
  39451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39452. */
  39453. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39454. /**
  39455. * Defines the camera the input is attached to.
  39456. */
  39457. camera: FollowCamera;
  39458. /**
  39459. * Gets the class name of the current input.
  39460. * @returns the class name
  39461. */
  39462. getClassName(): string;
  39463. /**
  39464. * Defines the pointer angular sensibility along the X axis or how fast is
  39465. * the camera rotating.
  39466. * A negative number will reverse the axis direction.
  39467. */
  39468. angularSensibilityX: number;
  39469. /**
  39470. * Defines the pointer angular sensibility along the Y axis or how fast is
  39471. * the camera rotating.
  39472. * A negative number will reverse the axis direction.
  39473. */
  39474. angularSensibilityY: number;
  39475. /**
  39476. * Defines the pointer pinch precision or how fast is the camera zooming.
  39477. * A negative number will reverse the axis direction.
  39478. */
  39479. pinchPrecision: number;
  39480. /**
  39481. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39482. * from 0.
  39483. * It defines the percentage of current camera.radius to use as delta when
  39484. * pinch zoom is used.
  39485. */
  39486. pinchDeltaPercentage: number;
  39487. /**
  39488. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39489. */
  39490. axisXControlRadius: boolean;
  39491. /**
  39492. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39493. */
  39494. axisXControlHeight: boolean;
  39495. /**
  39496. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39497. */
  39498. axisXControlRotation: boolean;
  39499. /**
  39500. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39501. */
  39502. axisYControlRadius: boolean;
  39503. /**
  39504. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39505. */
  39506. axisYControlHeight: boolean;
  39507. /**
  39508. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39509. */
  39510. axisYControlRotation: boolean;
  39511. /**
  39512. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39513. */
  39514. axisPinchControlRadius: boolean;
  39515. /**
  39516. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39517. */
  39518. axisPinchControlHeight: boolean;
  39519. /**
  39520. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39521. */
  39522. axisPinchControlRotation: boolean;
  39523. /**
  39524. * Log error messages if basic misconfiguration has occurred.
  39525. */
  39526. warningEnable: boolean;
  39527. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39528. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39529. private _warningCounter;
  39530. private _warning;
  39531. }
  39532. }
  39533. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39534. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39535. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39536. /**
  39537. * Default Inputs manager for the FollowCamera.
  39538. * It groups all the default supported inputs for ease of use.
  39539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39540. */
  39541. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39542. /**
  39543. * Instantiates a new FollowCameraInputsManager.
  39544. * @param camera Defines the camera the inputs belong to
  39545. */
  39546. constructor(camera: FollowCamera);
  39547. /**
  39548. * Add keyboard input support to the input manager.
  39549. * @returns the current input manager
  39550. */
  39551. addKeyboard(): FollowCameraInputsManager;
  39552. /**
  39553. * Add mouse wheel input support to the input manager.
  39554. * @returns the current input manager
  39555. */
  39556. addMouseWheel(): FollowCameraInputsManager;
  39557. /**
  39558. * Add pointers input support to the input manager.
  39559. * @returns the current input manager
  39560. */
  39561. addPointers(): FollowCameraInputsManager;
  39562. /**
  39563. * Add orientation input support to the input manager.
  39564. * @returns the current input manager
  39565. */
  39566. addVRDeviceOrientation(): FollowCameraInputsManager;
  39567. }
  39568. }
  39569. declare module "babylonjs/Cameras/followCamera" {
  39570. import { Nullable } from "babylonjs/types";
  39571. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39572. import { Scene } from "babylonjs/scene";
  39573. import { Vector3 } from "babylonjs/Maths/math.vector";
  39574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39575. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39576. /**
  39577. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39578. * an arc rotate version arcFollowCamera are available.
  39579. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39580. */
  39581. export class FollowCamera extends TargetCamera {
  39582. /**
  39583. * Distance the follow camera should follow an object at
  39584. */
  39585. radius: number;
  39586. /**
  39587. * Minimum allowed distance of the camera to the axis of rotation
  39588. * (The camera can not get closer).
  39589. * This can help limiting how the Camera is able to move in the scene.
  39590. */
  39591. lowerRadiusLimit: Nullable<number>;
  39592. /**
  39593. * Maximum allowed distance of the camera to the axis of rotation
  39594. * (The camera can not get further).
  39595. * This can help limiting how the Camera is able to move in the scene.
  39596. */
  39597. upperRadiusLimit: Nullable<number>;
  39598. /**
  39599. * Define a rotation offset between the camera and the object it follows
  39600. */
  39601. rotationOffset: number;
  39602. /**
  39603. * Minimum allowed angle to camera position relative to target object.
  39604. * This can help limiting how the Camera is able to move in the scene.
  39605. */
  39606. lowerRotationOffsetLimit: Nullable<number>;
  39607. /**
  39608. * Maximum allowed angle to camera position relative to target object.
  39609. * This can help limiting how the Camera is able to move in the scene.
  39610. */
  39611. upperRotationOffsetLimit: Nullable<number>;
  39612. /**
  39613. * Define a height offset between the camera and the object it follows.
  39614. * It can help following an object from the top (like a car chaing a plane)
  39615. */
  39616. heightOffset: number;
  39617. /**
  39618. * Minimum allowed height of camera position relative to target object.
  39619. * This can help limiting how the Camera is able to move in the scene.
  39620. */
  39621. lowerHeightOffsetLimit: Nullable<number>;
  39622. /**
  39623. * Maximum allowed height of camera position relative to target object.
  39624. * This can help limiting how the Camera is able to move in the scene.
  39625. */
  39626. upperHeightOffsetLimit: Nullable<number>;
  39627. /**
  39628. * Define how fast the camera can accelerate to follow it s target.
  39629. */
  39630. cameraAcceleration: number;
  39631. /**
  39632. * Define the speed limit of the camera following an object.
  39633. */
  39634. maxCameraSpeed: number;
  39635. /**
  39636. * Define the target of the camera.
  39637. */
  39638. lockedTarget: Nullable<AbstractMesh>;
  39639. /**
  39640. * Defines the input associated with the camera.
  39641. */
  39642. inputs: FollowCameraInputsManager;
  39643. /**
  39644. * Instantiates the follow camera.
  39645. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39646. * @param name Define the name of the camera in the scene
  39647. * @param position Define the position of the camera
  39648. * @param scene Define the scene the camera belong to
  39649. * @param lockedTarget Define the target of the camera
  39650. */
  39651. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39652. private _follow;
  39653. /**
  39654. * Attached controls to the current camera.
  39655. * @param element Defines the element the controls should be listened from
  39656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39657. */
  39658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39659. /**
  39660. * Detach the current controls from the camera.
  39661. * The camera will stop reacting to inputs.
  39662. * @param element Defines the element to stop listening the inputs from
  39663. */
  39664. detachControl(element: HTMLElement): void;
  39665. /** @hidden */
  39666. _checkInputs(): void;
  39667. private _checkLimits;
  39668. /**
  39669. * Gets the camera class name.
  39670. * @returns the class name
  39671. */
  39672. getClassName(): string;
  39673. }
  39674. /**
  39675. * Arc Rotate version of the follow camera.
  39676. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39677. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39678. */
  39679. export class ArcFollowCamera extends TargetCamera {
  39680. /** The longitudinal angle of the camera */
  39681. alpha: number;
  39682. /** The latitudinal angle of the camera */
  39683. beta: number;
  39684. /** The radius of the camera from its target */
  39685. radius: number;
  39686. /** Define the camera target (the messh it should follow) */
  39687. target: Nullable<AbstractMesh>;
  39688. private _cartesianCoordinates;
  39689. /**
  39690. * Instantiates a new ArcFollowCamera
  39691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39692. * @param name Define the name of the camera
  39693. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39694. * @param beta Define the rotation angle of the camera around the elevation axis
  39695. * @param radius Define the radius of the camera from its target point
  39696. * @param target Define the target of the camera
  39697. * @param scene Define the scene the camera belongs to
  39698. */
  39699. constructor(name: string,
  39700. /** The longitudinal angle of the camera */
  39701. alpha: number,
  39702. /** The latitudinal angle of the camera */
  39703. beta: number,
  39704. /** The radius of the camera from its target */
  39705. radius: number,
  39706. /** Define the camera target (the messh it should follow) */
  39707. target: Nullable<AbstractMesh>, scene: Scene);
  39708. private _follow;
  39709. /** @hidden */
  39710. _checkInputs(): void;
  39711. /**
  39712. * Returns the class name of the object.
  39713. * It is mostly used internally for serialization purposes.
  39714. */
  39715. getClassName(): string;
  39716. }
  39717. }
  39718. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39719. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39720. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39721. import { Nullable } from "babylonjs/types";
  39722. /**
  39723. * Manage the keyboard inputs to control the movement of a follow camera.
  39724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39725. */
  39726. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39727. /**
  39728. * Defines the camera the input is attached to.
  39729. */
  39730. camera: FollowCamera;
  39731. /**
  39732. * Defines the list of key codes associated with the up action (increase heightOffset)
  39733. */
  39734. keysHeightOffsetIncr: number[];
  39735. /**
  39736. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39737. */
  39738. keysHeightOffsetDecr: number[];
  39739. /**
  39740. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39741. */
  39742. keysHeightOffsetModifierAlt: boolean;
  39743. /**
  39744. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39745. */
  39746. keysHeightOffsetModifierCtrl: boolean;
  39747. /**
  39748. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39749. */
  39750. keysHeightOffsetModifierShift: boolean;
  39751. /**
  39752. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39753. */
  39754. keysRotationOffsetIncr: number[];
  39755. /**
  39756. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39757. */
  39758. keysRotationOffsetDecr: number[];
  39759. /**
  39760. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39761. */
  39762. keysRotationOffsetModifierAlt: boolean;
  39763. /**
  39764. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39765. */
  39766. keysRotationOffsetModifierCtrl: boolean;
  39767. /**
  39768. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39769. */
  39770. keysRotationOffsetModifierShift: boolean;
  39771. /**
  39772. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39773. */
  39774. keysRadiusIncr: number[];
  39775. /**
  39776. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39777. */
  39778. keysRadiusDecr: number[];
  39779. /**
  39780. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39781. */
  39782. keysRadiusModifierAlt: boolean;
  39783. /**
  39784. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39785. */
  39786. keysRadiusModifierCtrl: boolean;
  39787. /**
  39788. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39789. */
  39790. keysRadiusModifierShift: boolean;
  39791. /**
  39792. * Defines the rate of change of heightOffset.
  39793. */
  39794. heightSensibility: number;
  39795. /**
  39796. * Defines the rate of change of rotationOffset.
  39797. */
  39798. rotationSensibility: number;
  39799. /**
  39800. * Defines the rate of change of radius.
  39801. */
  39802. radiusSensibility: number;
  39803. private _keys;
  39804. private _ctrlPressed;
  39805. private _altPressed;
  39806. private _shiftPressed;
  39807. private _onCanvasBlurObserver;
  39808. private _onKeyboardObserver;
  39809. private _engine;
  39810. private _scene;
  39811. /**
  39812. * Attach the input controls to a specific dom element to get the input from.
  39813. * @param element Defines the element the controls should be listened from
  39814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39815. */
  39816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39817. /**
  39818. * Detach the current controls from the specified dom element.
  39819. * @param element Defines the element to stop listening the inputs from
  39820. */
  39821. detachControl(element: Nullable<HTMLElement>): void;
  39822. /**
  39823. * Update the current camera state depending on the inputs that have been used this frame.
  39824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39825. */
  39826. checkInputs(): void;
  39827. /**
  39828. * Gets the class name of the current input.
  39829. * @returns the class name
  39830. */
  39831. getClassName(): string;
  39832. /**
  39833. * Get the friendly name associated with the input class.
  39834. * @returns the input friendly name
  39835. */
  39836. getSimpleName(): string;
  39837. /**
  39838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39839. * allow modification of the heightOffset value.
  39840. */
  39841. private _modifierHeightOffset;
  39842. /**
  39843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39844. * allow modification of the rotationOffset value.
  39845. */
  39846. private _modifierRotationOffset;
  39847. /**
  39848. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39849. * allow modification of the radius value.
  39850. */
  39851. private _modifierRadius;
  39852. }
  39853. }
  39854. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39855. import { Nullable } from "babylonjs/types";
  39856. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39858. import { Observable } from "babylonjs/Misc/observable";
  39859. module "babylonjs/Cameras/freeCameraInputsManager" {
  39860. interface FreeCameraInputsManager {
  39861. /**
  39862. * @hidden
  39863. */
  39864. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39865. /**
  39866. * Add orientation input support to the input manager.
  39867. * @returns the current input manager
  39868. */
  39869. addDeviceOrientation(): FreeCameraInputsManager;
  39870. }
  39871. }
  39872. /**
  39873. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39874. * Screen rotation is taken into account.
  39875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39876. */
  39877. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39878. private _camera;
  39879. private _screenOrientationAngle;
  39880. private _constantTranform;
  39881. private _screenQuaternion;
  39882. private _alpha;
  39883. private _beta;
  39884. private _gamma;
  39885. /**
  39886. * Can be used to detect if a device orientation sensor is availible on a device
  39887. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39888. * @returns a promise that will resolve on orientation change
  39889. */
  39890. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39891. /**
  39892. * @hidden
  39893. */
  39894. _onDeviceOrientationChangedObservable: Observable<void>;
  39895. /**
  39896. * Instantiates a new input
  39897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39898. */
  39899. constructor();
  39900. /**
  39901. * Define the camera controlled by the input.
  39902. */
  39903. camera: FreeCamera;
  39904. /**
  39905. * Attach the input controls to a specific dom element to get the input from.
  39906. * @param element Defines the element the controls should be listened from
  39907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39908. */
  39909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39910. private _orientationChanged;
  39911. private _deviceOrientation;
  39912. /**
  39913. * Detach the current controls from the specified dom element.
  39914. * @param element Defines the element to stop listening the inputs from
  39915. */
  39916. detachControl(element: Nullable<HTMLElement>): void;
  39917. /**
  39918. * Update the current camera state depending on the inputs that have been used this frame.
  39919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39920. */
  39921. checkInputs(): void;
  39922. /**
  39923. * Gets the class name of the current intput.
  39924. * @returns the class name
  39925. */
  39926. getClassName(): string;
  39927. /**
  39928. * Get the friendly name associated with the input class.
  39929. * @returns the input friendly name
  39930. */
  39931. getSimpleName(): string;
  39932. }
  39933. }
  39934. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39935. import { Nullable } from "babylonjs/types";
  39936. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39938. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39939. /**
  39940. * Manage the gamepad inputs to control a free camera.
  39941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39942. */
  39943. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39944. /**
  39945. * Define the camera the input is attached to.
  39946. */
  39947. camera: FreeCamera;
  39948. /**
  39949. * Define the Gamepad controlling the input
  39950. */
  39951. gamepad: Nullable<Gamepad>;
  39952. /**
  39953. * Defines the gamepad rotation sensiblity.
  39954. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39955. */
  39956. gamepadAngularSensibility: number;
  39957. /**
  39958. * Defines the gamepad move sensiblity.
  39959. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39960. */
  39961. gamepadMoveSensibility: number;
  39962. private _yAxisScale;
  39963. /**
  39964. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39965. */
  39966. invertYAxis: boolean;
  39967. private _onGamepadConnectedObserver;
  39968. private _onGamepadDisconnectedObserver;
  39969. private _cameraTransform;
  39970. private _deltaTransform;
  39971. private _vector3;
  39972. private _vector2;
  39973. /**
  39974. * Attach the input controls to a specific dom element to get the input from.
  39975. * @param element Defines the element the controls should be listened from
  39976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39977. */
  39978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39979. /**
  39980. * Detach the current controls from the specified dom element.
  39981. * @param element Defines the element to stop listening the inputs from
  39982. */
  39983. detachControl(element: Nullable<HTMLElement>): void;
  39984. /**
  39985. * Update the current camera state depending on the inputs that have been used this frame.
  39986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39987. */
  39988. checkInputs(): void;
  39989. /**
  39990. * Gets the class name of the current intput.
  39991. * @returns the class name
  39992. */
  39993. getClassName(): string;
  39994. /**
  39995. * Get the friendly name associated with the input class.
  39996. * @returns the input friendly name
  39997. */
  39998. getSimpleName(): string;
  39999. }
  40000. }
  40001. declare module "babylonjs/Misc/virtualJoystick" {
  40002. import { Nullable } from "babylonjs/types";
  40003. import { Vector3 } from "babylonjs/Maths/math.vector";
  40004. /**
  40005. * Defines the potential axis of a Joystick
  40006. */
  40007. export enum JoystickAxis {
  40008. /** X axis */
  40009. X = 0,
  40010. /** Y axis */
  40011. Y = 1,
  40012. /** Z axis */
  40013. Z = 2
  40014. }
  40015. /**
  40016. * Class used to define virtual joystick (used in touch mode)
  40017. */
  40018. export class VirtualJoystick {
  40019. /**
  40020. * Gets or sets a boolean indicating that left and right values must be inverted
  40021. */
  40022. reverseLeftRight: boolean;
  40023. /**
  40024. * Gets or sets a boolean indicating that up and down values must be inverted
  40025. */
  40026. reverseUpDown: boolean;
  40027. /**
  40028. * Gets the offset value for the position (ie. the change of the position value)
  40029. */
  40030. deltaPosition: Vector3;
  40031. /**
  40032. * Gets a boolean indicating if the virtual joystick was pressed
  40033. */
  40034. pressed: boolean;
  40035. /**
  40036. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40037. */
  40038. static Canvas: Nullable<HTMLCanvasElement>;
  40039. private static _globalJoystickIndex;
  40040. private static vjCanvasContext;
  40041. private static vjCanvasWidth;
  40042. private static vjCanvasHeight;
  40043. private static halfWidth;
  40044. private _action;
  40045. private _axisTargetedByLeftAndRight;
  40046. private _axisTargetedByUpAndDown;
  40047. private _joystickSensibility;
  40048. private _inversedSensibility;
  40049. private _joystickPointerID;
  40050. private _joystickColor;
  40051. private _joystickPointerPos;
  40052. private _joystickPreviousPointerPos;
  40053. private _joystickPointerStartPos;
  40054. private _deltaJoystickVector;
  40055. private _leftJoystick;
  40056. private _touches;
  40057. private _onPointerDownHandlerRef;
  40058. private _onPointerMoveHandlerRef;
  40059. private _onPointerUpHandlerRef;
  40060. private _onResize;
  40061. /**
  40062. * Creates a new virtual joystick
  40063. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40064. */
  40065. constructor(leftJoystick?: boolean);
  40066. /**
  40067. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40068. * @param newJoystickSensibility defines the new sensibility
  40069. */
  40070. setJoystickSensibility(newJoystickSensibility: number): void;
  40071. private _onPointerDown;
  40072. private _onPointerMove;
  40073. private _onPointerUp;
  40074. /**
  40075. * Change the color of the virtual joystick
  40076. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40077. */
  40078. setJoystickColor(newColor: string): void;
  40079. /**
  40080. * Defines a callback to call when the joystick is touched
  40081. * @param action defines the callback
  40082. */
  40083. setActionOnTouch(action: () => any): void;
  40084. /**
  40085. * Defines which axis you'd like to control for left & right
  40086. * @param axis defines the axis to use
  40087. */
  40088. setAxisForLeftRight(axis: JoystickAxis): void;
  40089. /**
  40090. * Defines which axis you'd like to control for up & down
  40091. * @param axis defines the axis to use
  40092. */
  40093. setAxisForUpDown(axis: JoystickAxis): void;
  40094. private _drawVirtualJoystick;
  40095. /**
  40096. * Release internal HTML canvas
  40097. */
  40098. releaseCanvas(): void;
  40099. }
  40100. }
  40101. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40102. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40103. import { Nullable } from "babylonjs/types";
  40104. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40105. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40106. module "babylonjs/Cameras/freeCameraInputsManager" {
  40107. interface FreeCameraInputsManager {
  40108. /**
  40109. * Add virtual joystick input support to the input manager.
  40110. * @returns the current input manager
  40111. */
  40112. addVirtualJoystick(): FreeCameraInputsManager;
  40113. }
  40114. }
  40115. /**
  40116. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40118. */
  40119. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40120. /**
  40121. * Defines the camera the input is attached to.
  40122. */
  40123. camera: FreeCamera;
  40124. private _leftjoystick;
  40125. private _rightjoystick;
  40126. /**
  40127. * Gets the left stick of the virtual joystick.
  40128. * @returns The virtual Joystick
  40129. */
  40130. getLeftJoystick(): VirtualJoystick;
  40131. /**
  40132. * Gets the right stick of the virtual joystick.
  40133. * @returns The virtual Joystick
  40134. */
  40135. getRightJoystick(): VirtualJoystick;
  40136. /**
  40137. * Update the current camera state depending on the inputs that have been used this frame.
  40138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40139. */
  40140. checkInputs(): void;
  40141. /**
  40142. * Attach the input controls to a specific dom element to get the input from.
  40143. * @param element Defines the element the controls should be listened from
  40144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40145. */
  40146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40147. /**
  40148. * Detach the current controls from the specified dom element.
  40149. * @param element Defines the element to stop listening the inputs from
  40150. */
  40151. detachControl(element: Nullable<HTMLElement>): void;
  40152. /**
  40153. * Gets the class name of the current intput.
  40154. * @returns the class name
  40155. */
  40156. getClassName(): string;
  40157. /**
  40158. * Get the friendly name associated with the input class.
  40159. * @returns the input friendly name
  40160. */
  40161. getSimpleName(): string;
  40162. }
  40163. }
  40164. declare module "babylonjs/Cameras/Inputs/index" {
  40165. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40166. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40167. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40168. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40169. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40170. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40171. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40172. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40173. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40174. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40175. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40176. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40177. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40178. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40179. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40180. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40181. }
  40182. declare module "babylonjs/Cameras/touchCamera" {
  40183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40184. import { Scene } from "babylonjs/scene";
  40185. import { Vector3 } from "babylonjs/Maths/math.vector";
  40186. /**
  40187. * This represents a FPS type of camera controlled by touch.
  40188. * This is like a universal camera minus the Gamepad controls.
  40189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40190. */
  40191. export class TouchCamera extends FreeCamera {
  40192. /**
  40193. * Defines the touch sensibility for rotation.
  40194. * The higher the faster.
  40195. */
  40196. touchAngularSensibility: number;
  40197. /**
  40198. * Defines the touch sensibility for move.
  40199. * The higher the faster.
  40200. */
  40201. touchMoveSensibility: number;
  40202. /**
  40203. * Instantiates a new touch camera.
  40204. * This represents a FPS type of camera controlled by touch.
  40205. * This is like a universal camera minus the Gamepad controls.
  40206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40207. * @param name Define the name of the camera in the scene
  40208. * @param position Define the start position of the camera in the scene
  40209. * @param scene Define the scene the camera belongs to
  40210. */
  40211. constructor(name: string, position: Vector3, scene: Scene);
  40212. /**
  40213. * Gets the current object class name.
  40214. * @return the class name
  40215. */
  40216. getClassName(): string;
  40217. /** @hidden */
  40218. _setupInputs(): void;
  40219. }
  40220. }
  40221. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40222. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40223. import { Scene } from "babylonjs/scene";
  40224. import { Vector3 } from "babylonjs/Maths/math.vector";
  40225. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40226. import { Axis } from "babylonjs/Maths/math.axis";
  40227. /**
  40228. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40229. * being tilted forward or back and left or right.
  40230. */
  40231. export class DeviceOrientationCamera extends FreeCamera {
  40232. private _initialQuaternion;
  40233. private _quaternionCache;
  40234. private _tmpDragQuaternion;
  40235. private _disablePointerInputWhenUsingDeviceOrientation;
  40236. /**
  40237. * Creates a new device orientation camera
  40238. * @param name The name of the camera
  40239. * @param position The start position camera
  40240. * @param scene The scene the camera belongs to
  40241. */
  40242. constructor(name: string, position: Vector3, scene: Scene);
  40243. /**
  40244. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40245. */
  40246. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40247. private _dragFactor;
  40248. /**
  40249. * Enabled turning on the y axis when the orientation sensor is active
  40250. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40251. */
  40252. enableHorizontalDragging(dragFactor?: number): void;
  40253. /**
  40254. * Gets the current instance class name ("DeviceOrientationCamera").
  40255. * This helps avoiding instanceof at run time.
  40256. * @returns the class name
  40257. */
  40258. getClassName(): string;
  40259. /**
  40260. * @hidden
  40261. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40262. */
  40263. _checkInputs(): void;
  40264. /**
  40265. * Reset the camera to its default orientation on the specified axis only.
  40266. * @param axis The axis to reset
  40267. */
  40268. resetToCurrentRotation(axis?: Axis): void;
  40269. }
  40270. }
  40271. declare module "babylonjs/Gamepads/xboxGamepad" {
  40272. import { Observable } from "babylonjs/Misc/observable";
  40273. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40274. /**
  40275. * Defines supported buttons for XBox360 compatible gamepads
  40276. */
  40277. export enum Xbox360Button {
  40278. /** A */
  40279. A = 0,
  40280. /** B */
  40281. B = 1,
  40282. /** X */
  40283. X = 2,
  40284. /** Y */
  40285. Y = 3,
  40286. /** Start */
  40287. Start = 4,
  40288. /** Back */
  40289. Back = 5,
  40290. /** Left button */
  40291. LB = 6,
  40292. /** Right button */
  40293. RB = 7,
  40294. /** Left stick */
  40295. LeftStick = 8,
  40296. /** Right stick */
  40297. RightStick = 9
  40298. }
  40299. /** Defines values for XBox360 DPad */
  40300. export enum Xbox360Dpad {
  40301. /** Up */
  40302. Up = 0,
  40303. /** Down */
  40304. Down = 1,
  40305. /** Left */
  40306. Left = 2,
  40307. /** Right */
  40308. Right = 3
  40309. }
  40310. /**
  40311. * Defines a XBox360 gamepad
  40312. */
  40313. export class Xbox360Pad extends Gamepad {
  40314. private _leftTrigger;
  40315. private _rightTrigger;
  40316. private _onlefttriggerchanged;
  40317. private _onrighttriggerchanged;
  40318. private _onbuttondown;
  40319. private _onbuttonup;
  40320. private _ondpaddown;
  40321. private _ondpadup;
  40322. /** Observable raised when a button is pressed */
  40323. onButtonDownObservable: Observable<Xbox360Button>;
  40324. /** Observable raised when a button is released */
  40325. onButtonUpObservable: Observable<Xbox360Button>;
  40326. /** Observable raised when a pad is pressed */
  40327. onPadDownObservable: Observable<Xbox360Dpad>;
  40328. /** Observable raised when a pad is released */
  40329. onPadUpObservable: Observable<Xbox360Dpad>;
  40330. private _buttonA;
  40331. private _buttonB;
  40332. private _buttonX;
  40333. private _buttonY;
  40334. private _buttonBack;
  40335. private _buttonStart;
  40336. private _buttonLB;
  40337. private _buttonRB;
  40338. private _buttonLeftStick;
  40339. private _buttonRightStick;
  40340. private _dPadUp;
  40341. private _dPadDown;
  40342. private _dPadLeft;
  40343. private _dPadRight;
  40344. private _isXboxOnePad;
  40345. /**
  40346. * Creates a new XBox360 gamepad object
  40347. * @param id defines the id of this gamepad
  40348. * @param index defines its index
  40349. * @param gamepad defines the internal HTML gamepad object
  40350. * @param xboxOne defines if it is a XBox One gamepad
  40351. */
  40352. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40353. /**
  40354. * Defines the callback to call when left trigger is pressed
  40355. * @param callback defines the callback to use
  40356. */
  40357. onlefttriggerchanged(callback: (value: number) => void): void;
  40358. /**
  40359. * Defines the callback to call when right trigger is pressed
  40360. * @param callback defines the callback to use
  40361. */
  40362. onrighttriggerchanged(callback: (value: number) => void): void;
  40363. /**
  40364. * Gets the left trigger value
  40365. */
  40366. /**
  40367. * Sets the left trigger value
  40368. */
  40369. leftTrigger: number;
  40370. /**
  40371. * Gets the right trigger value
  40372. */
  40373. /**
  40374. * Sets the right trigger value
  40375. */
  40376. rightTrigger: number;
  40377. /**
  40378. * Defines the callback to call when a button is pressed
  40379. * @param callback defines the callback to use
  40380. */
  40381. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40382. /**
  40383. * Defines the callback to call when a button is released
  40384. * @param callback defines the callback to use
  40385. */
  40386. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40387. /**
  40388. * Defines the callback to call when a pad is pressed
  40389. * @param callback defines the callback to use
  40390. */
  40391. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40392. /**
  40393. * Defines the callback to call when a pad is released
  40394. * @param callback defines the callback to use
  40395. */
  40396. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40397. private _setButtonValue;
  40398. private _setDPadValue;
  40399. /**
  40400. * Gets the value of the `A` button
  40401. */
  40402. /**
  40403. * Sets the value of the `A` button
  40404. */
  40405. buttonA: number;
  40406. /**
  40407. * Gets the value of the `B` button
  40408. */
  40409. /**
  40410. * Sets the value of the `B` button
  40411. */
  40412. buttonB: number;
  40413. /**
  40414. * Gets the value of the `X` button
  40415. */
  40416. /**
  40417. * Sets the value of the `X` button
  40418. */
  40419. buttonX: number;
  40420. /**
  40421. * Gets the value of the `Y` button
  40422. */
  40423. /**
  40424. * Sets the value of the `Y` button
  40425. */
  40426. buttonY: number;
  40427. /**
  40428. * Gets the value of the `Start` button
  40429. */
  40430. /**
  40431. * Sets the value of the `Start` button
  40432. */
  40433. buttonStart: number;
  40434. /**
  40435. * Gets the value of the `Back` button
  40436. */
  40437. /**
  40438. * Sets the value of the `Back` button
  40439. */
  40440. buttonBack: number;
  40441. /**
  40442. * Gets the value of the `Left` button
  40443. */
  40444. /**
  40445. * Sets the value of the `Left` button
  40446. */
  40447. buttonLB: number;
  40448. /**
  40449. * Gets the value of the `Right` button
  40450. */
  40451. /**
  40452. * Sets the value of the `Right` button
  40453. */
  40454. buttonRB: number;
  40455. /**
  40456. * Gets the value of the Left joystick
  40457. */
  40458. /**
  40459. * Sets the value of the Left joystick
  40460. */
  40461. buttonLeftStick: number;
  40462. /**
  40463. * Gets the value of the Right joystick
  40464. */
  40465. /**
  40466. * Sets the value of the Right joystick
  40467. */
  40468. buttonRightStick: number;
  40469. /**
  40470. * Gets the value of D-pad up
  40471. */
  40472. /**
  40473. * Sets the value of D-pad up
  40474. */
  40475. dPadUp: number;
  40476. /**
  40477. * Gets the value of D-pad down
  40478. */
  40479. /**
  40480. * Sets the value of D-pad down
  40481. */
  40482. dPadDown: number;
  40483. /**
  40484. * Gets the value of D-pad left
  40485. */
  40486. /**
  40487. * Sets the value of D-pad left
  40488. */
  40489. dPadLeft: number;
  40490. /**
  40491. * Gets the value of D-pad right
  40492. */
  40493. /**
  40494. * Sets the value of D-pad right
  40495. */
  40496. dPadRight: number;
  40497. /**
  40498. * Force the gamepad to synchronize with device values
  40499. */
  40500. update(): void;
  40501. /**
  40502. * Disposes the gamepad
  40503. */
  40504. dispose(): void;
  40505. }
  40506. }
  40507. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40508. import { Observable } from "babylonjs/Misc/observable";
  40509. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40510. /**
  40511. * Defines supported buttons for DualShock compatible gamepads
  40512. */
  40513. export enum DualShockButton {
  40514. /** Cross */
  40515. Cross = 0,
  40516. /** Circle */
  40517. Circle = 1,
  40518. /** Square */
  40519. Square = 2,
  40520. /** Triangle */
  40521. Triangle = 3,
  40522. /** Options */
  40523. Options = 4,
  40524. /** Share */
  40525. Share = 5,
  40526. /** L1 */
  40527. L1 = 6,
  40528. /** R1 */
  40529. R1 = 7,
  40530. /** Left stick */
  40531. LeftStick = 8,
  40532. /** Right stick */
  40533. RightStick = 9
  40534. }
  40535. /** Defines values for DualShock DPad */
  40536. export enum DualShockDpad {
  40537. /** Up */
  40538. Up = 0,
  40539. /** Down */
  40540. Down = 1,
  40541. /** Left */
  40542. Left = 2,
  40543. /** Right */
  40544. Right = 3
  40545. }
  40546. /**
  40547. * Defines a DualShock gamepad
  40548. */
  40549. export class DualShockPad extends Gamepad {
  40550. private _leftTrigger;
  40551. private _rightTrigger;
  40552. private _onlefttriggerchanged;
  40553. private _onrighttriggerchanged;
  40554. private _onbuttondown;
  40555. private _onbuttonup;
  40556. private _ondpaddown;
  40557. private _ondpadup;
  40558. /** Observable raised when a button is pressed */
  40559. onButtonDownObservable: Observable<DualShockButton>;
  40560. /** Observable raised when a button is released */
  40561. onButtonUpObservable: Observable<DualShockButton>;
  40562. /** Observable raised when a pad is pressed */
  40563. onPadDownObservable: Observable<DualShockDpad>;
  40564. /** Observable raised when a pad is released */
  40565. onPadUpObservable: Observable<DualShockDpad>;
  40566. private _buttonCross;
  40567. private _buttonCircle;
  40568. private _buttonSquare;
  40569. private _buttonTriangle;
  40570. private _buttonShare;
  40571. private _buttonOptions;
  40572. private _buttonL1;
  40573. private _buttonR1;
  40574. private _buttonLeftStick;
  40575. private _buttonRightStick;
  40576. private _dPadUp;
  40577. private _dPadDown;
  40578. private _dPadLeft;
  40579. private _dPadRight;
  40580. /**
  40581. * Creates a new DualShock gamepad object
  40582. * @param id defines the id of this gamepad
  40583. * @param index defines its index
  40584. * @param gamepad defines the internal HTML gamepad object
  40585. */
  40586. constructor(id: string, index: number, gamepad: any);
  40587. /**
  40588. * Defines the callback to call when left trigger is pressed
  40589. * @param callback defines the callback to use
  40590. */
  40591. onlefttriggerchanged(callback: (value: number) => void): void;
  40592. /**
  40593. * Defines the callback to call when right trigger is pressed
  40594. * @param callback defines the callback to use
  40595. */
  40596. onrighttriggerchanged(callback: (value: number) => void): void;
  40597. /**
  40598. * Gets the left trigger value
  40599. */
  40600. /**
  40601. * Sets the left trigger value
  40602. */
  40603. leftTrigger: number;
  40604. /**
  40605. * Gets the right trigger value
  40606. */
  40607. /**
  40608. * Sets the right trigger value
  40609. */
  40610. rightTrigger: number;
  40611. /**
  40612. * Defines the callback to call when a button is pressed
  40613. * @param callback defines the callback to use
  40614. */
  40615. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40616. /**
  40617. * Defines the callback to call when a button is released
  40618. * @param callback defines the callback to use
  40619. */
  40620. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40621. /**
  40622. * Defines the callback to call when a pad is pressed
  40623. * @param callback defines the callback to use
  40624. */
  40625. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40626. /**
  40627. * Defines the callback to call when a pad is released
  40628. * @param callback defines the callback to use
  40629. */
  40630. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40631. private _setButtonValue;
  40632. private _setDPadValue;
  40633. /**
  40634. * Gets the value of the `Cross` button
  40635. */
  40636. /**
  40637. * Sets the value of the `Cross` button
  40638. */
  40639. buttonCross: number;
  40640. /**
  40641. * Gets the value of the `Circle` button
  40642. */
  40643. /**
  40644. * Sets the value of the `Circle` button
  40645. */
  40646. buttonCircle: number;
  40647. /**
  40648. * Gets the value of the `Square` button
  40649. */
  40650. /**
  40651. * Sets the value of the `Square` button
  40652. */
  40653. buttonSquare: number;
  40654. /**
  40655. * Gets the value of the `Triangle` button
  40656. */
  40657. /**
  40658. * Sets the value of the `Triangle` button
  40659. */
  40660. buttonTriangle: number;
  40661. /**
  40662. * Gets the value of the `Options` button
  40663. */
  40664. /**
  40665. * Sets the value of the `Options` button
  40666. */
  40667. buttonOptions: number;
  40668. /**
  40669. * Gets the value of the `Share` button
  40670. */
  40671. /**
  40672. * Sets the value of the `Share` button
  40673. */
  40674. buttonShare: number;
  40675. /**
  40676. * Gets the value of the `L1` button
  40677. */
  40678. /**
  40679. * Sets the value of the `L1` button
  40680. */
  40681. buttonL1: number;
  40682. /**
  40683. * Gets the value of the `R1` button
  40684. */
  40685. /**
  40686. * Sets the value of the `R1` button
  40687. */
  40688. buttonR1: number;
  40689. /**
  40690. * Gets the value of the Left joystick
  40691. */
  40692. /**
  40693. * Sets the value of the Left joystick
  40694. */
  40695. buttonLeftStick: number;
  40696. /**
  40697. * Gets the value of the Right joystick
  40698. */
  40699. /**
  40700. * Sets the value of the Right joystick
  40701. */
  40702. buttonRightStick: number;
  40703. /**
  40704. * Gets the value of D-pad up
  40705. */
  40706. /**
  40707. * Sets the value of D-pad up
  40708. */
  40709. dPadUp: number;
  40710. /**
  40711. * Gets the value of D-pad down
  40712. */
  40713. /**
  40714. * Sets the value of D-pad down
  40715. */
  40716. dPadDown: number;
  40717. /**
  40718. * Gets the value of D-pad left
  40719. */
  40720. /**
  40721. * Sets the value of D-pad left
  40722. */
  40723. dPadLeft: number;
  40724. /**
  40725. * Gets the value of D-pad right
  40726. */
  40727. /**
  40728. * Sets the value of D-pad right
  40729. */
  40730. dPadRight: number;
  40731. /**
  40732. * Force the gamepad to synchronize with device values
  40733. */
  40734. update(): void;
  40735. /**
  40736. * Disposes the gamepad
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module "babylonjs/Gamepads/gamepadManager" {
  40742. import { Observable } from "babylonjs/Misc/observable";
  40743. import { Nullable } from "babylonjs/types";
  40744. import { Scene } from "babylonjs/scene";
  40745. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40746. /**
  40747. * Manager for handling gamepads
  40748. */
  40749. export class GamepadManager {
  40750. private _scene?;
  40751. private _babylonGamepads;
  40752. private _oneGamepadConnected;
  40753. /** @hidden */
  40754. _isMonitoring: boolean;
  40755. private _gamepadEventSupported;
  40756. private _gamepadSupport;
  40757. /**
  40758. * observable to be triggered when the gamepad controller has been connected
  40759. */
  40760. onGamepadConnectedObservable: Observable<Gamepad>;
  40761. /**
  40762. * observable to be triggered when the gamepad controller has been disconnected
  40763. */
  40764. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40765. private _onGamepadConnectedEvent;
  40766. private _onGamepadDisconnectedEvent;
  40767. /**
  40768. * Initializes the gamepad manager
  40769. * @param _scene BabylonJS scene
  40770. */
  40771. constructor(_scene?: Scene | undefined);
  40772. /**
  40773. * The gamepads in the game pad manager
  40774. */
  40775. readonly gamepads: Gamepad[];
  40776. /**
  40777. * Get the gamepad controllers based on type
  40778. * @param type The type of gamepad controller
  40779. * @returns Nullable gamepad
  40780. */
  40781. getGamepadByType(type?: number): Nullable<Gamepad>;
  40782. /**
  40783. * Disposes the gamepad manager
  40784. */
  40785. dispose(): void;
  40786. private _addNewGamepad;
  40787. private _startMonitoringGamepads;
  40788. private _stopMonitoringGamepads;
  40789. /** @hidden */
  40790. _checkGamepadsStatus(): void;
  40791. private _updateGamepadObjects;
  40792. }
  40793. }
  40794. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40795. import { Nullable } from "babylonjs/types";
  40796. import { Scene } from "babylonjs/scene";
  40797. import { ISceneComponent } from "babylonjs/sceneComponent";
  40798. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40799. module "babylonjs/scene" {
  40800. interface Scene {
  40801. /** @hidden */
  40802. _gamepadManager: Nullable<GamepadManager>;
  40803. /**
  40804. * Gets the gamepad manager associated with the scene
  40805. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40806. */
  40807. gamepadManager: GamepadManager;
  40808. }
  40809. }
  40810. module "babylonjs/Cameras/freeCameraInputsManager" {
  40811. /**
  40812. * Interface representing a free camera inputs manager
  40813. */
  40814. interface FreeCameraInputsManager {
  40815. /**
  40816. * Adds gamepad input support to the FreeCameraInputsManager.
  40817. * @returns the FreeCameraInputsManager
  40818. */
  40819. addGamepad(): FreeCameraInputsManager;
  40820. }
  40821. }
  40822. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40823. /**
  40824. * Interface representing an arc rotate camera inputs manager
  40825. */
  40826. interface ArcRotateCameraInputsManager {
  40827. /**
  40828. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40829. * @returns the camera inputs manager
  40830. */
  40831. addGamepad(): ArcRotateCameraInputsManager;
  40832. }
  40833. }
  40834. /**
  40835. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40836. */
  40837. export class GamepadSystemSceneComponent implements ISceneComponent {
  40838. /**
  40839. * The component name helpfull to identify the component in the list of scene components.
  40840. */
  40841. readonly name: string;
  40842. /**
  40843. * The scene the component belongs to.
  40844. */
  40845. scene: Scene;
  40846. /**
  40847. * Creates a new instance of the component for the given scene
  40848. * @param scene Defines the scene to register the component in
  40849. */
  40850. constructor(scene: Scene);
  40851. /**
  40852. * Registers the component in a given scene
  40853. */
  40854. register(): void;
  40855. /**
  40856. * Rebuilds the elements related to this component in case of
  40857. * context lost for instance.
  40858. */
  40859. rebuild(): void;
  40860. /**
  40861. * Disposes the component and the associated ressources
  40862. */
  40863. dispose(): void;
  40864. private _beforeCameraUpdate;
  40865. }
  40866. }
  40867. declare module "babylonjs/Cameras/universalCamera" {
  40868. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40869. import { Scene } from "babylonjs/scene";
  40870. import { Vector3 } from "babylonjs/Maths/math.vector";
  40871. import "babylonjs/Gamepads/gamepadSceneComponent";
  40872. /**
  40873. * 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,
  40874. * which still works and will still be found in many Playgrounds.
  40875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40876. */
  40877. export class UniversalCamera extends TouchCamera {
  40878. /**
  40879. * Defines the gamepad rotation sensiblity.
  40880. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40881. */
  40882. gamepadAngularSensibility: number;
  40883. /**
  40884. * Defines the gamepad move sensiblity.
  40885. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40886. */
  40887. gamepadMoveSensibility: number;
  40888. /**
  40889. * 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,
  40890. * which still works and will still be found in many Playgrounds.
  40891. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40892. * @param name Define the name of the camera in the scene
  40893. * @param position Define the start position of the camera in the scene
  40894. * @param scene Define the scene the camera belongs to
  40895. */
  40896. constructor(name: string, position: Vector3, scene: Scene);
  40897. /**
  40898. * Gets the current object class name.
  40899. * @return the class name
  40900. */
  40901. getClassName(): string;
  40902. }
  40903. }
  40904. declare module "babylonjs/Cameras/gamepadCamera" {
  40905. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40906. import { Scene } from "babylonjs/scene";
  40907. import { Vector3 } from "babylonjs/Maths/math.vector";
  40908. /**
  40909. * This represents a FPS type of camera. This is only here for back compat purpose.
  40910. * Please use the UniversalCamera instead as both are identical.
  40911. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40912. */
  40913. export class GamepadCamera extends UniversalCamera {
  40914. /**
  40915. * Instantiates a new Gamepad Camera
  40916. * This represents a FPS type of camera. This is only here for back compat purpose.
  40917. * Please use the UniversalCamera instead as both are identical.
  40918. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40919. * @param name Define the name of the camera in the scene
  40920. * @param position Define the start position of the camera in the scene
  40921. * @param scene Define the scene the camera belongs to
  40922. */
  40923. constructor(name: string, position: Vector3, scene: Scene);
  40924. /**
  40925. * Gets the current object class name.
  40926. * @return the class name
  40927. */
  40928. getClassName(): string;
  40929. }
  40930. }
  40931. declare module "babylonjs/Shaders/pass.fragment" {
  40932. /** @hidden */
  40933. export var passPixelShader: {
  40934. name: string;
  40935. shader: string;
  40936. };
  40937. }
  40938. declare module "babylonjs/Shaders/passCube.fragment" {
  40939. /** @hidden */
  40940. export var passCubePixelShader: {
  40941. name: string;
  40942. shader: string;
  40943. };
  40944. }
  40945. declare module "babylonjs/PostProcesses/passPostProcess" {
  40946. import { Nullable } from "babylonjs/types";
  40947. import { Camera } from "babylonjs/Cameras/camera";
  40948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40949. import { Engine } from "babylonjs/Engines/engine";
  40950. import "babylonjs/Shaders/pass.fragment";
  40951. import "babylonjs/Shaders/passCube.fragment";
  40952. /**
  40953. * PassPostProcess which produces an output the same as it's input
  40954. */
  40955. export class PassPostProcess extends PostProcess {
  40956. /**
  40957. * Creates the PassPostProcess
  40958. * @param name The name of the effect.
  40959. * @param options The required width/height ratio to downsize to before computing the render pass.
  40960. * @param camera The camera to apply the render pass to.
  40961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40962. * @param engine The engine which the post process will be applied. (default: current engine)
  40963. * @param reusable If the post process can be reused on the same frame. (default: false)
  40964. * @param textureType The type of texture to be used when performing the post processing.
  40965. * @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)
  40966. */
  40967. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40968. }
  40969. /**
  40970. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40971. */
  40972. export class PassCubePostProcess extends PostProcess {
  40973. private _face;
  40974. /**
  40975. * Gets or sets the cube face to display.
  40976. * * 0 is +X
  40977. * * 1 is -X
  40978. * * 2 is +Y
  40979. * * 3 is -Y
  40980. * * 4 is +Z
  40981. * * 5 is -Z
  40982. */
  40983. face: number;
  40984. /**
  40985. * Creates the PassCubePostProcess
  40986. * @param name The name of the effect.
  40987. * @param options The required width/height ratio to downsize to before computing the render pass.
  40988. * @param camera The camera to apply the render pass to.
  40989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40990. * @param engine The engine which the post process will be applied. (default: current engine)
  40991. * @param reusable If the post process can be reused on the same frame. (default: false)
  40992. * @param textureType The type of texture to be used when performing the post processing.
  40993. * @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)
  40994. */
  40995. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40996. }
  40997. }
  40998. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40999. /** @hidden */
  41000. export var anaglyphPixelShader: {
  41001. name: string;
  41002. shader: string;
  41003. };
  41004. }
  41005. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41006. import { Engine } from "babylonjs/Engines/engine";
  41007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41008. import { Camera } from "babylonjs/Cameras/camera";
  41009. import "babylonjs/Shaders/anaglyph.fragment";
  41010. /**
  41011. * Postprocess used to generate anaglyphic rendering
  41012. */
  41013. export class AnaglyphPostProcess extends PostProcess {
  41014. private _passedProcess;
  41015. /**
  41016. * Creates a new AnaglyphPostProcess
  41017. * @param name defines postprocess name
  41018. * @param options defines creation options or target ratio scale
  41019. * @param rigCameras defines cameras using this postprocess
  41020. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41021. * @param engine defines hosting engine
  41022. * @param reusable defines if the postprocess will be reused multiple times per frame
  41023. */
  41024. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41025. }
  41026. }
  41027. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41028. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41029. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41030. import { Scene } from "babylonjs/scene";
  41031. import { Vector3 } from "babylonjs/Maths/math.vector";
  41032. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41033. /**
  41034. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41035. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41036. */
  41037. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41038. /**
  41039. * Creates a new AnaglyphArcRotateCamera
  41040. * @param name defines camera name
  41041. * @param alpha defines alpha angle (in radians)
  41042. * @param beta defines beta angle (in radians)
  41043. * @param radius defines radius
  41044. * @param target defines camera target
  41045. * @param interaxialDistance defines distance between each color axis
  41046. * @param scene defines the hosting scene
  41047. */
  41048. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41049. /**
  41050. * Gets camera class name
  41051. * @returns AnaglyphArcRotateCamera
  41052. */
  41053. getClassName(): string;
  41054. }
  41055. }
  41056. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41057. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41058. import { Scene } from "babylonjs/scene";
  41059. import { Vector3 } from "babylonjs/Maths/math.vector";
  41060. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41061. /**
  41062. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41063. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41064. */
  41065. export class AnaglyphFreeCamera extends FreeCamera {
  41066. /**
  41067. * Creates a new AnaglyphFreeCamera
  41068. * @param name defines camera name
  41069. * @param position defines initial position
  41070. * @param interaxialDistance defines distance between each color axis
  41071. * @param scene defines the hosting scene
  41072. */
  41073. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41074. /**
  41075. * Gets camera class name
  41076. * @returns AnaglyphFreeCamera
  41077. */
  41078. getClassName(): string;
  41079. }
  41080. }
  41081. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41082. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41083. import { Scene } from "babylonjs/scene";
  41084. import { Vector3 } from "babylonjs/Maths/math.vector";
  41085. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41086. /**
  41087. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41088. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41089. */
  41090. export class AnaglyphGamepadCamera extends GamepadCamera {
  41091. /**
  41092. * Creates a new AnaglyphGamepadCamera
  41093. * @param name defines camera name
  41094. * @param position defines initial position
  41095. * @param interaxialDistance defines distance between each color axis
  41096. * @param scene defines the hosting scene
  41097. */
  41098. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41099. /**
  41100. * Gets camera class name
  41101. * @returns AnaglyphGamepadCamera
  41102. */
  41103. getClassName(): string;
  41104. }
  41105. }
  41106. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41107. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41108. import { Scene } from "babylonjs/scene";
  41109. import { Vector3 } from "babylonjs/Maths/math.vector";
  41110. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41111. /**
  41112. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41113. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41114. */
  41115. export class AnaglyphUniversalCamera extends UniversalCamera {
  41116. /**
  41117. * Creates a new AnaglyphUniversalCamera
  41118. * @param name defines camera name
  41119. * @param position defines initial position
  41120. * @param interaxialDistance defines distance between each color axis
  41121. * @param scene defines the hosting scene
  41122. */
  41123. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41124. /**
  41125. * Gets camera class name
  41126. * @returns AnaglyphUniversalCamera
  41127. */
  41128. getClassName(): string;
  41129. }
  41130. }
  41131. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41132. /** @hidden */
  41133. export var stereoscopicInterlacePixelShader: {
  41134. name: string;
  41135. shader: string;
  41136. };
  41137. }
  41138. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41139. import { Camera } from "babylonjs/Cameras/camera";
  41140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41141. import { Engine } from "babylonjs/Engines/engine";
  41142. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41143. /**
  41144. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41145. */
  41146. export class StereoscopicInterlacePostProcess extends PostProcess {
  41147. private _stepSize;
  41148. private _passedProcess;
  41149. /**
  41150. * Initializes a StereoscopicInterlacePostProcess
  41151. * @param name The name of the effect.
  41152. * @param rigCameras The rig cameras to be appled to the post process
  41153. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41155. * @param engine The engine which the post process will be applied. (default: current engine)
  41156. * @param reusable If the post process can be reused on the same frame. (default: false)
  41157. */
  41158. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41159. }
  41160. }
  41161. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41162. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41163. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41164. import { Scene } from "babylonjs/scene";
  41165. import { Vector3 } from "babylonjs/Maths/math.vector";
  41166. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41167. /**
  41168. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41169. * @see http://doc.babylonjs.com/features/cameras
  41170. */
  41171. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41172. /**
  41173. * Creates a new StereoscopicArcRotateCamera
  41174. * @param name defines camera name
  41175. * @param alpha defines alpha angle (in radians)
  41176. * @param beta defines beta angle (in radians)
  41177. * @param radius defines radius
  41178. * @param target defines camera target
  41179. * @param interaxialDistance defines distance between each color axis
  41180. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41181. * @param scene defines the hosting scene
  41182. */
  41183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41184. /**
  41185. * Gets camera class name
  41186. * @returns StereoscopicArcRotateCamera
  41187. */
  41188. getClassName(): string;
  41189. }
  41190. }
  41191. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41192. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41193. import { Scene } from "babylonjs/scene";
  41194. import { Vector3 } from "babylonjs/Maths/math.vector";
  41195. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41196. /**
  41197. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41198. * @see http://doc.babylonjs.com/features/cameras
  41199. */
  41200. export class StereoscopicFreeCamera extends FreeCamera {
  41201. /**
  41202. * Creates a new StereoscopicFreeCamera
  41203. * @param name defines camera name
  41204. * @param position defines initial position
  41205. * @param interaxialDistance defines distance between each color axis
  41206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41207. * @param scene defines the hosting scene
  41208. */
  41209. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41210. /**
  41211. * Gets camera class name
  41212. * @returns StereoscopicFreeCamera
  41213. */
  41214. getClassName(): string;
  41215. }
  41216. }
  41217. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41218. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41219. import { Scene } from "babylonjs/scene";
  41220. import { Vector3 } from "babylonjs/Maths/math.vector";
  41221. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41222. /**
  41223. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41224. * @see http://doc.babylonjs.com/features/cameras
  41225. */
  41226. export class StereoscopicGamepadCamera extends GamepadCamera {
  41227. /**
  41228. * Creates a new StereoscopicGamepadCamera
  41229. * @param name defines camera name
  41230. * @param position defines initial position
  41231. * @param interaxialDistance defines distance between each color axis
  41232. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41233. * @param scene defines the hosting scene
  41234. */
  41235. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41236. /**
  41237. * Gets camera class name
  41238. * @returns StereoscopicGamepadCamera
  41239. */
  41240. getClassName(): string;
  41241. }
  41242. }
  41243. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41244. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41245. import { Scene } from "babylonjs/scene";
  41246. import { Vector3 } from "babylonjs/Maths/math.vector";
  41247. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41248. /**
  41249. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41250. * @see http://doc.babylonjs.com/features/cameras
  41251. */
  41252. export class StereoscopicUniversalCamera extends UniversalCamera {
  41253. /**
  41254. * Creates a new StereoscopicUniversalCamera
  41255. * @param name defines camera name
  41256. * @param position defines initial position
  41257. * @param interaxialDistance defines distance between each color axis
  41258. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41259. * @param scene defines the hosting scene
  41260. */
  41261. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41262. /**
  41263. * Gets camera class name
  41264. * @returns StereoscopicUniversalCamera
  41265. */
  41266. getClassName(): string;
  41267. }
  41268. }
  41269. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41270. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41271. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41272. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41273. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41274. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41275. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41276. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41277. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41278. }
  41279. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41280. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41281. import { Scene } from "babylonjs/scene";
  41282. import { Vector3 } from "babylonjs/Maths/math.vector";
  41283. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41284. /**
  41285. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41286. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41287. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41288. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41289. */
  41290. export class VirtualJoysticksCamera extends FreeCamera {
  41291. /**
  41292. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41293. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41294. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41295. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41296. * @param name Define the name of the camera in the scene
  41297. * @param position Define the start position of the camera in the scene
  41298. * @param scene Define the scene the camera belongs to
  41299. */
  41300. constructor(name: string, position: Vector3, scene: Scene);
  41301. /**
  41302. * Gets the current object class name.
  41303. * @return the class name
  41304. */
  41305. getClassName(): string;
  41306. }
  41307. }
  41308. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41309. import { Matrix } from "babylonjs/Maths/math.vector";
  41310. /**
  41311. * This represents all the required metrics to create a VR camera.
  41312. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41313. */
  41314. export class VRCameraMetrics {
  41315. /**
  41316. * Define the horizontal resolution off the screen.
  41317. */
  41318. hResolution: number;
  41319. /**
  41320. * Define the vertical resolution off the screen.
  41321. */
  41322. vResolution: number;
  41323. /**
  41324. * Define the horizontal screen size.
  41325. */
  41326. hScreenSize: number;
  41327. /**
  41328. * Define the vertical screen size.
  41329. */
  41330. vScreenSize: number;
  41331. /**
  41332. * Define the vertical screen center position.
  41333. */
  41334. vScreenCenter: number;
  41335. /**
  41336. * Define the distance of the eyes to the screen.
  41337. */
  41338. eyeToScreenDistance: number;
  41339. /**
  41340. * Define the distance between both lenses
  41341. */
  41342. lensSeparationDistance: number;
  41343. /**
  41344. * Define the distance between both viewer's eyes.
  41345. */
  41346. interpupillaryDistance: number;
  41347. /**
  41348. * Define the distortion factor of the VR postprocess.
  41349. * Please, touch with care.
  41350. */
  41351. distortionK: number[];
  41352. /**
  41353. * Define the chromatic aberration correction factors for the VR post process.
  41354. */
  41355. chromaAbCorrection: number[];
  41356. /**
  41357. * Define the scale factor of the post process.
  41358. * The smaller the better but the slower.
  41359. */
  41360. postProcessScaleFactor: number;
  41361. /**
  41362. * Define an offset for the lens center.
  41363. */
  41364. lensCenterOffset: number;
  41365. /**
  41366. * Define if the current vr camera should compensate the distortion of the lense or not.
  41367. */
  41368. compensateDistortion: boolean;
  41369. /**
  41370. * Defines if multiview should be enabled when rendering (Default: false)
  41371. */
  41372. multiviewEnabled: boolean;
  41373. /**
  41374. * Gets the rendering aspect ratio based on the provided resolutions.
  41375. */
  41376. readonly aspectRatio: number;
  41377. /**
  41378. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41379. */
  41380. readonly aspectRatioFov: number;
  41381. /**
  41382. * @hidden
  41383. */
  41384. readonly leftHMatrix: Matrix;
  41385. /**
  41386. * @hidden
  41387. */
  41388. readonly rightHMatrix: Matrix;
  41389. /**
  41390. * @hidden
  41391. */
  41392. readonly leftPreViewMatrix: Matrix;
  41393. /**
  41394. * @hidden
  41395. */
  41396. readonly rightPreViewMatrix: Matrix;
  41397. /**
  41398. * Get the default VRMetrics based on the most generic setup.
  41399. * @returns the default vr metrics
  41400. */
  41401. static GetDefault(): VRCameraMetrics;
  41402. }
  41403. }
  41404. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41405. /** @hidden */
  41406. export var vrDistortionCorrectionPixelShader: {
  41407. name: string;
  41408. shader: string;
  41409. };
  41410. }
  41411. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41412. import { Camera } from "babylonjs/Cameras/camera";
  41413. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41415. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41416. /**
  41417. * VRDistortionCorrectionPostProcess used for mobile VR
  41418. */
  41419. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41420. private _isRightEye;
  41421. private _distortionFactors;
  41422. private _postProcessScaleFactor;
  41423. private _lensCenterOffset;
  41424. private _scaleIn;
  41425. private _scaleFactor;
  41426. private _lensCenter;
  41427. /**
  41428. * Initializes the VRDistortionCorrectionPostProcess
  41429. * @param name The name of the effect.
  41430. * @param camera The camera to apply the render pass to.
  41431. * @param isRightEye If this is for the right eye distortion
  41432. * @param vrMetrics All the required metrics for the VR camera
  41433. */
  41434. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41435. }
  41436. }
  41437. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41438. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41439. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41440. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41441. import { Scene } from "babylonjs/scene";
  41442. import { Vector3 } from "babylonjs/Maths/math.vector";
  41443. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41444. import "babylonjs/Cameras/RigModes/vrRigMode";
  41445. /**
  41446. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41447. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41448. */
  41449. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41450. /**
  41451. * Creates a new VRDeviceOrientationArcRotateCamera
  41452. * @param name defines camera name
  41453. * @param alpha defines the camera rotation along the logitudinal axis
  41454. * @param beta defines the camera rotation along the latitudinal axis
  41455. * @param radius defines the camera distance from its target
  41456. * @param target defines the camera target
  41457. * @param scene defines the scene the camera belongs to
  41458. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41459. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41460. */
  41461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41462. /**
  41463. * Gets camera class name
  41464. * @returns VRDeviceOrientationArcRotateCamera
  41465. */
  41466. getClassName(): string;
  41467. }
  41468. }
  41469. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41470. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41471. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41472. import { Scene } from "babylonjs/scene";
  41473. import { Vector3 } from "babylonjs/Maths/math.vector";
  41474. import "babylonjs/Cameras/RigModes/vrRigMode";
  41475. /**
  41476. * Camera used to simulate VR rendering (based on FreeCamera)
  41477. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41478. */
  41479. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41480. /**
  41481. * Creates a new VRDeviceOrientationFreeCamera
  41482. * @param name defines camera name
  41483. * @param position defines the start position of the camera
  41484. * @param scene defines the scene the camera belongs to
  41485. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41486. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41487. */
  41488. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41489. /**
  41490. * Gets camera class name
  41491. * @returns VRDeviceOrientationFreeCamera
  41492. */
  41493. getClassName(): string;
  41494. }
  41495. }
  41496. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41497. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41498. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41499. import { Scene } from "babylonjs/scene";
  41500. import { Vector3 } from "babylonjs/Maths/math.vector";
  41501. import "babylonjs/Gamepads/gamepadSceneComponent";
  41502. /**
  41503. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41504. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41505. */
  41506. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41507. /**
  41508. * Creates a new VRDeviceOrientationGamepadCamera
  41509. * @param name defines camera name
  41510. * @param position defines the start position of the camera
  41511. * @param scene defines the scene the camera belongs to
  41512. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41513. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41514. */
  41515. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41516. /**
  41517. * Gets camera class name
  41518. * @returns VRDeviceOrientationGamepadCamera
  41519. */
  41520. getClassName(): string;
  41521. }
  41522. }
  41523. declare module "babylonjs/Materials/pushMaterial" {
  41524. import { Nullable } from "babylonjs/types";
  41525. import { Scene } from "babylonjs/scene";
  41526. import { Matrix } from "babylonjs/Maths/math.vector";
  41527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41528. import { Mesh } from "babylonjs/Meshes/mesh";
  41529. import { Material } from "babylonjs/Materials/material";
  41530. import { Effect } from "babylonjs/Materials/effect";
  41531. /**
  41532. * Base class of materials working in push mode in babylon JS
  41533. * @hidden
  41534. */
  41535. export class PushMaterial extends Material {
  41536. protected _activeEffect: Effect;
  41537. protected _normalMatrix: Matrix;
  41538. /**
  41539. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41540. * This means that the material can keep using a previous shader while a new one is being compiled.
  41541. * This is mostly used when shader parallel compilation is supported (true by default)
  41542. */
  41543. allowShaderHotSwapping: boolean;
  41544. constructor(name: string, scene: Scene);
  41545. getEffect(): Effect;
  41546. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41547. /**
  41548. * Binds the given world matrix to the active effect
  41549. *
  41550. * @param world the matrix to bind
  41551. */
  41552. bindOnlyWorldMatrix(world: Matrix): void;
  41553. /**
  41554. * Binds the given normal matrix to the active effect
  41555. *
  41556. * @param normalMatrix the matrix to bind
  41557. */
  41558. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41559. bind(world: Matrix, mesh?: Mesh): void;
  41560. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41561. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41562. }
  41563. }
  41564. declare module "babylonjs/Materials/materialFlags" {
  41565. /**
  41566. * This groups all the flags used to control the materials channel.
  41567. */
  41568. export class MaterialFlags {
  41569. private static _DiffuseTextureEnabled;
  41570. /**
  41571. * Are diffuse textures enabled in the application.
  41572. */
  41573. static DiffuseTextureEnabled: boolean;
  41574. private static _AmbientTextureEnabled;
  41575. /**
  41576. * Are ambient textures enabled in the application.
  41577. */
  41578. static AmbientTextureEnabled: boolean;
  41579. private static _OpacityTextureEnabled;
  41580. /**
  41581. * Are opacity textures enabled in the application.
  41582. */
  41583. static OpacityTextureEnabled: boolean;
  41584. private static _ReflectionTextureEnabled;
  41585. /**
  41586. * Are reflection textures enabled in the application.
  41587. */
  41588. static ReflectionTextureEnabled: boolean;
  41589. private static _EmissiveTextureEnabled;
  41590. /**
  41591. * Are emissive textures enabled in the application.
  41592. */
  41593. static EmissiveTextureEnabled: boolean;
  41594. private static _SpecularTextureEnabled;
  41595. /**
  41596. * Are specular textures enabled in the application.
  41597. */
  41598. static SpecularTextureEnabled: boolean;
  41599. private static _BumpTextureEnabled;
  41600. /**
  41601. * Are bump textures enabled in the application.
  41602. */
  41603. static BumpTextureEnabled: boolean;
  41604. private static _LightmapTextureEnabled;
  41605. /**
  41606. * Are lightmap textures enabled in the application.
  41607. */
  41608. static LightmapTextureEnabled: boolean;
  41609. private static _RefractionTextureEnabled;
  41610. /**
  41611. * Are refraction textures enabled in the application.
  41612. */
  41613. static RefractionTextureEnabled: boolean;
  41614. private static _ColorGradingTextureEnabled;
  41615. /**
  41616. * Are color grading textures enabled in the application.
  41617. */
  41618. static ColorGradingTextureEnabled: boolean;
  41619. private static _FresnelEnabled;
  41620. /**
  41621. * Are fresnels enabled in the application.
  41622. */
  41623. static FresnelEnabled: boolean;
  41624. private static _ClearCoatTextureEnabled;
  41625. /**
  41626. * Are clear coat textures enabled in the application.
  41627. */
  41628. static ClearCoatTextureEnabled: boolean;
  41629. private static _ClearCoatBumpTextureEnabled;
  41630. /**
  41631. * Are clear coat bump textures enabled in the application.
  41632. */
  41633. static ClearCoatBumpTextureEnabled: boolean;
  41634. private static _ClearCoatTintTextureEnabled;
  41635. /**
  41636. * Are clear coat tint textures enabled in the application.
  41637. */
  41638. static ClearCoatTintTextureEnabled: boolean;
  41639. private static _SheenTextureEnabled;
  41640. /**
  41641. * Are sheen textures enabled in the application.
  41642. */
  41643. static SheenTextureEnabled: boolean;
  41644. private static _AnisotropicTextureEnabled;
  41645. /**
  41646. * Are anisotropic textures enabled in the application.
  41647. */
  41648. static AnisotropicTextureEnabled: boolean;
  41649. private static _ThicknessTextureEnabled;
  41650. /**
  41651. * Are thickness textures enabled in the application.
  41652. */
  41653. static ThicknessTextureEnabled: boolean;
  41654. }
  41655. }
  41656. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41657. /** @hidden */
  41658. export var defaultFragmentDeclaration: {
  41659. name: string;
  41660. shader: string;
  41661. };
  41662. }
  41663. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41664. /** @hidden */
  41665. export var defaultUboDeclaration: {
  41666. name: string;
  41667. shader: string;
  41668. };
  41669. }
  41670. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41671. /** @hidden */
  41672. export var lightFragmentDeclaration: {
  41673. name: string;
  41674. shader: string;
  41675. };
  41676. }
  41677. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41678. /** @hidden */
  41679. export var lightUboDeclaration: {
  41680. name: string;
  41681. shader: string;
  41682. };
  41683. }
  41684. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41685. /** @hidden */
  41686. export var lightsFragmentFunctions: {
  41687. name: string;
  41688. shader: string;
  41689. };
  41690. }
  41691. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41692. /** @hidden */
  41693. export var shadowsFragmentFunctions: {
  41694. name: string;
  41695. shader: string;
  41696. };
  41697. }
  41698. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41699. /** @hidden */
  41700. export var fresnelFunction: {
  41701. name: string;
  41702. shader: string;
  41703. };
  41704. }
  41705. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41706. /** @hidden */
  41707. export var reflectionFunction: {
  41708. name: string;
  41709. shader: string;
  41710. };
  41711. }
  41712. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41713. /** @hidden */
  41714. export var bumpFragmentFunctions: {
  41715. name: string;
  41716. shader: string;
  41717. };
  41718. }
  41719. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41720. /** @hidden */
  41721. export var logDepthDeclaration: {
  41722. name: string;
  41723. shader: string;
  41724. };
  41725. }
  41726. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41727. /** @hidden */
  41728. export var bumpFragment: {
  41729. name: string;
  41730. shader: string;
  41731. };
  41732. }
  41733. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41734. /** @hidden */
  41735. export var depthPrePass: {
  41736. name: string;
  41737. shader: string;
  41738. };
  41739. }
  41740. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41741. /** @hidden */
  41742. export var lightFragment: {
  41743. name: string;
  41744. shader: string;
  41745. };
  41746. }
  41747. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41748. /** @hidden */
  41749. export var logDepthFragment: {
  41750. name: string;
  41751. shader: string;
  41752. };
  41753. }
  41754. declare module "babylonjs/Shaders/default.fragment" {
  41755. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41756. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41758. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41759. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41760. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41761. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41762. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41763. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41764. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41765. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41766. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41767. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41768. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41769. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41770. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41771. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41772. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41773. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41774. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41775. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41776. /** @hidden */
  41777. export var defaultPixelShader: {
  41778. name: string;
  41779. shader: string;
  41780. };
  41781. }
  41782. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41783. /** @hidden */
  41784. export var defaultVertexDeclaration: {
  41785. name: string;
  41786. shader: string;
  41787. };
  41788. }
  41789. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41790. /** @hidden */
  41791. export var bumpVertexDeclaration: {
  41792. name: string;
  41793. shader: string;
  41794. };
  41795. }
  41796. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41797. /** @hidden */
  41798. export var bumpVertex: {
  41799. name: string;
  41800. shader: string;
  41801. };
  41802. }
  41803. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41804. /** @hidden */
  41805. export var fogVertex: {
  41806. name: string;
  41807. shader: string;
  41808. };
  41809. }
  41810. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41811. /** @hidden */
  41812. export var shadowsVertex: {
  41813. name: string;
  41814. shader: string;
  41815. };
  41816. }
  41817. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41818. /** @hidden */
  41819. export var pointCloudVertex: {
  41820. name: string;
  41821. shader: string;
  41822. };
  41823. }
  41824. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41825. /** @hidden */
  41826. export var logDepthVertex: {
  41827. name: string;
  41828. shader: string;
  41829. };
  41830. }
  41831. declare module "babylonjs/Shaders/default.vertex" {
  41832. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41833. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41837. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41838. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41839. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41840. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41841. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41844. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41848. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41849. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41850. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41851. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41852. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41853. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41854. /** @hidden */
  41855. export var defaultVertexShader: {
  41856. name: string;
  41857. shader: string;
  41858. };
  41859. }
  41860. declare module "babylonjs/Materials/standardMaterial" {
  41861. import { SmartArray } from "babylonjs/Misc/smartArray";
  41862. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41863. import { Nullable } from "babylonjs/types";
  41864. import { Scene } from "babylonjs/scene";
  41865. import { Matrix } from "babylonjs/Maths/math.vector";
  41866. import { Color3 } from "babylonjs/Maths/math.color";
  41867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41869. import { Mesh } from "babylonjs/Meshes/mesh";
  41870. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41871. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41872. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41873. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41874. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41875. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41877. import "babylonjs/Shaders/default.fragment";
  41878. import "babylonjs/Shaders/default.vertex";
  41879. /** @hidden */
  41880. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41881. MAINUV1: boolean;
  41882. MAINUV2: boolean;
  41883. DIFFUSE: boolean;
  41884. DIFFUSEDIRECTUV: number;
  41885. AMBIENT: boolean;
  41886. AMBIENTDIRECTUV: number;
  41887. OPACITY: boolean;
  41888. OPACITYDIRECTUV: number;
  41889. OPACITYRGB: boolean;
  41890. REFLECTION: boolean;
  41891. EMISSIVE: boolean;
  41892. EMISSIVEDIRECTUV: number;
  41893. SPECULAR: boolean;
  41894. SPECULARDIRECTUV: number;
  41895. BUMP: boolean;
  41896. BUMPDIRECTUV: number;
  41897. PARALLAX: boolean;
  41898. PARALLAXOCCLUSION: boolean;
  41899. SPECULAROVERALPHA: boolean;
  41900. CLIPPLANE: boolean;
  41901. CLIPPLANE2: boolean;
  41902. CLIPPLANE3: boolean;
  41903. CLIPPLANE4: boolean;
  41904. ALPHATEST: boolean;
  41905. DEPTHPREPASS: boolean;
  41906. ALPHAFROMDIFFUSE: boolean;
  41907. POINTSIZE: boolean;
  41908. FOG: boolean;
  41909. SPECULARTERM: boolean;
  41910. DIFFUSEFRESNEL: boolean;
  41911. OPACITYFRESNEL: boolean;
  41912. REFLECTIONFRESNEL: boolean;
  41913. REFRACTIONFRESNEL: boolean;
  41914. EMISSIVEFRESNEL: boolean;
  41915. FRESNEL: boolean;
  41916. NORMAL: boolean;
  41917. UV1: boolean;
  41918. UV2: boolean;
  41919. VERTEXCOLOR: boolean;
  41920. VERTEXALPHA: boolean;
  41921. NUM_BONE_INFLUENCERS: number;
  41922. BonesPerMesh: number;
  41923. BONETEXTURE: boolean;
  41924. INSTANCES: boolean;
  41925. GLOSSINESS: boolean;
  41926. ROUGHNESS: boolean;
  41927. EMISSIVEASILLUMINATION: boolean;
  41928. LINKEMISSIVEWITHDIFFUSE: boolean;
  41929. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41930. LIGHTMAP: boolean;
  41931. LIGHTMAPDIRECTUV: number;
  41932. OBJECTSPACE_NORMALMAP: boolean;
  41933. USELIGHTMAPASSHADOWMAP: boolean;
  41934. REFLECTIONMAP_3D: boolean;
  41935. REFLECTIONMAP_SPHERICAL: boolean;
  41936. REFLECTIONMAP_PLANAR: boolean;
  41937. REFLECTIONMAP_CUBIC: boolean;
  41938. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41939. REFLECTIONMAP_PROJECTION: boolean;
  41940. REFLECTIONMAP_SKYBOX: boolean;
  41941. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41942. REFLECTIONMAP_EXPLICIT: boolean;
  41943. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41944. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41945. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41946. INVERTCUBICMAP: boolean;
  41947. LOGARITHMICDEPTH: boolean;
  41948. REFRACTION: boolean;
  41949. REFRACTIONMAP_3D: boolean;
  41950. REFLECTIONOVERALPHA: boolean;
  41951. TWOSIDEDLIGHTING: boolean;
  41952. SHADOWFLOAT: boolean;
  41953. MORPHTARGETS: boolean;
  41954. MORPHTARGETS_NORMAL: boolean;
  41955. MORPHTARGETS_TANGENT: boolean;
  41956. MORPHTARGETS_UV: boolean;
  41957. NUM_MORPH_INFLUENCERS: number;
  41958. NONUNIFORMSCALING: boolean;
  41959. PREMULTIPLYALPHA: boolean;
  41960. IMAGEPROCESSING: boolean;
  41961. VIGNETTE: boolean;
  41962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41963. VIGNETTEBLENDMODEOPAQUE: boolean;
  41964. TONEMAPPING: boolean;
  41965. TONEMAPPING_ACES: boolean;
  41966. CONTRAST: boolean;
  41967. COLORCURVES: boolean;
  41968. COLORGRADING: boolean;
  41969. COLORGRADING3D: boolean;
  41970. SAMPLER3DGREENDEPTH: boolean;
  41971. SAMPLER3DBGRMAP: boolean;
  41972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41973. MULTIVIEW: boolean;
  41974. /**
  41975. * If the reflection texture on this material is in linear color space
  41976. * @hidden
  41977. */
  41978. IS_REFLECTION_LINEAR: boolean;
  41979. /**
  41980. * If the refraction texture on this material is in linear color space
  41981. * @hidden
  41982. */
  41983. IS_REFRACTION_LINEAR: boolean;
  41984. EXPOSURE: boolean;
  41985. constructor();
  41986. setReflectionMode(modeToEnable: string): void;
  41987. }
  41988. /**
  41989. * This is the default material used in Babylon. It is the best trade off between quality
  41990. * and performances.
  41991. * @see http://doc.babylonjs.com/babylon101/materials
  41992. */
  41993. export class StandardMaterial extends PushMaterial {
  41994. private _diffuseTexture;
  41995. /**
  41996. * The basic texture of the material as viewed under a light.
  41997. */
  41998. diffuseTexture: Nullable<BaseTexture>;
  41999. private _ambientTexture;
  42000. /**
  42001. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42002. */
  42003. ambientTexture: Nullable<BaseTexture>;
  42004. private _opacityTexture;
  42005. /**
  42006. * Define the transparency of the material from a texture.
  42007. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42008. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42009. */
  42010. opacityTexture: Nullable<BaseTexture>;
  42011. private _reflectionTexture;
  42012. /**
  42013. * Define the texture used to display the reflection.
  42014. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42015. */
  42016. reflectionTexture: Nullable<BaseTexture>;
  42017. private _emissiveTexture;
  42018. /**
  42019. * Define texture of the material as if self lit.
  42020. * This will be mixed in the final result even in the absence of light.
  42021. */
  42022. emissiveTexture: Nullable<BaseTexture>;
  42023. private _specularTexture;
  42024. /**
  42025. * Define how the color and intensity of the highlight given by the light in the material.
  42026. */
  42027. specularTexture: Nullable<BaseTexture>;
  42028. private _bumpTexture;
  42029. /**
  42030. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42031. * 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.
  42032. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42033. */
  42034. bumpTexture: Nullable<BaseTexture>;
  42035. private _lightmapTexture;
  42036. /**
  42037. * Complex lighting can be computationally expensive to compute at runtime.
  42038. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42039. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42040. */
  42041. lightmapTexture: Nullable<BaseTexture>;
  42042. private _refractionTexture;
  42043. /**
  42044. * Define the texture used to display the refraction.
  42045. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42046. */
  42047. refractionTexture: Nullable<BaseTexture>;
  42048. /**
  42049. * The color of the material lit by the environmental background lighting.
  42050. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42051. */
  42052. ambientColor: Color3;
  42053. /**
  42054. * The basic color of the material as viewed under a light.
  42055. */
  42056. diffuseColor: Color3;
  42057. /**
  42058. * Define how the color and intensity of the highlight given by the light in the material.
  42059. */
  42060. specularColor: Color3;
  42061. /**
  42062. * Define the color of the material as if self lit.
  42063. * This will be mixed in the final result even in the absence of light.
  42064. */
  42065. emissiveColor: Color3;
  42066. /**
  42067. * Defines how sharp are the highlights in the material.
  42068. * The bigger the value the sharper giving a more glossy feeling to the result.
  42069. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42070. */
  42071. specularPower: number;
  42072. private _useAlphaFromDiffuseTexture;
  42073. /**
  42074. * Does the transparency come from the diffuse texture alpha channel.
  42075. */
  42076. useAlphaFromDiffuseTexture: boolean;
  42077. private _useEmissiveAsIllumination;
  42078. /**
  42079. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42080. */
  42081. useEmissiveAsIllumination: boolean;
  42082. private _linkEmissiveWithDiffuse;
  42083. /**
  42084. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42085. * the emissive level when the final color is close to one.
  42086. */
  42087. linkEmissiveWithDiffuse: boolean;
  42088. private _useSpecularOverAlpha;
  42089. /**
  42090. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42091. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42092. */
  42093. useSpecularOverAlpha: boolean;
  42094. private _useReflectionOverAlpha;
  42095. /**
  42096. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42097. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42098. */
  42099. useReflectionOverAlpha: boolean;
  42100. private _disableLighting;
  42101. /**
  42102. * Does lights from the scene impacts this material.
  42103. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42104. */
  42105. disableLighting: boolean;
  42106. private _useObjectSpaceNormalMap;
  42107. /**
  42108. * Allows using an object space normal map (instead of tangent space).
  42109. */
  42110. useObjectSpaceNormalMap: boolean;
  42111. private _useParallax;
  42112. /**
  42113. * Is parallax enabled or not.
  42114. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42115. */
  42116. useParallax: boolean;
  42117. private _useParallaxOcclusion;
  42118. /**
  42119. * Is parallax occlusion enabled or not.
  42120. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42121. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42122. */
  42123. useParallaxOcclusion: boolean;
  42124. /**
  42125. * 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.
  42126. */
  42127. parallaxScaleBias: number;
  42128. private _roughness;
  42129. /**
  42130. * Helps to define how blurry the reflections should appears in the material.
  42131. */
  42132. roughness: number;
  42133. /**
  42134. * In case of refraction, define the value of the index of refraction.
  42135. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42136. */
  42137. indexOfRefraction: number;
  42138. /**
  42139. * Invert the refraction texture alongside the y axis.
  42140. * It can be useful with procedural textures or probe for instance.
  42141. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42142. */
  42143. invertRefractionY: boolean;
  42144. /**
  42145. * Defines the alpha limits in alpha test mode.
  42146. */
  42147. alphaCutOff: number;
  42148. private _useLightmapAsShadowmap;
  42149. /**
  42150. * In case of light mapping, define whether the map contains light or shadow informations.
  42151. */
  42152. useLightmapAsShadowmap: boolean;
  42153. private _diffuseFresnelParameters;
  42154. /**
  42155. * Define the diffuse fresnel parameters of the material.
  42156. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42157. */
  42158. diffuseFresnelParameters: FresnelParameters;
  42159. private _opacityFresnelParameters;
  42160. /**
  42161. * Define the opacity fresnel parameters of the material.
  42162. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42163. */
  42164. opacityFresnelParameters: FresnelParameters;
  42165. private _reflectionFresnelParameters;
  42166. /**
  42167. * Define the reflection fresnel parameters of the material.
  42168. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42169. */
  42170. reflectionFresnelParameters: FresnelParameters;
  42171. private _refractionFresnelParameters;
  42172. /**
  42173. * Define the refraction fresnel parameters of the material.
  42174. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42175. */
  42176. refractionFresnelParameters: FresnelParameters;
  42177. private _emissiveFresnelParameters;
  42178. /**
  42179. * Define the emissive fresnel parameters of the material.
  42180. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42181. */
  42182. emissiveFresnelParameters: FresnelParameters;
  42183. private _useReflectionFresnelFromSpecular;
  42184. /**
  42185. * If true automatically deducts the fresnels values from the material specularity.
  42186. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42187. */
  42188. useReflectionFresnelFromSpecular: boolean;
  42189. private _useGlossinessFromSpecularMapAlpha;
  42190. /**
  42191. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42192. */
  42193. useGlossinessFromSpecularMapAlpha: boolean;
  42194. private _maxSimultaneousLights;
  42195. /**
  42196. * Defines the maximum number of lights that can be used in the material
  42197. */
  42198. maxSimultaneousLights: number;
  42199. private _invertNormalMapX;
  42200. /**
  42201. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42202. */
  42203. invertNormalMapX: boolean;
  42204. private _invertNormalMapY;
  42205. /**
  42206. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42207. */
  42208. invertNormalMapY: boolean;
  42209. private _twoSidedLighting;
  42210. /**
  42211. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42212. */
  42213. twoSidedLighting: boolean;
  42214. /**
  42215. * Default configuration related to image processing available in the standard Material.
  42216. */
  42217. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42218. /**
  42219. * Gets the image processing configuration used either in this material.
  42220. */
  42221. /**
  42222. * Sets the Default image processing configuration used either in the this material.
  42223. *
  42224. * If sets to null, the scene one is in use.
  42225. */
  42226. imageProcessingConfiguration: ImageProcessingConfiguration;
  42227. /**
  42228. * Keep track of the image processing observer to allow dispose and replace.
  42229. */
  42230. private _imageProcessingObserver;
  42231. /**
  42232. * Attaches a new image processing configuration to the Standard Material.
  42233. * @param configuration
  42234. */
  42235. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42236. /**
  42237. * Gets wether the color curves effect is enabled.
  42238. */
  42239. /**
  42240. * Sets wether the color curves effect is enabled.
  42241. */
  42242. cameraColorCurvesEnabled: boolean;
  42243. /**
  42244. * Gets wether the color grading effect is enabled.
  42245. */
  42246. /**
  42247. * Gets wether the color grading effect is enabled.
  42248. */
  42249. cameraColorGradingEnabled: boolean;
  42250. /**
  42251. * Gets wether tonemapping is enabled or not.
  42252. */
  42253. /**
  42254. * Sets wether tonemapping is enabled or not
  42255. */
  42256. cameraToneMappingEnabled: boolean;
  42257. /**
  42258. * The camera exposure used on this material.
  42259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42260. * This corresponds to a photographic exposure.
  42261. */
  42262. /**
  42263. * The camera exposure used on this material.
  42264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42265. * This corresponds to a photographic exposure.
  42266. */
  42267. cameraExposure: number;
  42268. /**
  42269. * Gets The camera contrast used on this material.
  42270. */
  42271. /**
  42272. * Sets The camera contrast used on this material.
  42273. */
  42274. cameraContrast: number;
  42275. /**
  42276. * Gets the Color Grading 2D Lookup Texture.
  42277. */
  42278. /**
  42279. * Sets the Color Grading 2D Lookup Texture.
  42280. */
  42281. cameraColorGradingTexture: Nullable<BaseTexture>;
  42282. /**
  42283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42285. * 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;
  42286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42287. */
  42288. /**
  42289. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42290. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42291. * 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;
  42292. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42293. */
  42294. cameraColorCurves: Nullable<ColorCurves>;
  42295. /**
  42296. * Custom callback helping to override the default shader used in the material.
  42297. */
  42298. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42299. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42300. protected _worldViewProjectionMatrix: Matrix;
  42301. protected _globalAmbientColor: Color3;
  42302. protected _useLogarithmicDepth: boolean;
  42303. protected _rebuildInParallel: boolean;
  42304. /**
  42305. * Instantiates a new standard material.
  42306. * This is the default material used in Babylon. It is the best trade off between quality
  42307. * and performances.
  42308. * @see http://doc.babylonjs.com/babylon101/materials
  42309. * @param name Define the name of the material in the scene
  42310. * @param scene Define the scene the material belong to
  42311. */
  42312. constructor(name: string, scene: Scene);
  42313. /**
  42314. * Gets a boolean indicating that current material needs to register RTT
  42315. */
  42316. readonly hasRenderTargetTextures: boolean;
  42317. /**
  42318. * Gets the current class name of the material e.g. "StandardMaterial"
  42319. * Mainly use in serialization.
  42320. * @returns the class name
  42321. */
  42322. getClassName(): string;
  42323. /**
  42324. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42325. * You can try switching to logarithmic depth.
  42326. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42327. */
  42328. useLogarithmicDepth: boolean;
  42329. /**
  42330. * Specifies if the material will require alpha blending
  42331. * @returns a boolean specifying if alpha blending is needed
  42332. */
  42333. needAlphaBlending(): boolean;
  42334. /**
  42335. * Specifies if this material should be rendered in alpha test mode
  42336. * @returns a boolean specifying if an alpha test is needed.
  42337. */
  42338. needAlphaTesting(): boolean;
  42339. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42340. /**
  42341. * Get the texture used for alpha test purpose.
  42342. * @returns the diffuse texture in case of the standard material.
  42343. */
  42344. getAlphaTestTexture(): Nullable<BaseTexture>;
  42345. /**
  42346. * Get if the submesh is ready to be used and all its information available.
  42347. * Child classes can use it to update shaders
  42348. * @param mesh defines the mesh to check
  42349. * @param subMesh defines which submesh to check
  42350. * @param useInstances specifies that instances should be used
  42351. * @returns a boolean indicating that the submesh is ready or not
  42352. */
  42353. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42354. /**
  42355. * Builds the material UBO layouts.
  42356. * Used internally during the effect preparation.
  42357. */
  42358. buildUniformLayout(): void;
  42359. /**
  42360. * Unbinds the material from the mesh
  42361. */
  42362. unbind(): void;
  42363. /**
  42364. * Binds the submesh to this material by preparing the effect and shader to draw
  42365. * @param world defines the world transformation matrix
  42366. * @param mesh defines the mesh containing the submesh
  42367. * @param subMesh defines the submesh to bind the material to
  42368. */
  42369. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42370. /**
  42371. * Get the list of animatables in the material.
  42372. * @returns the list of animatables object used in the material
  42373. */
  42374. getAnimatables(): IAnimatable[];
  42375. /**
  42376. * Gets the active textures from the material
  42377. * @returns an array of textures
  42378. */
  42379. getActiveTextures(): BaseTexture[];
  42380. /**
  42381. * Specifies if the material uses a texture
  42382. * @param texture defines the texture to check against the material
  42383. * @returns a boolean specifying if the material uses the texture
  42384. */
  42385. hasTexture(texture: BaseTexture): boolean;
  42386. /**
  42387. * Disposes the material
  42388. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42389. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42390. */
  42391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42392. /**
  42393. * Makes a duplicate of the material, and gives it a new name
  42394. * @param name defines the new name for the duplicated material
  42395. * @returns the cloned material
  42396. */
  42397. clone(name: string): StandardMaterial;
  42398. /**
  42399. * Serializes this material in a JSON representation
  42400. * @returns the serialized material object
  42401. */
  42402. serialize(): any;
  42403. /**
  42404. * Creates a standard material from parsed material data
  42405. * @param source defines the JSON representation of the material
  42406. * @param scene defines the hosting scene
  42407. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42408. * @returns a new standard material
  42409. */
  42410. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42411. /**
  42412. * Are diffuse textures enabled in the application.
  42413. */
  42414. static DiffuseTextureEnabled: boolean;
  42415. /**
  42416. * Are ambient textures enabled in the application.
  42417. */
  42418. static AmbientTextureEnabled: boolean;
  42419. /**
  42420. * Are opacity textures enabled in the application.
  42421. */
  42422. static OpacityTextureEnabled: boolean;
  42423. /**
  42424. * Are reflection textures enabled in the application.
  42425. */
  42426. static ReflectionTextureEnabled: boolean;
  42427. /**
  42428. * Are emissive textures enabled in the application.
  42429. */
  42430. static EmissiveTextureEnabled: boolean;
  42431. /**
  42432. * Are specular textures enabled in the application.
  42433. */
  42434. static SpecularTextureEnabled: boolean;
  42435. /**
  42436. * Are bump textures enabled in the application.
  42437. */
  42438. static BumpTextureEnabled: boolean;
  42439. /**
  42440. * Are lightmap textures enabled in the application.
  42441. */
  42442. static LightmapTextureEnabled: boolean;
  42443. /**
  42444. * Are refraction textures enabled in the application.
  42445. */
  42446. static RefractionTextureEnabled: boolean;
  42447. /**
  42448. * Are color grading textures enabled in the application.
  42449. */
  42450. static ColorGradingTextureEnabled: boolean;
  42451. /**
  42452. * Are fresnels enabled in the application.
  42453. */
  42454. static FresnelEnabled: boolean;
  42455. }
  42456. }
  42457. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42458. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42459. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42460. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42461. /** @hidden */
  42462. export var imageProcessingPixelShader: {
  42463. name: string;
  42464. shader: string;
  42465. };
  42466. }
  42467. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42468. import { Nullable } from "babylonjs/types";
  42469. import { Color4 } from "babylonjs/Maths/math.color";
  42470. import { Camera } from "babylonjs/Cameras/camera";
  42471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42472. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42473. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42474. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42475. import { Engine } from "babylonjs/Engines/engine";
  42476. import "babylonjs/Shaders/imageProcessing.fragment";
  42477. import "babylonjs/Shaders/postprocess.vertex";
  42478. /**
  42479. * ImageProcessingPostProcess
  42480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42481. */
  42482. export class ImageProcessingPostProcess extends PostProcess {
  42483. /**
  42484. * Default configuration related to image processing available in the PBR Material.
  42485. */
  42486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42487. /**
  42488. * Gets the image processing configuration used either in this material.
  42489. */
  42490. /**
  42491. * Sets the Default image processing configuration used either in the this material.
  42492. *
  42493. * If sets to null, the scene one is in use.
  42494. */
  42495. imageProcessingConfiguration: ImageProcessingConfiguration;
  42496. /**
  42497. * Keep track of the image processing observer to allow dispose and replace.
  42498. */
  42499. private _imageProcessingObserver;
  42500. /**
  42501. * Attaches a new image processing configuration to the PBR Material.
  42502. * @param configuration
  42503. */
  42504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42505. /**
  42506. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42507. */
  42508. /**
  42509. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42510. */
  42511. colorCurves: Nullable<ColorCurves>;
  42512. /**
  42513. * Gets wether the color curves effect is enabled.
  42514. */
  42515. /**
  42516. * Sets wether the color curves effect is enabled.
  42517. */
  42518. colorCurvesEnabled: boolean;
  42519. /**
  42520. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42521. */
  42522. /**
  42523. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42524. */
  42525. colorGradingTexture: Nullable<BaseTexture>;
  42526. /**
  42527. * Gets wether the color grading effect is enabled.
  42528. */
  42529. /**
  42530. * Gets wether the color grading effect is enabled.
  42531. */
  42532. colorGradingEnabled: boolean;
  42533. /**
  42534. * Gets exposure used in the effect.
  42535. */
  42536. /**
  42537. * Sets exposure used in the effect.
  42538. */
  42539. exposure: number;
  42540. /**
  42541. * Gets wether tonemapping is enabled or not.
  42542. */
  42543. /**
  42544. * Sets wether tonemapping is enabled or not
  42545. */
  42546. toneMappingEnabled: boolean;
  42547. /**
  42548. * Gets the type of tone mapping effect.
  42549. */
  42550. /**
  42551. * Sets the type of tone mapping effect.
  42552. */
  42553. toneMappingType: number;
  42554. /**
  42555. * Gets contrast used in the effect.
  42556. */
  42557. /**
  42558. * Sets contrast used in the effect.
  42559. */
  42560. contrast: number;
  42561. /**
  42562. * Gets Vignette stretch size.
  42563. */
  42564. /**
  42565. * Sets Vignette stretch size.
  42566. */
  42567. vignetteStretch: number;
  42568. /**
  42569. * Gets Vignette centre X Offset.
  42570. */
  42571. /**
  42572. * Sets Vignette centre X Offset.
  42573. */
  42574. vignetteCentreX: number;
  42575. /**
  42576. * Gets Vignette centre Y Offset.
  42577. */
  42578. /**
  42579. * Sets Vignette centre Y Offset.
  42580. */
  42581. vignetteCentreY: number;
  42582. /**
  42583. * Gets Vignette weight or intensity of the vignette effect.
  42584. */
  42585. /**
  42586. * Sets Vignette weight or intensity of the vignette effect.
  42587. */
  42588. vignetteWeight: number;
  42589. /**
  42590. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42591. * if vignetteEnabled is set to true.
  42592. */
  42593. /**
  42594. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42595. * if vignetteEnabled is set to true.
  42596. */
  42597. vignetteColor: Color4;
  42598. /**
  42599. * Gets Camera field of view used by the Vignette effect.
  42600. */
  42601. /**
  42602. * Sets Camera field of view used by the Vignette effect.
  42603. */
  42604. vignetteCameraFov: number;
  42605. /**
  42606. * Gets the vignette blend mode allowing different kind of effect.
  42607. */
  42608. /**
  42609. * Sets the vignette blend mode allowing different kind of effect.
  42610. */
  42611. vignetteBlendMode: number;
  42612. /**
  42613. * Gets wether the vignette effect is enabled.
  42614. */
  42615. /**
  42616. * Sets wether the vignette effect is enabled.
  42617. */
  42618. vignetteEnabled: boolean;
  42619. private _fromLinearSpace;
  42620. /**
  42621. * Gets wether the input of the processing is in Gamma or Linear Space.
  42622. */
  42623. /**
  42624. * Sets wether the input of the processing is in Gamma or Linear Space.
  42625. */
  42626. fromLinearSpace: boolean;
  42627. /**
  42628. * Defines cache preventing GC.
  42629. */
  42630. private _defines;
  42631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42632. /**
  42633. * "ImageProcessingPostProcess"
  42634. * @returns "ImageProcessingPostProcess"
  42635. */
  42636. getClassName(): string;
  42637. protected _updateParameters(): void;
  42638. dispose(camera?: Camera): void;
  42639. }
  42640. }
  42641. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42642. import { Scene } from "babylonjs/scene";
  42643. import { Color3 } from "babylonjs/Maths/math.color";
  42644. import { Mesh } from "babylonjs/Meshes/mesh";
  42645. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42646. import { Nullable } from "babylonjs/types";
  42647. /**
  42648. * Class containing static functions to help procedurally build meshes
  42649. */
  42650. export class GroundBuilder {
  42651. /**
  42652. * Creates a ground mesh
  42653. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42654. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42656. * @param name defines the name of the mesh
  42657. * @param options defines the options used to create the mesh
  42658. * @param scene defines the hosting scene
  42659. * @returns the ground mesh
  42660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42661. */
  42662. static CreateGround(name: string, options: {
  42663. width?: number;
  42664. height?: number;
  42665. subdivisions?: number;
  42666. subdivisionsX?: number;
  42667. subdivisionsY?: number;
  42668. updatable?: boolean;
  42669. }, scene: any): Mesh;
  42670. /**
  42671. * Creates a tiled ground mesh
  42672. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42673. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42674. * * 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
  42675. * * 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
  42676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42677. * @param name defines the name of the mesh
  42678. * @param options defines the options used to create the mesh
  42679. * @param scene defines the hosting scene
  42680. * @returns the tiled ground mesh
  42681. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42682. */
  42683. static CreateTiledGround(name: string, options: {
  42684. xmin: number;
  42685. zmin: number;
  42686. xmax: number;
  42687. zmax: number;
  42688. subdivisions?: {
  42689. w: number;
  42690. h: number;
  42691. };
  42692. precision?: {
  42693. w: number;
  42694. h: number;
  42695. };
  42696. updatable?: boolean;
  42697. }, scene?: Nullable<Scene>): Mesh;
  42698. /**
  42699. * Creates a ground mesh from a height map
  42700. * * The parameter `url` sets the URL of the height map image resource.
  42701. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42702. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42703. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42704. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42705. * * 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.
  42706. * * 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).
  42707. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42709. * @param name defines the name of the mesh
  42710. * @param url defines the url to the height map
  42711. * @param options defines the options used to create the mesh
  42712. * @param scene defines the hosting scene
  42713. * @returns the ground mesh
  42714. * @see https://doc.babylonjs.com/babylon101/height_map
  42715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42716. */
  42717. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42718. width?: number;
  42719. height?: number;
  42720. subdivisions?: number;
  42721. minHeight?: number;
  42722. maxHeight?: number;
  42723. colorFilter?: Color3;
  42724. alphaFilter?: number;
  42725. updatable?: boolean;
  42726. onReady?: (mesh: GroundMesh) => void;
  42727. }, scene?: Nullable<Scene>): GroundMesh;
  42728. }
  42729. }
  42730. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42731. import { Vector4 } from "babylonjs/Maths/math.vector";
  42732. import { Mesh } from "babylonjs/Meshes/mesh";
  42733. /**
  42734. * Class containing static functions to help procedurally build meshes
  42735. */
  42736. export class TorusBuilder {
  42737. /**
  42738. * Creates a torus mesh
  42739. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42740. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42741. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42745. * @param name defines the name of the mesh
  42746. * @param options defines the options used to create the mesh
  42747. * @param scene defines the hosting scene
  42748. * @returns the torus mesh
  42749. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42750. */
  42751. static CreateTorus(name: string, options: {
  42752. diameter?: number;
  42753. thickness?: number;
  42754. tessellation?: number;
  42755. updatable?: boolean;
  42756. sideOrientation?: number;
  42757. frontUVs?: Vector4;
  42758. backUVs?: Vector4;
  42759. }, scene: any): Mesh;
  42760. }
  42761. }
  42762. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42763. import { Vector4 } from "babylonjs/Maths/math.vector";
  42764. import { Color4 } from "babylonjs/Maths/math.color";
  42765. import { Mesh } from "babylonjs/Meshes/mesh";
  42766. /**
  42767. * Class containing static functions to help procedurally build meshes
  42768. */
  42769. export class CylinderBuilder {
  42770. /**
  42771. * Creates a cylinder or a cone mesh
  42772. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42773. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42774. * * 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.
  42775. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42776. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42777. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42778. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42779. * * 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).
  42780. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42781. * * 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).
  42782. * * 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
  42783. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42784. * * 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
  42785. * * 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.
  42786. * * If `enclose` is false, a ring surface is one element.
  42787. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42788. * * 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
  42789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42792. * @param name defines the name of the mesh
  42793. * @param options defines the options used to create the mesh
  42794. * @param scene defines the hosting scene
  42795. * @returns the cylinder mesh
  42796. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42797. */
  42798. static CreateCylinder(name: string, options: {
  42799. height?: number;
  42800. diameterTop?: number;
  42801. diameterBottom?: number;
  42802. diameter?: number;
  42803. tessellation?: number;
  42804. subdivisions?: number;
  42805. arc?: number;
  42806. faceColors?: Color4[];
  42807. faceUV?: Vector4[];
  42808. updatable?: boolean;
  42809. hasRings?: boolean;
  42810. enclose?: boolean;
  42811. cap?: number;
  42812. sideOrientation?: number;
  42813. frontUVs?: Vector4;
  42814. backUVs?: Vector4;
  42815. }, scene: any): Mesh;
  42816. }
  42817. }
  42818. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42819. import { Observable } from "babylonjs/Misc/observable";
  42820. import { Nullable } from "babylonjs/types";
  42821. import { Camera } from "babylonjs/Cameras/camera";
  42822. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42823. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42824. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42825. import { Scene } from "babylonjs/scene";
  42826. import { Vector3 } from "babylonjs/Maths/math.vector";
  42827. import { Color3 } from "babylonjs/Maths/math.color";
  42828. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42830. import { Mesh } from "babylonjs/Meshes/mesh";
  42831. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42832. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42833. import "babylonjs/Meshes/Builders/groundBuilder";
  42834. import "babylonjs/Meshes/Builders/torusBuilder";
  42835. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42836. import "babylonjs/Gamepads/gamepadSceneComponent";
  42837. import "babylonjs/Animations/animatable";
  42838. /**
  42839. * Options to modify the vr teleportation behavior.
  42840. */
  42841. export interface VRTeleportationOptions {
  42842. /**
  42843. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42844. */
  42845. floorMeshName?: string;
  42846. /**
  42847. * A list of meshes to be used as the teleportation floor. (default: empty)
  42848. */
  42849. floorMeshes?: Mesh[];
  42850. }
  42851. /**
  42852. * Options to modify the vr experience helper's behavior.
  42853. */
  42854. export interface VRExperienceHelperOptions extends WebVROptions {
  42855. /**
  42856. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42857. */
  42858. createDeviceOrientationCamera?: boolean;
  42859. /**
  42860. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42861. */
  42862. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42863. /**
  42864. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42865. */
  42866. laserToggle?: boolean;
  42867. /**
  42868. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42869. */
  42870. floorMeshes?: Mesh[];
  42871. /**
  42872. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42873. */
  42874. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42875. }
  42876. /**
  42877. * Event containing information after VR has been entered
  42878. */
  42879. export class OnAfterEnteringVRObservableEvent {
  42880. /**
  42881. * If entering vr was successful
  42882. */
  42883. success: boolean;
  42884. }
  42885. /**
  42886. * Helps to quickly add VR support to an existing scene.
  42887. * See http://doc.babylonjs.com/how_to/webvr_helper
  42888. */
  42889. export class VRExperienceHelper {
  42890. /** Options to modify the vr experience helper's behavior. */
  42891. webVROptions: VRExperienceHelperOptions;
  42892. private _scene;
  42893. private _position;
  42894. private _btnVR;
  42895. private _btnVRDisplayed;
  42896. private _webVRsupported;
  42897. private _webVRready;
  42898. private _webVRrequesting;
  42899. private _webVRpresenting;
  42900. private _hasEnteredVR;
  42901. private _fullscreenVRpresenting;
  42902. private _inputElement;
  42903. private _webVRCamera;
  42904. private _vrDeviceOrientationCamera;
  42905. private _deviceOrientationCamera;
  42906. private _existingCamera;
  42907. private _onKeyDown;
  42908. private _onVrDisplayPresentChange;
  42909. private _onVRDisplayChanged;
  42910. private _onVRRequestPresentStart;
  42911. private _onVRRequestPresentComplete;
  42912. /**
  42913. * 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)
  42914. */
  42915. enableGazeEvenWhenNoPointerLock: boolean;
  42916. /**
  42917. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42918. */
  42919. exitVROnDoubleTap: boolean;
  42920. /**
  42921. * Observable raised right before entering VR.
  42922. */
  42923. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42924. /**
  42925. * Observable raised when entering VR has completed.
  42926. */
  42927. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42928. /**
  42929. * Observable raised when exiting VR.
  42930. */
  42931. onExitingVRObservable: Observable<VRExperienceHelper>;
  42932. /**
  42933. * Observable raised when controller mesh is loaded.
  42934. */
  42935. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42936. /** Return this.onEnteringVRObservable
  42937. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42938. */
  42939. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42940. /** Return this.onExitingVRObservable
  42941. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42942. */
  42943. readonly onExitingVR: Observable<VRExperienceHelper>;
  42944. /** Return this.onControllerMeshLoadedObservable
  42945. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42946. */
  42947. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42948. private _rayLength;
  42949. private _useCustomVRButton;
  42950. private _teleportationRequested;
  42951. private _teleportActive;
  42952. private _floorMeshName;
  42953. private _floorMeshesCollection;
  42954. private _rotationAllowed;
  42955. private _teleportBackwardsVector;
  42956. private _teleportationTarget;
  42957. private _isDefaultTeleportationTarget;
  42958. private _postProcessMove;
  42959. private _teleportationFillColor;
  42960. private _teleportationBorderColor;
  42961. private _rotationAngle;
  42962. private _haloCenter;
  42963. private _cameraGazer;
  42964. private _padSensibilityUp;
  42965. private _padSensibilityDown;
  42966. private _leftController;
  42967. private _rightController;
  42968. /**
  42969. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42970. */
  42971. onNewMeshSelected: Observable<AbstractMesh>;
  42972. /**
  42973. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42974. * This observable will provide the mesh and the controller used to select the mesh
  42975. */
  42976. onMeshSelectedWithController: Observable<{
  42977. mesh: AbstractMesh;
  42978. controller: WebVRController;
  42979. }>;
  42980. /**
  42981. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42982. */
  42983. onNewMeshPicked: Observable<PickingInfo>;
  42984. private _circleEase;
  42985. /**
  42986. * Observable raised before camera teleportation
  42987. */
  42988. onBeforeCameraTeleport: Observable<Vector3>;
  42989. /**
  42990. * Observable raised after camera teleportation
  42991. */
  42992. onAfterCameraTeleport: Observable<Vector3>;
  42993. /**
  42994. * Observable raised when current selected mesh gets unselected
  42995. */
  42996. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42997. private _raySelectionPredicate;
  42998. /**
  42999. * To be optionaly changed by user to define custom ray selection
  43000. */
  43001. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43002. /**
  43003. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43004. */
  43005. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43006. /**
  43007. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43008. */
  43009. teleportationEnabled: boolean;
  43010. private _defaultHeight;
  43011. private _teleportationInitialized;
  43012. private _interactionsEnabled;
  43013. private _interactionsRequested;
  43014. private _displayGaze;
  43015. private _displayLaserPointer;
  43016. /**
  43017. * The mesh used to display where the user is going to teleport.
  43018. */
  43019. /**
  43020. * Sets the mesh to be used to display where the user is going to teleport.
  43021. */
  43022. teleportationTarget: Mesh;
  43023. /**
  43024. * 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
  43025. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43026. * See http://doc.babylonjs.com/resources/baking_transformations
  43027. */
  43028. gazeTrackerMesh: Mesh;
  43029. /**
  43030. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43031. */
  43032. updateGazeTrackerScale: boolean;
  43033. /**
  43034. * If the gaze trackers color should be updated when selecting meshes
  43035. */
  43036. updateGazeTrackerColor: boolean;
  43037. /**
  43038. * If the controller laser color should be updated when selecting meshes
  43039. */
  43040. updateControllerLaserColor: boolean;
  43041. /**
  43042. * The gaze tracking mesh corresponding to the left controller
  43043. */
  43044. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43045. /**
  43046. * The gaze tracking mesh corresponding to the right controller
  43047. */
  43048. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43049. /**
  43050. * If the ray of the gaze should be displayed.
  43051. */
  43052. /**
  43053. * Sets if the ray of the gaze should be displayed.
  43054. */
  43055. displayGaze: boolean;
  43056. /**
  43057. * If the ray of the LaserPointer should be displayed.
  43058. */
  43059. /**
  43060. * Sets if the ray of the LaserPointer should be displayed.
  43061. */
  43062. displayLaserPointer: boolean;
  43063. /**
  43064. * The deviceOrientationCamera used as the camera when not in VR.
  43065. */
  43066. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43067. /**
  43068. * Based on the current WebVR support, returns the current VR camera used.
  43069. */
  43070. readonly currentVRCamera: Nullable<Camera>;
  43071. /**
  43072. * The webVRCamera which is used when in VR.
  43073. */
  43074. readonly webVRCamera: WebVRFreeCamera;
  43075. /**
  43076. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43077. */
  43078. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43079. /**
  43080. * The html button that is used to trigger entering into VR.
  43081. */
  43082. readonly vrButton: Nullable<HTMLButtonElement>;
  43083. private readonly _teleportationRequestInitiated;
  43084. /**
  43085. * Defines wether or not Pointer lock should be requested when switching to
  43086. * full screen.
  43087. */
  43088. requestPointerLockOnFullScreen: boolean;
  43089. /**
  43090. * Instantiates a VRExperienceHelper.
  43091. * Helps to quickly add VR support to an existing scene.
  43092. * @param scene The scene the VRExperienceHelper belongs to.
  43093. * @param webVROptions Options to modify the vr experience helper's behavior.
  43094. */
  43095. constructor(scene: Scene,
  43096. /** Options to modify the vr experience helper's behavior. */
  43097. webVROptions?: VRExperienceHelperOptions);
  43098. private _onDefaultMeshLoaded;
  43099. private _onResize;
  43100. private _onFullscreenChange;
  43101. /**
  43102. * Gets a value indicating if we are currently in VR mode.
  43103. */
  43104. readonly isInVRMode: boolean;
  43105. private onVrDisplayPresentChange;
  43106. private onVRDisplayChanged;
  43107. private moveButtonToBottomRight;
  43108. private displayVRButton;
  43109. private updateButtonVisibility;
  43110. private _cachedAngularSensibility;
  43111. /**
  43112. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43113. * Otherwise, will use the fullscreen API.
  43114. */
  43115. enterVR(): void;
  43116. /**
  43117. * Attempt to exit VR, or fullscreen.
  43118. */
  43119. exitVR(): void;
  43120. /**
  43121. * The position of the vr experience helper.
  43122. */
  43123. /**
  43124. * Sets the position of the vr experience helper.
  43125. */
  43126. position: Vector3;
  43127. /**
  43128. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43129. */
  43130. enableInteractions(): void;
  43131. private readonly _noControllerIsActive;
  43132. private beforeRender;
  43133. private _isTeleportationFloor;
  43134. /**
  43135. * Adds a floor mesh to be used for teleportation.
  43136. * @param floorMesh the mesh to be used for teleportation.
  43137. */
  43138. addFloorMesh(floorMesh: Mesh): void;
  43139. /**
  43140. * Removes a floor mesh from being used for teleportation.
  43141. * @param floorMesh the mesh to be removed.
  43142. */
  43143. removeFloorMesh(floorMesh: Mesh): void;
  43144. /**
  43145. * Enables interactions and teleportation using the VR controllers and gaze.
  43146. * @param vrTeleportationOptions options to modify teleportation behavior.
  43147. */
  43148. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43149. private _onNewGamepadConnected;
  43150. private _tryEnableInteractionOnController;
  43151. private _onNewGamepadDisconnected;
  43152. private _enableInteractionOnController;
  43153. private _checkTeleportWithRay;
  43154. private _checkRotate;
  43155. private _checkTeleportBackwards;
  43156. private _enableTeleportationOnController;
  43157. private _createTeleportationCircles;
  43158. private _displayTeleportationTarget;
  43159. private _hideTeleportationTarget;
  43160. private _rotateCamera;
  43161. private _moveTeleportationSelectorTo;
  43162. private _workingVector;
  43163. private _workingQuaternion;
  43164. private _workingMatrix;
  43165. /**
  43166. * Teleports the users feet to the desired location
  43167. * @param location The location where the user's feet should be placed
  43168. */
  43169. teleportCamera(location: Vector3): void;
  43170. private _convertNormalToDirectionOfRay;
  43171. private _castRayAndSelectObject;
  43172. private _notifySelectedMeshUnselected;
  43173. /**
  43174. * Sets the color of the laser ray from the vr controllers.
  43175. * @param color new color for the ray.
  43176. */
  43177. changeLaserColor(color: Color3): void;
  43178. /**
  43179. * Sets the color of the ray from the vr headsets gaze.
  43180. * @param color new color for the ray.
  43181. */
  43182. changeGazeColor(color: Color3): void;
  43183. /**
  43184. * Exits VR and disposes of the vr experience helper
  43185. */
  43186. dispose(): void;
  43187. /**
  43188. * Gets the name of the VRExperienceHelper class
  43189. * @returns "VRExperienceHelper"
  43190. */
  43191. getClassName(): string;
  43192. }
  43193. }
  43194. declare module "babylonjs/Cameras/VR/index" {
  43195. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43196. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43197. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43198. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43199. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43200. export * from "babylonjs/Cameras/VR/webVRCamera";
  43201. }
  43202. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43203. import { Nullable } from "babylonjs/types";
  43204. import { IDisposable } from "babylonjs/scene";
  43205. /**
  43206. * States of the webXR experience
  43207. */
  43208. export enum WebXRState {
  43209. /**
  43210. * Transitioning to being in XR mode
  43211. */
  43212. ENTERING_XR = 0,
  43213. /**
  43214. * Transitioning to non XR mode
  43215. */
  43216. EXITING_XR = 1,
  43217. /**
  43218. * In XR mode and presenting
  43219. */
  43220. IN_XR = 2,
  43221. /**
  43222. * Not entered XR mode
  43223. */
  43224. NOT_IN_XR = 3
  43225. }
  43226. /**
  43227. * Abstraction of the XR render target
  43228. */
  43229. export interface WebXRRenderTarget extends IDisposable {
  43230. /**
  43231. * xrpresent context of the canvas which can be used to display/mirror xr content
  43232. */
  43233. canvasContext: WebGLRenderingContext;
  43234. /**
  43235. * xr layer for the canvas
  43236. */
  43237. xrLayer: Nullable<XRWebGLLayer>;
  43238. /**
  43239. * Initializes the xr layer for the session
  43240. * @param xrSession xr session
  43241. * @returns a promise that will resolve once the XR Layer has been created
  43242. */
  43243. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43244. }
  43245. }
  43246. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43247. import { Nullable } from "babylonjs/types";
  43248. import { Observable } from "babylonjs/Misc/observable";
  43249. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43250. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43251. /**
  43252. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43253. */
  43254. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43255. private _engine;
  43256. private _canvas;
  43257. /**
  43258. * xrpresent context of the canvas which can be used to display/mirror xr content
  43259. */
  43260. canvasContext: WebGLRenderingContext;
  43261. /**
  43262. * xr layer for the canvas
  43263. */
  43264. xrLayer: Nullable<XRWebGLLayer>;
  43265. /**
  43266. * Initializes the xr layer for the session
  43267. * @param xrSession xr session
  43268. * @returns a promise that will resolve once the XR Layer has been created
  43269. */
  43270. initializeXRLayerAsync(xrSession: any): any;
  43271. /**
  43272. * Initializes the canvas to be added/removed upon entering/exiting xr
  43273. * @param engine the Babylon engine
  43274. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43275. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43276. */
  43277. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43278. /**
  43279. * Disposes of the object
  43280. */
  43281. dispose(): void;
  43282. private _setManagedOutputCanvas;
  43283. private _addCanvas;
  43284. private _removeCanvas;
  43285. }
  43286. }
  43287. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43288. import { Observable } from "babylonjs/Misc/observable";
  43289. import { Nullable } from "babylonjs/types";
  43290. import { IDisposable, Scene } from "babylonjs/scene";
  43291. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43292. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43293. /**
  43294. * Manages an XRSession to work with Babylon's engine
  43295. * @see https://doc.babylonjs.com/how_to/webxr
  43296. */
  43297. export class WebXRSessionManager implements IDisposable {
  43298. private scene;
  43299. /**
  43300. * Fires every time a new xrFrame arrives which can be used to update the camera
  43301. */
  43302. onXRFrameObservable: Observable<any>;
  43303. /**
  43304. * Fires when the xr session is ended either by the device or manually done
  43305. */
  43306. onXRSessionEnded: Observable<any>;
  43307. /**
  43308. * Underlying xr session
  43309. */
  43310. session: XRSession;
  43311. /**
  43312. * Type of reference space used when creating the session
  43313. */
  43314. referenceSpace: XRReferenceSpace;
  43315. /**
  43316. * Current XR frame
  43317. */
  43318. currentFrame: Nullable<XRFrame>;
  43319. private _xrNavigator;
  43320. private baseLayer;
  43321. private _rttProvider;
  43322. private _sessionEnded;
  43323. /**
  43324. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43325. * @param scene The scene which the session should be created for
  43326. */
  43327. constructor(scene: Scene);
  43328. /**
  43329. * Initializes the manager
  43330. * After initialization enterXR can be called to start an XR session
  43331. * @returns Promise which resolves after it is initialized
  43332. */
  43333. initializeAsync(): Promise<void>;
  43334. /**
  43335. * Initializes an xr session
  43336. * @param xrSessionMode mode to initialize
  43337. * @param optionalFeatures defines optional values to pass to the session builder
  43338. * @returns a promise which will resolve once the session has been initialized
  43339. */
  43340. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43341. /**
  43342. * Sets the reference space on the xr session
  43343. * @param referenceSpace space to set
  43344. * @returns a promise that will resolve once the reference space has been set
  43345. */
  43346. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43347. /**
  43348. * Updates the render state of the session
  43349. * @param state state to set
  43350. * @returns a promise that resolves once the render state has been updated
  43351. */
  43352. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43353. /**
  43354. * Starts rendering to the xr layer
  43355. * @returns a promise that will resolve once rendering has started
  43356. */
  43357. startRenderingToXRAsync(): Promise<void>;
  43358. /**
  43359. * Gets the correct render target texture to be rendered this frame for this eye
  43360. * @param eye the eye for which to get the render target
  43361. * @returns the render target for the specified eye
  43362. */
  43363. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43364. /**
  43365. * Stops the xrSession and restores the renderloop
  43366. * @returns Promise which resolves after it exits XR
  43367. */
  43368. exitXRAsync(): Promise<void>;
  43369. /**
  43370. * Checks if a session would be supported for the creation options specified
  43371. * @param sessionMode session mode to check if supported eg. immersive-vr
  43372. * @returns true if supported
  43373. */
  43374. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43375. /**
  43376. * Creates a WebXRRenderTarget object for the XR session
  43377. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43378. * @returns a WebXR render target to which the session can render
  43379. */
  43380. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43381. /**
  43382. * @hidden
  43383. * Converts the render layer of xrSession to a render target
  43384. * @param session session to create render target for
  43385. * @param scene scene the new render target should be created for
  43386. */
  43387. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43388. /**
  43389. * Disposes of the session manager
  43390. */
  43391. dispose(): void;
  43392. }
  43393. }
  43394. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43395. import { Scene } from "babylonjs/scene";
  43396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43397. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43398. /**
  43399. * WebXR Camera which holds the views for the xrSession
  43400. * @see https://doc.babylonjs.com/how_to/webxr
  43401. */
  43402. export class WebXRCamera extends FreeCamera {
  43403. private static _TmpMatrix;
  43404. /**
  43405. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43406. * @param name the name of the camera
  43407. * @param scene the scene to add the camera to
  43408. */
  43409. constructor(name: string, scene: Scene);
  43410. private _updateNumberOfRigCameras;
  43411. /** @hidden */
  43412. _updateForDualEyeDebugging(): void;
  43413. /**
  43414. * Updates the cameras position from the current pose information of the XR session
  43415. * @param xrSessionManager the session containing pose information
  43416. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43417. */
  43418. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43419. }
  43420. }
  43421. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43422. import { Observable } from "babylonjs/Misc/observable";
  43423. import { IDisposable, Scene } from "babylonjs/scene";
  43424. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43426. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43427. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43428. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43429. /**
  43430. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43431. * @see https://doc.babylonjs.com/how_to/webxr
  43432. */
  43433. export class WebXRExperienceHelper implements IDisposable {
  43434. private scene;
  43435. /**
  43436. * 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
  43437. */
  43438. container: AbstractMesh;
  43439. /**
  43440. * Camera used to render xr content
  43441. */
  43442. camera: WebXRCamera;
  43443. /**
  43444. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43445. */
  43446. state: WebXRState;
  43447. private _setState;
  43448. private static _TmpVector;
  43449. /**
  43450. * Fires when the state of the experience helper has changed
  43451. */
  43452. onStateChangedObservable: Observable<WebXRState>;
  43453. /** Session manager used to keep track of xr session */
  43454. sessionManager: WebXRSessionManager;
  43455. private _nonVRCamera;
  43456. private _originalSceneAutoClear;
  43457. private _supported;
  43458. /**
  43459. * Creates the experience helper
  43460. * @param scene the scene to attach the experience helper to
  43461. * @returns a promise for the experience helper
  43462. */
  43463. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43464. /**
  43465. * Creates a WebXRExperienceHelper
  43466. * @param scene The scene the helper should be created in
  43467. */
  43468. private constructor();
  43469. /**
  43470. * Exits XR mode and returns the scene to its original state
  43471. * @returns promise that resolves after xr mode has exited
  43472. */
  43473. exitXRAsync(): Promise<void>;
  43474. /**
  43475. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43476. * @param sessionMode options for the XR session
  43477. * @param referenceSpaceType frame of reference of the XR session
  43478. * @param renderTarget the output canvas that will be used to enter XR mode
  43479. * @returns promise that resolves after xr mode has entered
  43480. */
  43481. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43482. /**
  43483. * Updates the global position of the camera by moving the camera's container
  43484. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43485. * @param position The desired global position of the camera
  43486. */
  43487. setPositionOfCameraUsingContainer(position: Vector3): void;
  43488. /**
  43489. * Rotates the xr camera by rotating the camera's container around the camera's position
  43490. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43491. * @param rotation the desired quaternion rotation to apply to the camera
  43492. */
  43493. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43494. /**
  43495. * Disposes of the experience helper
  43496. */
  43497. dispose(): void;
  43498. }
  43499. }
  43500. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43501. import { Nullable } from "babylonjs/types";
  43502. import { Observable } from "babylonjs/Misc/observable";
  43503. import { IDisposable, Scene } from "babylonjs/scene";
  43504. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43505. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43506. /**
  43507. * Button which can be used to enter a different mode of XR
  43508. */
  43509. export class WebXREnterExitUIButton {
  43510. /** button element */
  43511. element: HTMLElement;
  43512. /** XR initialization options for the button */
  43513. sessionMode: XRSessionMode;
  43514. /** Reference space type */
  43515. referenceSpaceType: XRReferenceSpaceType;
  43516. /**
  43517. * Creates a WebXREnterExitUIButton
  43518. * @param element button element
  43519. * @param sessionMode XR initialization session mode
  43520. * @param referenceSpaceType the type of reference space to be used
  43521. */
  43522. constructor(
  43523. /** button element */
  43524. element: HTMLElement,
  43525. /** XR initialization options for the button */
  43526. sessionMode: XRSessionMode,
  43527. /** Reference space type */
  43528. referenceSpaceType: XRReferenceSpaceType);
  43529. /**
  43530. * Overwritable function which can be used to update the button's visuals when the state changes
  43531. * @param activeButton the current active button in the UI
  43532. */
  43533. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43534. }
  43535. /**
  43536. * Options to create the webXR UI
  43537. */
  43538. export class WebXREnterExitUIOptions {
  43539. /**
  43540. * Context to enter xr with
  43541. */
  43542. renderTarget?: Nullable<WebXRRenderTarget>;
  43543. /**
  43544. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43545. */
  43546. customButtons?: Array<WebXREnterExitUIButton>;
  43547. }
  43548. /**
  43549. * UI to allow the user to enter/exit XR mode
  43550. */
  43551. export class WebXREnterExitUI implements IDisposable {
  43552. private scene;
  43553. private _overlay;
  43554. private _buttons;
  43555. private _activeButton;
  43556. /**
  43557. * Fired every time the active button is changed.
  43558. *
  43559. * When xr is entered via a button that launches xr that button will be the callback parameter
  43560. *
  43561. * When exiting xr the callback parameter will be null)
  43562. */
  43563. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43564. /**
  43565. * Creates UI to allow the user to enter/exit XR mode
  43566. * @param scene the scene to add the ui to
  43567. * @param helper the xr experience helper to enter/exit xr with
  43568. * @param options options to configure the UI
  43569. * @returns the created ui
  43570. */
  43571. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43572. private constructor();
  43573. private _updateButtons;
  43574. /**
  43575. * Disposes of the object
  43576. */
  43577. dispose(): void;
  43578. }
  43579. }
  43580. declare module "babylonjs/Cameras/XR/webXRController" {
  43581. import { Nullable } from "babylonjs/types";
  43582. import { Observable } from "babylonjs/Misc/observable";
  43583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43584. import { Ray } from "babylonjs/Culling/ray";
  43585. import { Scene } from "babylonjs/scene";
  43586. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43587. /**
  43588. * Represents an XR input
  43589. */
  43590. export class WebXRController {
  43591. private scene;
  43592. /** The underlying input source for the controller */
  43593. inputSource: XRInputSource;
  43594. private parentContainer;
  43595. /**
  43596. * 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
  43597. */
  43598. grip?: AbstractMesh;
  43599. /**
  43600. * Pointer which can be used to select objects or attach a visible laser to
  43601. */
  43602. pointer: AbstractMesh;
  43603. private _gamepadMode;
  43604. /**
  43605. * If available, this is the gamepad object related to this controller.
  43606. * Using this object it is possible to get click events and trackpad changes of the
  43607. * webxr controller that is currently being used.
  43608. */
  43609. gamepadController?: WebVRController;
  43610. /**
  43611. * Event that fires when the controller is removed/disposed
  43612. */
  43613. onDisposeObservable: Observable<{}>;
  43614. private _tmpMatrix;
  43615. private _tmpQuaternion;
  43616. private _tmpVector;
  43617. /**
  43618. * Creates the controller
  43619. * @see https://doc.babylonjs.com/how_to/webxr
  43620. * @param scene the scene which the controller should be associated to
  43621. * @param inputSource the underlying input source for the controller
  43622. * @param parentContainer parent that the controller meshes should be children of
  43623. */
  43624. constructor(scene: Scene,
  43625. /** The underlying input source for the controller */
  43626. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43627. /**
  43628. * Updates the controller pose based on the given XRFrame
  43629. * @param xrFrame xr frame to update the pose with
  43630. * @param referenceSpace reference space to use
  43631. */
  43632. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43633. /**
  43634. * Gets a world space ray coming from the controller
  43635. * @param result the resulting ray
  43636. */
  43637. getWorldPointerRayToRef(result: Ray): void;
  43638. /**
  43639. * Get the scene associated with this controller
  43640. * @returns the scene object
  43641. */
  43642. getScene(): Scene;
  43643. /**
  43644. * Disposes of the object
  43645. */
  43646. dispose(): void;
  43647. }
  43648. }
  43649. declare module "babylonjs/Cameras/XR/webXRInput" {
  43650. import { Observable } from "babylonjs/Misc/observable";
  43651. import { IDisposable } from "babylonjs/scene";
  43652. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43653. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43654. /**
  43655. * XR input used to track XR inputs such as controllers/rays
  43656. */
  43657. export class WebXRInput implements IDisposable {
  43658. /**
  43659. * Base experience the input listens to
  43660. */
  43661. baseExperience: WebXRExperienceHelper;
  43662. /**
  43663. * XR controllers being tracked
  43664. */
  43665. controllers: Array<WebXRController>;
  43666. private _frameObserver;
  43667. private _stateObserver;
  43668. /**
  43669. * Event when a controller has been connected/added
  43670. */
  43671. onControllerAddedObservable: Observable<WebXRController>;
  43672. /**
  43673. * Event when a controller has been removed/disconnected
  43674. */
  43675. onControllerRemovedObservable: Observable<WebXRController>;
  43676. /**
  43677. * Initializes the WebXRInput
  43678. * @param baseExperience experience helper which the input should be created for
  43679. */
  43680. constructor(
  43681. /**
  43682. * Base experience the input listens to
  43683. */
  43684. baseExperience: WebXRExperienceHelper);
  43685. private _onInputSourcesChange;
  43686. private _addAndRemoveControllers;
  43687. /**
  43688. * Disposes of the object
  43689. */
  43690. dispose(): void;
  43691. }
  43692. }
  43693. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43695. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43696. /**
  43697. * Enables teleportation
  43698. */
  43699. export class WebXRControllerTeleportation {
  43700. private _teleportationFillColor;
  43701. private _teleportationBorderColor;
  43702. private _tmpRay;
  43703. private _tmpVector;
  43704. /**
  43705. * Creates a WebXRControllerTeleportation
  43706. * @param input input manager to add teleportation to
  43707. * @param floorMeshes floormeshes which can be teleported to
  43708. */
  43709. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43710. }
  43711. }
  43712. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43713. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43714. /**
  43715. * Handles pointer input automatically for the pointer of XR controllers
  43716. */
  43717. export class WebXRControllerPointerSelection {
  43718. private static _idCounter;
  43719. private _tmpRay;
  43720. /**
  43721. * Creates a WebXRControllerPointerSelection
  43722. * @param input input manager to setup pointer selection
  43723. */
  43724. constructor(input: WebXRInput);
  43725. private _convertNormalToDirectionOfRay;
  43726. private _updatePointerDistance;
  43727. }
  43728. }
  43729. declare module "babylonjs/Loading/sceneLoader" {
  43730. import { Observable } from "babylonjs/Misc/observable";
  43731. import { Nullable } from "babylonjs/types";
  43732. import { Scene } from "babylonjs/scene";
  43733. import { Engine } from "babylonjs/Engines/engine";
  43734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43735. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43736. import { AssetContainer } from "babylonjs/assetContainer";
  43737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43738. import { Skeleton } from "babylonjs/Bones/skeleton";
  43739. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43740. import { WebRequest } from "babylonjs/Misc/webRequest";
  43741. /**
  43742. * Class used to represent data loading progression
  43743. */
  43744. export class SceneLoaderProgressEvent {
  43745. /** defines if data length to load can be evaluated */
  43746. readonly lengthComputable: boolean;
  43747. /** defines the loaded data length */
  43748. readonly loaded: number;
  43749. /** defines the data length to load */
  43750. readonly total: number;
  43751. /**
  43752. * Create a new progress event
  43753. * @param lengthComputable defines if data length to load can be evaluated
  43754. * @param loaded defines the loaded data length
  43755. * @param total defines the data length to load
  43756. */
  43757. constructor(
  43758. /** defines if data length to load can be evaluated */
  43759. lengthComputable: boolean,
  43760. /** defines the loaded data length */
  43761. loaded: number,
  43762. /** defines the data length to load */
  43763. total: number);
  43764. /**
  43765. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43766. * @param event defines the source event
  43767. * @returns a new SceneLoaderProgressEvent
  43768. */
  43769. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43770. }
  43771. /**
  43772. * Interface used by SceneLoader plugins to define supported file extensions
  43773. */
  43774. export interface ISceneLoaderPluginExtensions {
  43775. /**
  43776. * Defines the list of supported extensions
  43777. */
  43778. [extension: string]: {
  43779. isBinary: boolean;
  43780. };
  43781. }
  43782. /**
  43783. * Interface used by SceneLoader plugin factory
  43784. */
  43785. export interface ISceneLoaderPluginFactory {
  43786. /**
  43787. * Defines the name of the factory
  43788. */
  43789. name: string;
  43790. /**
  43791. * Function called to create a new plugin
  43792. * @return the new plugin
  43793. */
  43794. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43795. /**
  43796. * The callback that returns true if the data can be directly loaded.
  43797. * @param data string containing the file data
  43798. * @returns if the data can be loaded directly
  43799. */
  43800. canDirectLoad?(data: string): boolean;
  43801. }
  43802. /**
  43803. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43804. */
  43805. export interface ISceneLoaderPluginBase {
  43806. /**
  43807. * The friendly name of this plugin.
  43808. */
  43809. name: string;
  43810. /**
  43811. * The file extensions supported by this plugin.
  43812. */
  43813. extensions: string | ISceneLoaderPluginExtensions;
  43814. /**
  43815. * The callback called when loading from a url.
  43816. * @param scene scene loading this url
  43817. * @param url url to load
  43818. * @param onSuccess callback called when the file successfully loads
  43819. * @param onProgress callback called while file is loading (if the server supports this mode)
  43820. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43821. * @param onError callback called when the file fails to load
  43822. * @returns a file request object
  43823. */
  43824. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43825. /**
  43826. * The callback called when loading from a file object.
  43827. * @param scene scene loading this file
  43828. * @param file defines the file to load
  43829. * @param onSuccess defines the callback to call when data is loaded
  43830. * @param onProgress defines the callback to call during loading process
  43831. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43832. * @param onError defines the callback to call when an error occurs
  43833. * @returns a file request object
  43834. */
  43835. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43836. /**
  43837. * The callback that returns true if the data can be directly loaded.
  43838. * @param data string containing the file data
  43839. * @returns if the data can be loaded directly
  43840. */
  43841. canDirectLoad?(data: string): boolean;
  43842. /**
  43843. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43844. * @param scene scene loading this data
  43845. * @param data string containing the data
  43846. * @returns data to pass to the plugin
  43847. */
  43848. directLoad?(scene: Scene, data: string): any;
  43849. /**
  43850. * The callback that allows custom handling of the root url based on the response url.
  43851. * @param rootUrl the original root url
  43852. * @param responseURL the response url if available
  43853. * @returns the new root url
  43854. */
  43855. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43856. }
  43857. /**
  43858. * Interface used to define a SceneLoader plugin
  43859. */
  43860. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43861. /**
  43862. * Import meshes into a scene.
  43863. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43864. * @param scene The scene to import into
  43865. * @param data The data to import
  43866. * @param rootUrl The root url for scene and resources
  43867. * @param meshes The meshes array to import into
  43868. * @param particleSystems The particle systems array to import into
  43869. * @param skeletons The skeletons array to import into
  43870. * @param onError The callback when import fails
  43871. * @returns True if successful or false otherwise
  43872. */
  43873. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43874. /**
  43875. * Load into a scene.
  43876. * @param scene The scene to load into
  43877. * @param data The data to import
  43878. * @param rootUrl The root url for scene and resources
  43879. * @param onError The callback when import fails
  43880. * @returns True if successful or false otherwise
  43881. */
  43882. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43883. /**
  43884. * Load into an asset container.
  43885. * @param scene The scene to load into
  43886. * @param data The data to import
  43887. * @param rootUrl The root url for scene and resources
  43888. * @param onError The callback when import fails
  43889. * @returns The loaded asset container
  43890. */
  43891. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43892. }
  43893. /**
  43894. * Interface used to define an async SceneLoader plugin
  43895. */
  43896. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43897. /**
  43898. * Import meshes into a scene.
  43899. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43900. * @param scene The scene to import into
  43901. * @param data The data to import
  43902. * @param rootUrl The root url for scene and resources
  43903. * @param onProgress The callback when the load progresses
  43904. * @param fileName Defines the name of the file to load
  43905. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43906. */
  43907. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43908. meshes: AbstractMesh[];
  43909. particleSystems: IParticleSystem[];
  43910. skeletons: Skeleton[];
  43911. animationGroups: AnimationGroup[];
  43912. }>;
  43913. /**
  43914. * Load into a scene.
  43915. * @param scene The scene to load into
  43916. * @param data The data to import
  43917. * @param rootUrl The root url for scene and resources
  43918. * @param onProgress The callback when the load progresses
  43919. * @param fileName Defines the name of the file to load
  43920. * @returns Nothing
  43921. */
  43922. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43923. /**
  43924. * Load into an asset container.
  43925. * @param scene The scene to load into
  43926. * @param data The data to import
  43927. * @param rootUrl The root url for scene and resources
  43928. * @param onProgress The callback when the load progresses
  43929. * @param fileName Defines the name of the file to load
  43930. * @returns The loaded asset container
  43931. */
  43932. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43933. }
  43934. /**
  43935. * Class used to load scene from various file formats using registered plugins
  43936. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43937. */
  43938. export class SceneLoader {
  43939. /**
  43940. * No logging while loading
  43941. */
  43942. static readonly NO_LOGGING: number;
  43943. /**
  43944. * Minimal logging while loading
  43945. */
  43946. static readonly MINIMAL_LOGGING: number;
  43947. /**
  43948. * Summary logging while loading
  43949. */
  43950. static readonly SUMMARY_LOGGING: number;
  43951. /**
  43952. * Detailled logging while loading
  43953. */
  43954. static readonly DETAILED_LOGGING: number;
  43955. /**
  43956. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43957. */
  43958. static ForceFullSceneLoadingForIncremental: boolean;
  43959. /**
  43960. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43961. */
  43962. static ShowLoadingScreen: boolean;
  43963. /**
  43964. * Defines the current logging level (while loading the scene)
  43965. * @ignorenaming
  43966. */
  43967. static loggingLevel: number;
  43968. /**
  43969. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43970. */
  43971. static CleanBoneMatrixWeights: boolean;
  43972. /**
  43973. * Event raised when a plugin is used to load a scene
  43974. */
  43975. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43976. private static _registeredPlugins;
  43977. private static _getDefaultPlugin;
  43978. private static _getPluginForExtension;
  43979. private static _getPluginForDirectLoad;
  43980. private static _getPluginForFilename;
  43981. private static _getDirectLoad;
  43982. private static _loadData;
  43983. private static _getFileInfo;
  43984. /**
  43985. * Gets a plugin that can load the given extension
  43986. * @param extension defines the extension to load
  43987. * @returns a plugin or null if none works
  43988. */
  43989. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43990. /**
  43991. * Gets a boolean indicating that the given extension can be loaded
  43992. * @param extension defines the extension to load
  43993. * @returns true if the extension is supported
  43994. */
  43995. static IsPluginForExtensionAvailable(extension: string): boolean;
  43996. /**
  43997. * Adds a new plugin to the list of registered plugins
  43998. * @param plugin defines the plugin to add
  43999. */
  44000. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44001. /**
  44002. * Import meshes into a scene
  44003. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44004. * @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)
  44005. * @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)
  44006. * @param scene the instance of BABYLON.Scene to append to
  44007. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44008. * @param onProgress a callback with a progress event for each file being loaded
  44009. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44010. * @param pluginExtension the extension used to determine the plugin
  44011. * @returns The loaded plugin
  44012. */
  44013. 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>;
  44014. /**
  44015. * Import meshes into a scene
  44016. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44017. * @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)
  44018. * @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)
  44019. * @param scene the instance of BABYLON.Scene to append to
  44020. * @param onProgress a callback with a progress event for each file being loaded
  44021. * @param pluginExtension the extension used to determine the plugin
  44022. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44023. */
  44024. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44025. meshes: AbstractMesh[];
  44026. particleSystems: IParticleSystem[];
  44027. skeletons: Skeleton[];
  44028. animationGroups: AnimationGroup[];
  44029. }>;
  44030. /**
  44031. * Load a scene
  44032. * @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)
  44033. * @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)
  44034. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44035. * @param onSuccess a callback with the scene when import succeeds
  44036. * @param onProgress a callback with a progress event for each file being loaded
  44037. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44038. * @param pluginExtension the extension used to determine the plugin
  44039. * @returns The loaded plugin
  44040. */
  44041. 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>;
  44042. /**
  44043. * Load a scene
  44044. * @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)
  44045. * @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)
  44046. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44047. * @param onProgress a callback with a progress event for each file being loaded
  44048. * @param pluginExtension the extension used to determine the plugin
  44049. * @returns The loaded scene
  44050. */
  44051. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44052. /**
  44053. * Append a scene
  44054. * @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)
  44055. * @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)
  44056. * @param scene is the instance of BABYLON.Scene to append to
  44057. * @param onSuccess a callback with the scene when import succeeds
  44058. * @param onProgress a callback with a progress event for each file being loaded
  44059. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44060. * @param pluginExtension the extension used to determine the plugin
  44061. * @returns The loaded plugin
  44062. */
  44063. 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>;
  44064. /**
  44065. * Append a scene
  44066. * @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)
  44067. * @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)
  44068. * @param scene is the instance of BABYLON.Scene to append to
  44069. * @param onProgress a callback with a progress event for each file being loaded
  44070. * @param pluginExtension the extension used to determine the plugin
  44071. * @returns The given scene
  44072. */
  44073. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44074. /**
  44075. * Load a scene into an asset container
  44076. * @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)
  44077. * @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)
  44078. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44079. * @param onSuccess a callback with the scene when import succeeds
  44080. * @param onProgress a callback with a progress event for each file being loaded
  44081. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44082. * @param pluginExtension the extension used to determine the plugin
  44083. * @returns The loaded plugin
  44084. */
  44085. 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>;
  44086. /**
  44087. * Load a scene into an asset container
  44088. * @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)
  44089. * @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)
  44090. * @param scene is the instance of Scene to append to
  44091. * @param onProgress a callback with a progress event for each file being loaded
  44092. * @param pluginExtension the extension used to determine the plugin
  44093. * @returns The loaded asset container
  44094. */
  44095. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44096. }
  44097. }
  44098. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44099. import { Scene } from "babylonjs/scene";
  44100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44101. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44102. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44103. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44104. /**
  44105. * Generic Controller
  44106. */
  44107. export class GenericController extends WebVRController {
  44108. /**
  44109. * Base Url for the controller model.
  44110. */
  44111. static readonly MODEL_BASE_URL: string;
  44112. /**
  44113. * File name for the controller model.
  44114. */
  44115. static readonly MODEL_FILENAME: string;
  44116. /**
  44117. * Creates a new GenericController from a gamepad
  44118. * @param vrGamepad the gamepad that the controller should be created from
  44119. */
  44120. constructor(vrGamepad: any);
  44121. /**
  44122. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44123. * @param scene scene in which to add meshes
  44124. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44125. */
  44126. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44127. /**
  44128. * Called once for each button that changed state since the last frame
  44129. * @param buttonIdx Which button index changed
  44130. * @param state New state of the button
  44131. * @param changes Which properties on the state changed since last frame
  44132. */
  44133. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44134. }
  44135. }
  44136. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44137. import { Observable } from "babylonjs/Misc/observable";
  44138. import { Scene } from "babylonjs/scene";
  44139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44140. import { Ray } from "babylonjs/Culling/ray";
  44141. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44142. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44143. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44144. /**
  44145. * Defines the WindowsMotionController object that the state of the windows motion controller
  44146. */
  44147. export class WindowsMotionController extends WebVRController {
  44148. /**
  44149. * The base url used to load the left and right controller models
  44150. */
  44151. static MODEL_BASE_URL: string;
  44152. /**
  44153. * The name of the left controller model file
  44154. */
  44155. static MODEL_LEFT_FILENAME: string;
  44156. /**
  44157. * The name of the right controller model file
  44158. */
  44159. static MODEL_RIGHT_FILENAME: string;
  44160. /**
  44161. * The controller name prefix for this controller type
  44162. */
  44163. static readonly GAMEPAD_ID_PREFIX: string;
  44164. /**
  44165. * The controller id pattern for this controller type
  44166. */
  44167. private static readonly GAMEPAD_ID_PATTERN;
  44168. private _loadedMeshInfo;
  44169. private readonly _mapping;
  44170. /**
  44171. * Fired when the trackpad on this controller is clicked
  44172. */
  44173. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44174. /**
  44175. * Fired when the trackpad on this controller is modified
  44176. */
  44177. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44178. /**
  44179. * The current x and y values of this controller's trackpad
  44180. */
  44181. trackpad: StickValues;
  44182. /**
  44183. * Creates a new WindowsMotionController from a gamepad
  44184. * @param vrGamepad the gamepad that the controller should be created from
  44185. */
  44186. constructor(vrGamepad: any);
  44187. /**
  44188. * Fired when the trigger on this controller is modified
  44189. */
  44190. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44191. /**
  44192. * Fired when the menu button on this controller is modified
  44193. */
  44194. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44195. /**
  44196. * Fired when the grip button on this controller is modified
  44197. */
  44198. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44199. /**
  44200. * Fired when the thumbstick button on this controller is modified
  44201. */
  44202. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44203. /**
  44204. * Fired when the touchpad button on this controller is modified
  44205. */
  44206. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44207. /**
  44208. * Fired when the touchpad values on this controller are modified
  44209. */
  44210. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44211. private _updateTrackpad;
  44212. /**
  44213. * Called once per frame by the engine.
  44214. */
  44215. update(): void;
  44216. /**
  44217. * Called once for each button that changed state since the last frame
  44218. * @param buttonIdx Which button index changed
  44219. * @param state New state of the button
  44220. * @param changes Which properties on the state changed since last frame
  44221. */
  44222. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44223. /**
  44224. * Moves the buttons on the controller mesh based on their current state
  44225. * @param buttonName the name of the button to move
  44226. * @param buttonValue the value of the button which determines the buttons new position
  44227. */
  44228. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44229. /**
  44230. * Moves the axis on the controller mesh based on its current state
  44231. * @param axis the index of the axis
  44232. * @param axisValue the value of the axis which determines the meshes new position
  44233. * @hidden
  44234. */
  44235. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44236. /**
  44237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44238. * @param scene scene in which to add meshes
  44239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44240. */
  44241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44242. /**
  44243. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44244. * can be transformed by button presses and axes values, based on this._mapping.
  44245. *
  44246. * @param scene scene in which the meshes exist
  44247. * @param meshes list of meshes that make up the controller model to process
  44248. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44249. */
  44250. private processModel;
  44251. private createMeshInfo;
  44252. /**
  44253. * Gets the ray of the controller in the direction the controller is pointing
  44254. * @param length the length the resulting ray should be
  44255. * @returns a ray in the direction the controller is pointing
  44256. */
  44257. getForwardRay(length?: number): Ray;
  44258. /**
  44259. * Disposes of the controller
  44260. */
  44261. dispose(): void;
  44262. }
  44263. }
  44264. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44265. import { Observable } from "babylonjs/Misc/observable";
  44266. import { Scene } from "babylonjs/scene";
  44267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44268. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44269. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44270. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44271. /**
  44272. * Oculus Touch Controller
  44273. */
  44274. export class OculusTouchController extends WebVRController {
  44275. /**
  44276. * Base Url for the controller model.
  44277. */
  44278. static MODEL_BASE_URL: string;
  44279. /**
  44280. * File name for the left controller model.
  44281. */
  44282. static MODEL_LEFT_FILENAME: string;
  44283. /**
  44284. * File name for the right controller model.
  44285. */
  44286. static MODEL_RIGHT_FILENAME: string;
  44287. /**
  44288. * Base Url for the Quest controller model.
  44289. */
  44290. static QUEST_MODEL_BASE_URL: string;
  44291. /**
  44292. * @hidden
  44293. * If the controllers are running on a device that needs the updated Quest controller models
  44294. */
  44295. static _IsQuest: boolean;
  44296. /**
  44297. * Fired when the secondary trigger on this controller is modified
  44298. */
  44299. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44300. /**
  44301. * Fired when the thumb rest on this controller is modified
  44302. */
  44303. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44304. /**
  44305. * Creates a new OculusTouchController from a gamepad
  44306. * @param vrGamepad the gamepad that the controller should be created from
  44307. */
  44308. constructor(vrGamepad: any);
  44309. /**
  44310. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44311. * @param scene scene in which to add meshes
  44312. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44313. */
  44314. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44315. /**
  44316. * Fired when the A button on this controller is modified
  44317. */
  44318. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44319. /**
  44320. * Fired when the B button on this controller is modified
  44321. */
  44322. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44323. /**
  44324. * Fired when the X button on this controller is modified
  44325. */
  44326. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44327. /**
  44328. * Fired when the Y button on this controller is modified
  44329. */
  44330. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44331. /**
  44332. * Called once for each button that changed state since the last frame
  44333. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44334. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44335. * 2) secondary trigger (same)
  44336. * 3) A (right) X (left), touch, pressed = value
  44337. * 4) B / Y
  44338. * 5) thumb rest
  44339. * @param buttonIdx Which button index changed
  44340. * @param state New state of the button
  44341. * @param changes Which properties on the state changed since last frame
  44342. */
  44343. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44344. }
  44345. }
  44346. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44347. import { Scene } from "babylonjs/scene";
  44348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44349. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44350. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44351. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44352. import { Observable } from "babylonjs/Misc/observable";
  44353. /**
  44354. * Vive Controller
  44355. */
  44356. export class ViveController extends WebVRController {
  44357. /**
  44358. * Base Url for the controller model.
  44359. */
  44360. static MODEL_BASE_URL: string;
  44361. /**
  44362. * File name for the controller model.
  44363. */
  44364. static MODEL_FILENAME: string;
  44365. /**
  44366. * Creates a new ViveController from a gamepad
  44367. * @param vrGamepad the gamepad that the controller should be created from
  44368. */
  44369. constructor(vrGamepad: any);
  44370. /**
  44371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44372. * @param scene scene in which to add meshes
  44373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44374. */
  44375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44376. /**
  44377. * Fired when the left button on this controller is modified
  44378. */
  44379. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44380. /**
  44381. * Fired when the right button on this controller is modified
  44382. */
  44383. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44384. /**
  44385. * Fired when the menu button on this controller is modified
  44386. */
  44387. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44388. /**
  44389. * Called once for each button that changed state since the last frame
  44390. * Vive mapping:
  44391. * 0: touchpad
  44392. * 1: trigger
  44393. * 2: left AND right buttons
  44394. * 3: menu button
  44395. * @param buttonIdx Which button index changed
  44396. * @param state New state of the button
  44397. * @param changes Which properties on the state changed since last frame
  44398. */
  44399. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44400. }
  44401. }
  44402. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44403. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44404. /**
  44405. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44406. */
  44407. export class WebXRControllerModelLoader {
  44408. /**
  44409. * Creates the WebXRControllerModelLoader
  44410. * @param input xr input that creates the controllers
  44411. */
  44412. constructor(input: WebXRInput);
  44413. }
  44414. }
  44415. declare module "babylonjs/Cameras/XR/index" {
  44416. export * from "babylonjs/Cameras/XR/webXRCamera";
  44417. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44418. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44419. export * from "babylonjs/Cameras/XR/webXRInput";
  44420. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44421. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44422. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44423. export * from "babylonjs/Cameras/XR/webXRController";
  44424. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44425. export * from "babylonjs/Cameras/XR/webXRTypes";
  44426. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44427. }
  44428. declare module "babylonjs/Cameras/RigModes/index" {
  44429. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44430. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44431. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44432. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44433. }
  44434. declare module "babylonjs/Cameras/index" {
  44435. export * from "babylonjs/Cameras/Inputs/index";
  44436. export * from "babylonjs/Cameras/cameraInputsManager";
  44437. export * from "babylonjs/Cameras/camera";
  44438. export * from "babylonjs/Cameras/targetCamera";
  44439. export * from "babylonjs/Cameras/freeCamera";
  44440. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44441. export * from "babylonjs/Cameras/touchCamera";
  44442. export * from "babylonjs/Cameras/arcRotateCamera";
  44443. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44444. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44445. export * from "babylonjs/Cameras/flyCamera";
  44446. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44447. export * from "babylonjs/Cameras/followCamera";
  44448. export * from "babylonjs/Cameras/followCameraInputsManager";
  44449. export * from "babylonjs/Cameras/gamepadCamera";
  44450. export * from "babylonjs/Cameras/Stereoscopic/index";
  44451. export * from "babylonjs/Cameras/universalCamera";
  44452. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44453. export * from "babylonjs/Cameras/VR/index";
  44454. export * from "babylonjs/Cameras/XR/index";
  44455. export * from "babylonjs/Cameras/RigModes/index";
  44456. }
  44457. declare module "babylonjs/Collisions/index" {
  44458. export * from "babylonjs/Collisions/collider";
  44459. export * from "babylonjs/Collisions/collisionCoordinator";
  44460. export * from "babylonjs/Collisions/pickingInfo";
  44461. export * from "babylonjs/Collisions/intersectionInfo";
  44462. export * from "babylonjs/Collisions/meshCollisionData";
  44463. }
  44464. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44465. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44466. import { Vector3 } from "babylonjs/Maths/math.vector";
  44467. import { Ray } from "babylonjs/Culling/ray";
  44468. import { Plane } from "babylonjs/Maths/math.plane";
  44469. /**
  44470. * Contains an array of blocks representing the octree
  44471. */
  44472. export interface IOctreeContainer<T> {
  44473. /**
  44474. * Blocks within the octree
  44475. */
  44476. blocks: Array<OctreeBlock<T>>;
  44477. }
  44478. /**
  44479. * Class used to store a cell in an octree
  44480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44481. */
  44482. export class OctreeBlock<T> {
  44483. /**
  44484. * Gets the content of the current block
  44485. */
  44486. entries: T[];
  44487. /**
  44488. * Gets the list of block children
  44489. */
  44490. blocks: Array<OctreeBlock<T>>;
  44491. private _depth;
  44492. private _maxDepth;
  44493. private _capacity;
  44494. private _minPoint;
  44495. private _maxPoint;
  44496. private _boundingVectors;
  44497. private _creationFunc;
  44498. /**
  44499. * Creates a new block
  44500. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44501. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44502. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44503. * @param depth defines the current depth of this block in the octree
  44504. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44505. * @param creationFunc defines a callback to call when an element is added to the block
  44506. */
  44507. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44508. /**
  44509. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44510. */
  44511. readonly capacity: number;
  44512. /**
  44513. * Gets the minimum vector (in world space) of the block's bounding box
  44514. */
  44515. readonly minPoint: Vector3;
  44516. /**
  44517. * Gets the maximum vector (in world space) of the block's bounding box
  44518. */
  44519. readonly maxPoint: Vector3;
  44520. /**
  44521. * Add a new element to this block
  44522. * @param entry defines the element to add
  44523. */
  44524. addEntry(entry: T): void;
  44525. /**
  44526. * Remove an element from this block
  44527. * @param entry defines the element to remove
  44528. */
  44529. removeEntry(entry: T): void;
  44530. /**
  44531. * Add an array of elements to this block
  44532. * @param entries defines the array of elements to add
  44533. */
  44534. addEntries(entries: T[]): void;
  44535. /**
  44536. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44537. * @param frustumPlanes defines the frustum planes to test
  44538. * @param selection defines the array to store current content if selection is positive
  44539. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44540. */
  44541. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44542. /**
  44543. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44544. * @param sphereCenter defines the bounding sphere center
  44545. * @param sphereRadius defines the bounding sphere radius
  44546. * @param selection defines the array to store current content if selection is positive
  44547. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44548. */
  44549. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44550. /**
  44551. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44552. * @param ray defines the ray to test with
  44553. * @param selection defines the array to store current content if selection is positive
  44554. */
  44555. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44556. /**
  44557. * Subdivide the content into child blocks (this block will then be empty)
  44558. */
  44559. createInnerBlocks(): void;
  44560. /**
  44561. * @hidden
  44562. */
  44563. 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;
  44564. }
  44565. }
  44566. declare module "babylonjs/Culling/Octrees/octree" {
  44567. import { SmartArray } from "babylonjs/Misc/smartArray";
  44568. import { Vector3 } from "babylonjs/Maths/math.vector";
  44569. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44571. import { Ray } from "babylonjs/Culling/ray";
  44572. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44573. import { Plane } from "babylonjs/Maths/math.plane";
  44574. /**
  44575. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44576. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44577. */
  44578. export class Octree<T> {
  44579. /** 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.) */
  44580. maxDepth: number;
  44581. /**
  44582. * Blocks within the octree containing objects
  44583. */
  44584. blocks: Array<OctreeBlock<T>>;
  44585. /**
  44586. * Content stored in the octree
  44587. */
  44588. dynamicContent: T[];
  44589. private _maxBlockCapacity;
  44590. private _selectionContent;
  44591. private _creationFunc;
  44592. /**
  44593. * Creates a octree
  44594. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44595. * @param creationFunc function to be used to instatiate the octree
  44596. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44597. * @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.)
  44598. */
  44599. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44600. /** 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.) */
  44601. maxDepth?: number);
  44602. /**
  44603. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44604. * @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);
  44605. * @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);
  44606. * @param entries meshes to be added to the octree blocks
  44607. */
  44608. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44609. /**
  44610. * Adds a mesh to the octree
  44611. * @param entry Mesh to add to the octree
  44612. */
  44613. addMesh(entry: T): void;
  44614. /**
  44615. * Remove an element from the octree
  44616. * @param entry defines the element to remove
  44617. */
  44618. removeMesh(entry: T): void;
  44619. /**
  44620. * Selects an array of meshes within the frustum
  44621. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44622. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44623. * @returns array of meshes within the frustum
  44624. */
  44625. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44626. /**
  44627. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44628. * @param sphereCenter defines the bounding sphere center
  44629. * @param sphereRadius defines the bounding sphere radius
  44630. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44631. * @returns an array of objects that intersect the sphere
  44632. */
  44633. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44634. /**
  44635. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44636. * @param ray defines the ray to test with
  44637. * @returns array of intersected objects
  44638. */
  44639. intersectsRay(ray: Ray): SmartArray<T>;
  44640. /**
  44641. * Adds a mesh into the octree block if it intersects the block
  44642. */
  44643. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44644. /**
  44645. * Adds a submesh into the octree block if it intersects the block
  44646. */
  44647. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44648. }
  44649. }
  44650. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44651. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44652. import { Scene } from "babylonjs/scene";
  44653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44655. import { Ray } from "babylonjs/Culling/ray";
  44656. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44657. import { Collider } from "babylonjs/Collisions/collider";
  44658. module "babylonjs/scene" {
  44659. interface Scene {
  44660. /**
  44661. * @hidden
  44662. * Backing Filed
  44663. */
  44664. _selectionOctree: Octree<AbstractMesh>;
  44665. /**
  44666. * Gets the octree used to boost mesh selection (picking)
  44667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44668. */
  44669. selectionOctree: Octree<AbstractMesh>;
  44670. /**
  44671. * Creates or updates the octree used to boost selection (picking)
  44672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44673. * @param maxCapacity defines the maximum capacity per leaf
  44674. * @param maxDepth defines the maximum depth of the octree
  44675. * @returns an octree of AbstractMesh
  44676. */
  44677. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44678. }
  44679. }
  44680. module "babylonjs/Meshes/abstractMesh" {
  44681. interface AbstractMesh {
  44682. /**
  44683. * @hidden
  44684. * Backing Field
  44685. */
  44686. _submeshesOctree: Octree<SubMesh>;
  44687. /**
  44688. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44689. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44690. * @param maxCapacity defines the maximum size of each block (64 by default)
  44691. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44692. * @returns the new octree
  44693. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44695. */
  44696. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44697. }
  44698. }
  44699. /**
  44700. * Defines the octree scene component responsible to manage any octrees
  44701. * in a given scene.
  44702. */
  44703. export class OctreeSceneComponent {
  44704. /**
  44705. * The component name help to identify the component in the list of scene components.
  44706. */
  44707. readonly name: string;
  44708. /**
  44709. * The scene the component belongs to.
  44710. */
  44711. scene: Scene;
  44712. /**
  44713. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44714. */
  44715. readonly checksIsEnabled: boolean;
  44716. /**
  44717. * Creates a new instance of the component for the given scene
  44718. * @param scene Defines the scene to register the component in
  44719. */
  44720. constructor(scene: Scene);
  44721. /**
  44722. * Registers the component in a given scene
  44723. */
  44724. register(): void;
  44725. /**
  44726. * Return the list of active meshes
  44727. * @returns the list of active meshes
  44728. */
  44729. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44730. /**
  44731. * Return the list of active sub meshes
  44732. * @param mesh The mesh to get the candidates sub meshes from
  44733. * @returns the list of active sub meshes
  44734. */
  44735. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44736. private _tempRay;
  44737. /**
  44738. * Return the list of sub meshes intersecting with a given local ray
  44739. * @param mesh defines the mesh to find the submesh for
  44740. * @param localRay defines the ray in local space
  44741. * @returns the list of intersecting sub meshes
  44742. */
  44743. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44744. /**
  44745. * Return the list of sub meshes colliding with a collider
  44746. * @param mesh defines the mesh to find the submesh for
  44747. * @param collider defines the collider to evaluate the collision against
  44748. * @returns the list of colliding sub meshes
  44749. */
  44750. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44751. /**
  44752. * Rebuilds the elements related to this component in case of
  44753. * context lost for instance.
  44754. */
  44755. rebuild(): void;
  44756. /**
  44757. * Disposes the component and the associated ressources.
  44758. */
  44759. dispose(): void;
  44760. }
  44761. }
  44762. declare module "babylonjs/Culling/Octrees/index" {
  44763. export * from "babylonjs/Culling/Octrees/octree";
  44764. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44765. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44766. }
  44767. declare module "babylonjs/Culling/index" {
  44768. export * from "babylonjs/Culling/boundingBox";
  44769. export * from "babylonjs/Culling/boundingInfo";
  44770. export * from "babylonjs/Culling/boundingSphere";
  44771. export * from "babylonjs/Culling/Octrees/index";
  44772. export * from "babylonjs/Culling/ray";
  44773. }
  44774. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44775. import { IDisposable, Scene } from "babylonjs/scene";
  44776. import { Nullable } from "babylonjs/types";
  44777. import { Observable } from "babylonjs/Misc/observable";
  44778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44779. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44780. import { Camera } from "babylonjs/Cameras/camera";
  44781. /**
  44782. * Renders a layer on top of an existing scene
  44783. */
  44784. export class UtilityLayerRenderer implements IDisposable {
  44785. /** the original scene that will be rendered on top of */
  44786. originalScene: Scene;
  44787. private _pointerCaptures;
  44788. private _lastPointerEvents;
  44789. private static _DefaultUtilityLayer;
  44790. private static _DefaultKeepDepthUtilityLayer;
  44791. private _sharedGizmoLight;
  44792. private _renderCamera;
  44793. /**
  44794. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44795. * @returns the camera that is used when rendering the utility layer
  44796. */
  44797. getRenderCamera(): Nullable<Camera>;
  44798. /**
  44799. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44800. * @param cam the camera that should be used when rendering the utility layer
  44801. */
  44802. setRenderCamera(cam: Nullable<Camera>): void;
  44803. /**
  44804. * @hidden
  44805. * Light which used by gizmos to get light shading
  44806. */
  44807. _getSharedGizmoLight(): HemisphericLight;
  44808. /**
  44809. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44810. */
  44811. pickUtilitySceneFirst: boolean;
  44812. /**
  44813. * 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)
  44814. */
  44815. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44816. /**
  44817. * 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)
  44818. */
  44819. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44820. /**
  44821. * The scene that is rendered on top of the original scene
  44822. */
  44823. utilityLayerScene: Scene;
  44824. /**
  44825. * If the utility layer should automatically be rendered on top of existing scene
  44826. */
  44827. shouldRender: boolean;
  44828. /**
  44829. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44830. */
  44831. onlyCheckPointerDownEvents: boolean;
  44832. /**
  44833. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44834. */
  44835. processAllEvents: boolean;
  44836. /**
  44837. * Observable raised when the pointer move from the utility layer scene to the main scene
  44838. */
  44839. onPointerOutObservable: Observable<number>;
  44840. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44841. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44842. private _afterRenderObserver;
  44843. private _sceneDisposeObserver;
  44844. private _originalPointerObserver;
  44845. /**
  44846. * Instantiates a UtilityLayerRenderer
  44847. * @param originalScene the original scene that will be rendered on top of
  44848. * @param handleEvents boolean indicating if the utility layer should handle events
  44849. */
  44850. constructor(
  44851. /** the original scene that will be rendered on top of */
  44852. originalScene: Scene, handleEvents?: boolean);
  44853. private _notifyObservers;
  44854. /**
  44855. * Renders the utility layers scene on top of the original scene
  44856. */
  44857. render(): void;
  44858. /**
  44859. * Disposes of the renderer
  44860. */
  44861. dispose(): void;
  44862. private _updateCamera;
  44863. }
  44864. }
  44865. declare module "babylonjs/Gizmos/gizmo" {
  44866. import { Nullable } from "babylonjs/types";
  44867. import { IDisposable } from "babylonjs/scene";
  44868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44869. import { Mesh } from "babylonjs/Meshes/mesh";
  44870. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44871. /**
  44872. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44873. */
  44874. export class Gizmo implements IDisposable {
  44875. /** The utility layer the gizmo will be added to */
  44876. gizmoLayer: UtilityLayerRenderer;
  44877. /**
  44878. * The root mesh of the gizmo
  44879. */
  44880. _rootMesh: Mesh;
  44881. private _attachedMesh;
  44882. /**
  44883. * Ratio for the scale of the gizmo (Default: 1)
  44884. */
  44885. scaleRatio: number;
  44886. /**
  44887. * If a custom mesh has been set (Default: false)
  44888. */
  44889. protected _customMeshSet: boolean;
  44890. /**
  44891. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44892. * * When set, interactions will be enabled
  44893. */
  44894. attachedMesh: Nullable<AbstractMesh>;
  44895. /**
  44896. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44897. * @param mesh The mesh to replace the default mesh of the gizmo
  44898. */
  44899. setCustomMesh(mesh: Mesh): void;
  44900. /**
  44901. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44902. */
  44903. updateGizmoRotationToMatchAttachedMesh: boolean;
  44904. /**
  44905. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44906. */
  44907. updateGizmoPositionToMatchAttachedMesh: boolean;
  44908. /**
  44909. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44910. */
  44911. updateScale: boolean;
  44912. protected _interactionsEnabled: boolean;
  44913. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44914. private _beforeRenderObserver;
  44915. private _tempVector;
  44916. /**
  44917. * Creates a gizmo
  44918. * @param gizmoLayer The utility layer the gizmo will be added to
  44919. */
  44920. constructor(
  44921. /** The utility layer the gizmo will be added to */
  44922. gizmoLayer?: UtilityLayerRenderer);
  44923. /**
  44924. * Updates the gizmo to match the attached mesh's position/rotation
  44925. */
  44926. protected _update(): void;
  44927. /**
  44928. * Disposes of the gizmo
  44929. */
  44930. dispose(): void;
  44931. }
  44932. }
  44933. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44934. import { Observable } from "babylonjs/Misc/observable";
  44935. import { Nullable } from "babylonjs/types";
  44936. import { Vector3 } from "babylonjs/Maths/math.vector";
  44937. import { Color3 } from "babylonjs/Maths/math.color";
  44938. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44940. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44941. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44942. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44943. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44944. import { Scene } from "babylonjs/scene";
  44945. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44946. /**
  44947. * Single plane drag gizmo
  44948. */
  44949. export class PlaneDragGizmo extends Gizmo {
  44950. /**
  44951. * Drag behavior responsible for the gizmos dragging interactions
  44952. */
  44953. dragBehavior: PointerDragBehavior;
  44954. private _pointerObserver;
  44955. /**
  44956. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44957. */
  44958. snapDistance: number;
  44959. /**
  44960. * Event that fires each time the gizmo snaps to a new location.
  44961. * * snapDistance is the the change in distance
  44962. */
  44963. onSnapObservable: Observable<{
  44964. snapDistance: number;
  44965. }>;
  44966. private _plane;
  44967. private _coloredMaterial;
  44968. private _hoverMaterial;
  44969. private _isEnabled;
  44970. private _parent;
  44971. /** @hidden */
  44972. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44973. /** @hidden */
  44974. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44975. /**
  44976. * Creates a PlaneDragGizmo
  44977. * @param gizmoLayer The utility layer the gizmo will be added to
  44978. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44979. * @param color The color of the gizmo
  44980. */
  44981. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44982. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44983. /**
  44984. * If the gizmo is enabled
  44985. */
  44986. isEnabled: boolean;
  44987. /**
  44988. * Disposes of the gizmo
  44989. */
  44990. dispose(): void;
  44991. }
  44992. }
  44993. declare module "babylonjs/Gizmos/positionGizmo" {
  44994. import { Observable } from "babylonjs/Misc/observable";
  44995. import { Nullable } from "babylonjs/types";
  44996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44997. import { Mesh } from "babylonjs/Meshes/mesh";
  44998. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44999. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45000. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45001. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45002. /**
  45003. * Gizmo that enables dragging a mesh along 3 axis
  45004. */
  45005. export class PositionGizmo extends Gizmo {
  45006. /**
  45007. * Internal gizmo used for interactions on the x axis
  45008. */
  45009. xGizmo: AxisDragGizmo;
  45010. /**
  45011. * Internal gizmo used for interactions on the y axis
  45012. */
  45013. yGizmo: AxisDragGizmo;
  45014. /**
  45015. * Internal gizmo used for interactions on the z axis
  45016. */
  45017. zGizmo: AxisDragGizmo;
  45018. /**
  45019. * Internal gizmo used for interactions on the yz plane
  45020. */
  45021. xPlaneGizmo: PlaneDragGizmo;
  45022. /**
  45023. * Internal gizmo used for interactions on the xz plane
  45024. */
  45025. yPlaneGizmo: PlaneDragGizmo;
  45026. /**
  45027. * Internal gizmo used for interactions on the xy plane
  45028. */
  45029. zPlaneGizmo: PlaneDragGizmo;
  45030. /**
  45031. * private variables
  45032. */
  45033. private _meshAttached;
  45034. private _updateGizmoRotationToMatchAttachedMesh;
  45035. private _snapDistance;
  45036. private _scaleRatio;
  45037. /** Fires an event when any of it's sub gizmos are dragged */
  45038. onDragStartObservable: Observable<unknown>;
  45039. /** Fires an event when any of it's sub gizmos are released from dragging */
  45040. onDragEndObservable: Observable<unknown>;
  45041. /**
  45042. * If set to true, planar drag is enabled
  45043. */
  45044. private _planarGizmoEnabled;
  45045. attachedMesh: Nullable<AbstractMesh>;
  45046. /**
  45047. * Creates a PositionGizmo
  45048. * @param gizmoLayer The utility layer the gizmo will be added to
  45049. */
  45050. constructor(gizmoLayer?: UtilityLayerRenderer);
  45051. /**
  45052. * If the planar drag gizmo is enabled
  45053. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45054. */
  45055. planarGizmoEnabled: boolean;
  45056. updateGizmoRotationToMatchAttachedMesh: boolean;
  45057. /**
  45058. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45059. */
  45060. snapDistance: number;
  45061. /**
  45062. * Ratio for the scale of the gizmo (Default: 1)
  45063. */
  45064. scaleRatio: number;
  45065. /**
  45066. * Disposes of the gizmo
  45067. */
  45068. dispose(): void;
  45069. /**
  45070. * CustomMeshes are not supported by this gizmo
  45071. * @param mesh The mesh to replace the default mesh of the gizmo
  45072. */
  45073. setCustomMesh(mesh: Mesh): void;
  45074. }
  45075. }
  45076. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45077. import { Observable } from "babylonjs/Misc/observable";
  45078. import { Nullable } from "babylonjs/types";
  45079. import { Vector3 } from "babylonjs/Maths/math.vector";
  45080. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45082. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45083. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45084. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45085. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45086. import { Scene } from "babylonjs/scene";
  45087. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45088. import { Color3 } from "babylonjs/Maths/math.color";
  45089. /**
  45090. * Single axis drag gizmo
  45091. */
  45092. export class AxisDragGizmo extends Gizmo {
  45093. /**
  45094. * Drag behavior responsible for the gizmos dragging interactions
  45095. */
  45096. dragBehavior: PointerDragBehavior;
  45097. private _pointerObserver;
  45098. /**
  45099. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45100. */
  45101. snapDistance: number;
  45102. /**
  45103. * Event that fires each time the gizmo snaps to a new location.
  45104. * * snapDistance is the the change in distance
  45105. */
  45106. onSnapObservable: Observable<{
  45107. snapDistance: number;
  45108. }>;
  45109. private _isEnabled;
  45110. private _parent;
  45111. private _arrow;
  45112. private _coloredMaterial;
  45113. private _hoverMaterial;
  45114. /** @hidden */
  45115. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45116. /** @hidden */
  45117. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45118. /**
  45119. * Creates an AxisDragGizmo
  45120. * @param gizmoLayer The utility layer the gizmo will be added to
  45121. * @param dragAxis The axis which the gizmo will be able to drag on
  45122. * @param color The color of the gizmo
  45123. */
  45124. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45125. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45126. /**
  45127. * If the gizmo is enabled
  45128. */
  45129. isEnabled: boolean;
  45130. /**
  45131. * Disposes of the gizmo
  45132. */
  45133. dispose(): void;
  45134. }
  45135. }
  45136. declare module "babylonjs/Debug/axesViewer" {
  45137. import { Vector3 } from "babylonjs/Maths/math.vector";
  45138. import { Nullable } from "babylonjs/types";
  45139. import { Scene } from "babylonjs/scene";
  45140. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45141. /**
  45142. * The Axes viewer will show 3 axes in a specific point in space
  45143. */
  45144. export class AxesViewer {
  45145. private _xAxis;
  45146. private _yAxis;
  45147. private _zAxis;
  45148. private _scaleLinesFactor;
  45149. private _instanced;
  45150. /**
  45151. * Gets the hosting scene
  45152. */
  45153. scene: Scene;
  45154. /**
  45155. * Gets or sets a number used to scale line length
  45156. */
  45157. scaleLines: number;
  45158. /** Gets the node hierarchy used to render x-axis */
  45159. readonly xAxis: TransformNode;
  45160. /** Gets the node hierarchy used to render y-axis */
  45161. readonly yAxis: TransformNode;
  45162. /** Gets the node hierarchy used to render z-axis */
  45163. readonly zAxis: TransformNode;
  45164. /**
  45165. * Creates a new AxesViewer
  45166. * @param scene defines the hosting scene
  45167. * @param scaleLines defines a number used to scale line length (1 by default)
  45168. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45169. * @param xAxis defines the node hierarchy used to render the x-axis
  45170. * @param yAxis defines the node hierarchy used to render the y-axis
  45171. * @param zAxis defines the node hierarchy used to render the z-axis
  45172. */
  45173. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45174. /**
  45175. * Force the viewer to update
  45176. * @param position defines the position of the viewer
  45177. * @param xaxis defines the x axis of the viewer
  45178. * @param yaxis defines the y axis of the viewer
  45179. * @param zaxis defines the z axis of the viewer
  45180. */
  45181. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45182. /**
  45183. * Creates an instance of this axes viewer.
  45184. * @returns a new axes viewer with instanced meshes
  45185. */
  45186. createInstance(): AxesViewer;
  45187. /** Releases resources */
  45188. dispose(): void;
  45189. private static _SetRenderingGroupId;
  45190. }
  45191. }
  45192. declare module "babylonjs/Debug/boneAxesViewer" {
  45193. import { Nullable } from "babylonjs/types";
  45194. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45195. import { Vector3 } from "babylonjs/Maths/math.vector";
  45196. import { Mesh } from "babylonjs/Meshes/mesh";
  45197. import { Bone } from "babylonjs/Bones/bone";
  45198. import { Scene } from "babylonjs/scene";
  45199. /**
  45200. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45201. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45202. */
  45203. export class BoneAxesViewer extends AxesViewer {
  45204. /**
  45205. * Gets or sets the target mesh where to display the axes viewer
  45206. */
  45207. mesh: Nullable<Mesh>;
  45208. /**
  45209. * Gets or sets the target bone where to display the axes viewer
  45210. */
  45211. bone: Nullable<Bone>;
  45212. /** Gets current position */
  45213. pos: Vector3;
  45214. /** Gets direction of X axis */
  45215. xaxis: Vector3;
  45216. /** Gets direction of Y axis */
  45217. yaxis: Vector3;
  45218. /** Gets direction of Z axis */
  45219. zaxis: Vector3;
  45220. /**
  45221. * Creates a new BoneAxesViewer
  45222. * @param scene defines the hosting scene
  45223. * @param bone defines the target bone
  45224. * @param mesh defines the target mesh
  45225. * @param scaleLines defines a scaling factor for line length (1 by default)
  45226. */
  45227. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45228. /**
  45229. * Force the viewer to update
  45230. */
  45231. update(): void;
  45232. /** Releases resources */
  45233. dispose(): void;
  45234. }
  45235. }
  45236. declare module "babylonjs/Debug/debugLayer" {
  45237. import { Scene } from "babylonjs/scene";
  45238. /**
  45239. * Interface used to define scene explorer extensibility option
  45240. */
  45241. export interface IExplorerExtensibilityOption {
  45242. /**
  45243. * Define the option label
  45244. */
  45245. label: string;
  45246. /**
  45247. * Defines the action to execute on click
  45248. */
  45249. action: (entity: any) => void;
  45250. }
  45251. /**
  45252. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45253. */
  45254. export interface IExplorerExtensibilityGroup {
  45255. /**
  45256. * Defines a predicate to test if a given type mut be extended
  45257. */
  45258. predicate: (entity: any) => boolean;
  45259. /**
  45260. * Gets the list of options added to a type
  45261. */
  45262. entries: IExplorerExtensibilityOption[];
  45263. }
  45264. /**
  45265. * Interface used to define the options to use to create the Inspector
  45266. */
  45267. export interface IInspectorOptions {
  45268. /**
  45269. * Display in overlay mode (default: false)
  45270. */
  45271. overlay?: boolean;
  45272. /**
  45273. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45274. */
  45275. globalRoot?: HTMLElement;
  45276. /**
  45277. * Display the Scene explorer
  45278. */
  45279. showExplorer?: boolean;
  45280. /**
  45281. * Display the property inspector
  45282. */
  45283. showInspector?: boolean;
  45284. /**
  45285. * Display in embed mode (both panes on the right)
  45286. */
  45287. embedMode?: boolean;
  45288. /**
  45289. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45290. */
  45291. handleResize?: boolean;
  45292. /**
  45293. * Allow the panes to popup (default: true)
  45294. */
  45295. enablePopup?: boolean;
  45296. /**
  45297. * Allow the panes to be closed by users (default: true)
  45298. */
  45299. enableClose?: boolean;
  45300. /**
  45301. * Optional list of extensibility entries
  45302. */
  45303. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45304. /**
  45305. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45306. */
  45307. inspectorURL?: string;
  45308. }
  45309. module "babylonjs/scene" {
  45310. interface Scene {
  45311. /**
  45312. * @hidden
  45313. * Backing field
  45314. */
  45315. _debugLayer: DebugLayer;
  45316. /**
  45317. * Gets the debug layer (aka Inspector) associated with the scene
  45318. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45319. */
  45320. debugLayer: DebugLayer;
  45321. }
  45322. }
  45323. /**
  45324. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45325. * what is happening in your scene
  45326. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45327. */
  45328. export class DebugLayer {
  45329. /**
  45330. * Define the url to get the inspector script from.
  45331. * By default it uses the babylonjs CDN.
  45332. * @ignoreNaming
  45333. */
  45334. static InspectorURL: string;
  45335. private _scene;
  45336. private BJSINSPECTOR;
  45337. private _onPropertyChangedObservable?;
  45338. /**
  45339. * Observable triggered when a property is changed through the inspector.
  45340. */
  45341. readonly onPropertyChangedObservable: any;
  45342. /**
  45343. * Instantiates a new debug layer.
  45344. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45345. * what is happening in your scene
  45346. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45347. * @param scene Defines the scene to inspect
  45348. */
  45349. constructor(scene: Scene);
  45350. /** Creates the inspector window. */
  45351. private _createInspector;
  45352. /**
  45353. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45354. * @param entity defines the entity to select
  45355. * @param lineContainerTitle defines the specific block to highlight
  45356. */
  45357. select(entity: any, lineContainerTitle?: string): void;
  45358. /** Get the inspector from bundle or global */
  45359. private _getGlobalInspector;
  45360. /**
  45361. * Get if the inspector is visible or not.
  45362. * @returns true if visible otherwise, false
  45363. */
  45364. isVisible(): boolean;
  45365. /**
  45366. * Hide the inspector and close its window.
  45367. */
  45368. hide(): void;
  45369. /**
  45370. * Launch the debugLayer.
  45371. * @param config Define the configuration of the inspector
  45372. * @return a promise fulfilled when the debug layer is visible
  45373. */
  45374. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45375. }
  45376. }
  45377. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45378. import { Nullable } from "babylonjs/types";
  45379. import { Scene } from "babylonjs/scene";
  45380. import { Vector4 } from "babylonjs/Maths/math.vector";
  45381. import { Color4 } from "babylonjs/Maths/math.color";
  45382. import { Mesh } from "babylonjs/Meshes/mesh";
  45383. /**
  45384. * Class containing static functions to help procedurally build meshes
  45385. */
  45386. export class BoxBuilder {
  45387. /**
  45388. * Creates a box mesh
  45389. * * The parameter `size` sets the size (float) of each box side (default 1)
  45390. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45391. * * 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)
  45392. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45396. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45397. * @param name defines the name of the mesh
  45398. * @param options defines the options used to create the mesh
  45399. * @param scene defines the hosting scene
  45400. * @returns the box mesh
  45401. */
  45402. static CreateBox(name: string, options: {
  45403. size?: number;
  45404. width?: number;
  45405. height?: number;
  45406. depth?: number;
  45407. faceUV?: Vector4[];
  45408. faceColors?: Color4[];
  45409. sideOrientation?: number;
  45410. frontUVs?: Vector4;
  45411. backUVs?: Vector4;
  45412. wrap?: boolean;
  45413. topBaseAt?: number;
  45414. bottomBaseAt?: number;
  45415. updatable?: boolean;
  45416. }, scene?: Nullable<Scene>): Mesh;
  45417. }
  45418. }
  45419. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45420. import { Vector4 } from "babylonjs/Maths/math.vector";
  45421. import { Mesh } from "babylonjs/Meshes/mesh";
  45422. import { Scene } from "babylonjs/scene";
  45423. import { Nullable } from "babylonjs/types";
  45424. /**
  45425. * Class containing static functions to help procedurally build meshes
  45426. */
  45427. export class SphereBuilder {
  45428. /**
  45429. * Creates a sphere mesh
  45430. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45431. * * 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`)
  45432. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45433. * * 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
  45434. * * 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)
  45435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45438. * @param name defines the name of the mesh
  45439. * @param options defines the options used to create the mesh
  45440. * @param scene defines the hosting scene
  45441. * @returns the sphere mesh
  45442. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45443. */
  45444. static CreateSphere(name: string, options: {
  45445. segments?: number;
  45446. diameter?: number;
  45447. diameterX?: number;
  45448. diameterY?: number;
  45449. diameterZ?: number;
  45450. arc?: number;
  45451. slice?: number;
  45452. sideOrientation?: number;
  45453. frontUVs?: Vector4;
  45454. backUVs?: Vector4;
  45455. updatable?: boolean;
  45456. }, scene?: Nullable<Scene>): Mesh;
  45457. }
  45458. }
  45459. declare module "babylonjs/Debug/physicsViewer" {
  45460. import { Nullable } from "babylonjs/types";
  45461. import { Scene } from "babylonjs/scene";
  45462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45463. import { Mesh } from "babylonjs/Meshes/mesh";
  45464. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45465. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45466. /**
  45467. * Used to show the physics impostor around the specific mesh
  45468. */
  45469. export class PhysicsViewer {
  45470. /** @hidden */
  45471. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45472. /** @hidden */
  45473. protected _meshes: Array<Nullable<AbstractMesh>>;
  45474. /** @hidden */
  45475. protected _scene: Nullable<Scene>;
  45476. /** @hidden */
  45477. protected _numMeshes: number;
  45478. /** @hidden */
  45479. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45480. private _renderFunction;
  45481. private _utilityLayer;
  45482. private _debugBoxMesh;
  45483. private _debugSphereMesh;
  45484. private _debugCylinderMesh;
  45485. private _debugMaterial;
  45486. private _debugMeshMeshes;
  45487. /**
  45488. * Creates a new PhysicsViewer
  45489. * @param scene defines the hosting scene
  45490. */
  45491. constructor(scene: Scene);
  45492. /** @hidden */
  45493. protected _updateDebugMeshes(): void;
  45494. /**
  45495. * Renders a specified physic impostor
  45496. * @param impostor defines the impostor to render
  45497. * @param targetMesh defines the mesh represented by the impostor
  45498. * @returns the new debug mesh used to render the impostor
  45499. */
  45500. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45501. /**
  45502. * Hides a specified physic impostor
  45503. * @param impostor defines the impostor to hide
  45504. */
  45505. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45506. private _getDebugMaterial;
  45507. private _getDebugBoxMesh;
  45508. private _getDebugSphereMesh;
  45509. private _getDebugCylinderMesh;
  45510. private _getDebugMeshMesh;
  45511. private _getDebugMesh;
  45512. /** Releases all resources */
  45513. dispose(): void;
  45514. }
  45515. }
  45516. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45517. import { Vector3 } from "babylonjs/Maths/math.vector";
  45518. import { Color4 } from "babylonjs/Maths/math.color";
  45519. import { Nullable } from "babylonjs/types";
  45520. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45521. import { Scene } from "babylonjs/scene";
  45522. /**
  45523. * Class containing static functions to help procedurally build meshes
  45524. */
  45525. export class LinesBuilder {
  45526. /**
  45527. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45528. * * 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
  45529. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45530. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45531. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45532. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45533. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45534. * * 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
  45535. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45538. * @param name defines the name of the new line system
  45539. * @param options defines the options used to create the line system
  45540. * @param scene defines the hosting scene
  45541. * @returns a new line system mesh
  45542. */
  45543. static CreateLineSystem(name: string, options: {
  45544. lines: Vector3[][];
  45545. updatable?: boolean;
  45546. instance?: Nullable<LinesMesh>;
  45547. colors?: Nullable<Color4[][]>;
  45548. useVertexAlpha?: boolean;
  45549. }, scene: Nullable<Scene>): LinesMesh;
  45550. /**
  45551. * Creates a line mesh
  45552. * 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
  45553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45554. * * The parameter `points` is an array successive Vector3
  45555. * * 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
  45556. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45557. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45558. * * When updating an instance, remember that only point positions can change, not the number of points
  45559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45561. * @param name defines the name of the new line system
  45562. * @param options defines the options used to create the line system
  45563. * @param scene defines the hosting scene
  45564. * @returns a new line mesh
  45565. */
  45566. static CreateLines(name: string, options: {
  45567. points: Vector3[];
  45568. updatable?: boolean;
  45569. instance?: Nullable<LinesMesh>;
  45570. colors?: Color4[];
  45571. useVertexAlpha?: boolean;
  45572. }, scene?: Nullable<Scene>): LinesMesh;
  45573. /**
  45574. * Creates a dashed line mesh
  45575. * * 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
  45576. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45577. * * The parameter `points` is an array successive Vector3
  45578. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45579. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45580. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45581. * * 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
  45582. * * When updating an instance, remember that only point positions can change, not the number of points
  45583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45584. * @param name defines the name of the mesh
  45585. * @param options defines the options used to create the mesh
  45586. * @param scene defines the hosting scene
  45587. * @returns the dashed line mesh
  45588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45589. */
  45590. static CreateDashedLines(name: string, options: {
  45591. points: Vector3[];
  45592. dashSize?: number;
  45593. gapSize?: number;
  45594. dashNb?: number;
  45595. updatable?: boolean;
  45596. instance?: LinesMesh;
  45597. }, scene?: Nullable<Scene>): LinesMesh;
  45598. }
  45599. }
  45600. declare module "babylonjs/Debug/rayHelper" {
  45601. import { Nullable } from "babylonjs/types";
  45602. import { Ray } from "babylonjs/Culling/ray";
  45603. import { Vector3 } from "babylonjs/Maths/math.vector";
  45604. import { Color3 } from "babylonjs/Maths/math.color";
  45605. import { Scene } from "babylonjs/scene";
  45606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45607. import "babylonjs/Meshes/Builders/linesBuilder";
  45608. /**
  45609. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45610. * in order to better appreciate the issue one might have.
  45611. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45612. */
  45613. export class RayHelper {
  45614. /**
  45615. * Defines the ray we are currently tryin to visualize.
  45616. */
  45617. ray: Nullable<Ray>;
  45618. private _renderPoints;
  45619. private _renderLine;
  45620. private _renderFunction;
  45621. private _scene;
  45622. private _updateToMeshFunction;
  45623. private _attachedToMesh;
  45624. private _meshSpaceDirection;
  45625. private _meshSpaceOrigin;
  45626. /**
  45627. * Helper function to create a colored helper in a scene in one line.
  45628. * @param ray Defines the ray we are currently tryin to visualize
  45629. * @param scene Defines the scene the ray is used in
  45630. * @param color Defines the color we want to see the ray in
  45631. * @returns The newly created ray helper.
  45632. */
  45633. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45634. /**
  45635. * Instantiate a new ray helper.
  45636. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45637. * in order to better appreciate the issue one might have.
  45638. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45639. * @param ray Defines the ray we are currently tryin to visualize
  45640. */
  45641. constructor(ray: Ray);
  45642. /**
  45643. * Shows the ray we are willing to debug.
  45644. * @param scene Defines the scene the ray needs to be rendered in
  45645. * @param color Defines the color the ray needs to be rendered in
  45646. */
  45647. show(scene: Scene, color?: Color3): void;
  45648. /**
  45649. * Hides the ray we are debugging.
  45650. */
  45651. hide(): void;
  45652. private _render;
  45653. /**
  45654. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45655. * @param mesh Defines the mesh we want the helper attached to
  45656. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45657. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45658. * @param length Defines the length of the ray
  45659. */
  45660. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45661. /**
  45662. * Detach the ray helper from the mesh it has previously been attached to.
  45663. */
  45664. detachFromMesh(): void;
  45665. private _updateToMesh;
  45666. /**
  45667. * Dispose the helper and release its associated resources.
  45668. */
  45669. dispose(): void;
  45670. }
  45671. }
  45672. declare module "babylonjs/Debug/skeletonViewer" {
  45673. import { Color3 } from "babylonjs/Maths/math.color";
  45674. import { Scene } from "babylonjs/scene";
  45675. import { Nullable } from "babylonjs/types";
  45676. import { Skeleton } from "babylonjs/Bones/skeleton";
  45677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45678. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45679. /**
  45680. * Class used to render a debug view of a given skeleton
  45681. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45682. */
  45683. export class SkeletonViewer {
  45684. /** defines the skeleton to render */
  45685. skeleton: Skeleton;
  45686. /** defines the mesh attached to the skeleton */
  45687. mesh: AbstractMesh;
  45688. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45689. autoUpdateBonesMatrices: boolean;
  45690. /** defines the rendering group id to use with the viewer */
  45691. renderingGroupId: number;
  45692. /** Gets or sets the color used to render the skeleton */
  45693. color: Color3;
  45694. private _scene;
  45695. private _debugLines;
  45696. private _debugMesh;
  45697. private _isEnabled;
  45698. private _renderFunction;
  45699. private _utilityLayer;
  45700. /**
  45701. * Returns the mesh used to render the bones
  45702. */
  45703. readonly debugMesh: Nullable<LinesMesh>;
  45704. /**
  45705. * Creates a new SkeletonViewer
  45706. * @param skeleton defines the skeleton to render
  45707. * @param mesh defines the mesh attached to the skeleton
  45708. * @param scene defines the hosting scene
  45709. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45710. * @param renderingGroupId defines the rendering group id to use with the viewer
  45711. */
  45712. constructor(
  45713. /** defines the skeleton to render */
  45714. skeleton: Skeleton,
  45715. /** defines the mesh attached to the skeleton */
  45716. mesh: AbstractMesh, scene: Scene,
  45717. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45718. autoUpdateBonesMatrices?: boolean,
  45719. /** defines the rendering group id to use with the viewer */
  45720. renderingGroupId?: number);
  45721. /** Gets or sets a boolean indicating if the viewer is enabled */
  45722. isEnabled: boolean;
  45723. private _getBonePosition;
  45724. private _getLinesForBonesWithLength;
  45725. private _getLinesForBonesNoLength;
  45726. /** Update the viewer to sync with current skeleton state */
  45727. update(): void;
  45728. /** Release associated resources */
  45729. dispose(): void;
  45730. }
  45731. }
  45732. declare module "babylonjs/Debug/index" {
  45733. export * from "babylonjs/Debug/axesViewer";
  45734. export * from "babylonjs/Debug/boneAxesViewer";
  45735. export * from "babylonjs/Debug/debugLayer";
  45736. export * from "babylonjs/Debug/physicsViewer";
  45737. export * from "babylonjs/Debug/rayHelper";
  45738. export * from "babylonjs/Debug/skeletonViewer";
  45739. }
  45740. declare module "babylonjs/Engines/nullEngine" {
  45741. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45742. import { Scene } from "babylonjs/scene";
  45743. import { Engine } from "babylonjs/Engines/engine";
  45744. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45745. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45747. import { Effect } from "babylonjs/Materials/effect";
  45748. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45749. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45750. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45751. /**
  45752. * Options to create the null engine
  45753. */
  45754. export class NullEngineOptions {
  45755. /**
  45756. * Render width (Default: 512)
  45757. */
  45758. renderWidth: number;
  45759. /**
  45760. * Render height (Default: 256)
  45761. */
  45762. renderHeight: number;
  45763. /**
  45764. * Texture size (Default: 512)
  45765. */
  45766. textureSize: number;
  45767. /**
  45768. * If delta time between frames should be constant
  45769. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45770. */
  45771. deterministicLockstep: boolean;
  45772. /**
  45773. * Maximum about of steps between frames (Default: 4)
  45774. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45775. */
  45776. lockstepMaxSteps: number;
  45777. }
  45778. /**
  45779. * The null engine class provides support for headless version of babylon.js.
  45780. * This can be used in server side scenario or for testing purposes
  45781. */
  45782. export class NullEngine extends Engine {
  45783. private _options;
  45784. /**
  45785. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45787. * @returns true if engine is in deterministic lock step mode
  45788. */
  45789. isDeterministicLockStep(): boolean;
  45790. /**
  45791. * Gets the max steps when engine is running in deterministic lock step
  45792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45793. * @returns the max steps
  45794. */
  45795. getLockstepMaxSteps(): number;
  45796. /**
  45797. * Gets the current hardware scaling level.
  45798. * By default the hardware scaling level is computed from the window device ratio.
  45799. * 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.
  45800. * @returns a number indicating the current hardware scaling level
  45801. */
  45802. getHardwareScalingLevel(): number;
  45803. constructor(options?: NullEngineOptions);
  45804. /**
  45805. * Creates a vertex buffer
  45806. * @param vertices the data for the vertex buffer
  45807. * @returns the new WebGL static buffer
  45808. */
  45809. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45810. /**
  45811. * Creates a new index buffer
  45812. * @param indices defines the content of the index buffer
  45813. * @param updatable defines if the index buffer must be updatable
  45814. * @returns a new webGL buffer
  45815. */
  45816. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45817. /**
  45818. * Clear the current render buffer or the current render target (if any is set up)
  45819. * @param color defines the color to use
  45820. * @param backBuffer defines if the back buffer must be cleared
  45821. * @param depth defines if the depth buffer must be cleared
  45822. * @param stencil defines if the stencil buffer must be cleared
  45823. */
  45824. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45825. /**
  45826. * Gets the current render width
  45827. * @param useScreen defines if screen size must be used (or the current render target if any)
  45828. * @returns a number defining the current render width
  45829. */
  45830. getRenderWidth(useScreen?: boolean): number;
  45831. /**
  45832. * Gets the current render height
  45833. * @param useScreen defines if screen size must be used (or the current render target if any)
  45834. * @returns a number defining the current render height
  45835. */
  45836. getRenderHeight(useScreen?: boolean): number;
  45837. /**
  45838. * Set the WebGL's viewport
  45839. * @param viewport defines the viewport element to be used
  45840. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45841. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45842. */
  45843. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45844. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45845. /**
  45846. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45847. * @param pipelineContext defines the pipeline context to use
  45848. * @param uniformsNames defines the list of uniform names
  45849. * @returns an array of webGL uniform locations
  45850. */
  45851. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45852. /**
  45853. * Gets the lsit of active attributes for a given webGL program
  45854. * @param pipelineContext defines the pipeline context to use
  45855. * @param attributesNames defines the list of attribute names to get
  45856. * @returns an array of indices indicating the offset of each attribute
  45857. */
  45858. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45859. /**
  45860. * Binds an effect to the webGL context
  45861. * @param effect defines the effect to bind
  45862. */
  45863. bindSamplers(effect: Effect): void;
  45864. /**
  45865. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45866. * @param effect defines the effect to activate
  45867. */
  45868. enableEffect(effect: Effect): void;
  45869. /**
  45870. * Set various states to the webGL context
  45871. * @param culling defines backface culling state
  45872. * @param zOffset defines the value to apply to zOffset (0 by default)
  45873. * @param force defines if states must be applied even if cache is up to date
  45874. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45875. */
  45876. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45877. /**
  45878. * Set the value of an uniform to an array of int32
  45879. * @param uniform defines the webGL uniform location where to store the value
  45880. * @param array defines the array of int32 to store
  45881. */
  45882. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45883. /**
  45884. * Set the value of an uniform to an array of int32 (stored as vec2)
  45885. * @param uniform defines the webGL uniform location where to store the value
  45886. * @param array defines the array of int32 to store
  45887. */
  45888. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45889. /**
  45890. * Set the value of an uniform to an array of int32 (stored as vec3)
  45891. * @param uniform defines the webGL uniform location where to store the value
  45892. * @param array defines the array of int32 to store
  45893. */
  45894. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45895. /**
  45896. * Set the value of an uniform to an array of int32 (stored as vec4)
  45897. * @param uniform defines the webGL uniform location where to store the value
  45898. * @param array defines the array of int32 to store
  45899. */
  45900. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45901. /**
  45902. * Set the value of an uniform to an array of float32
  45903. * @param uniform defines the webGL uniform location where to store the value
  45904. * @param array defines the array of float32 to store
  45905. */
  45906. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45907. /**
  45908. * Set the value of an uniform to an array of float32 (stored as vec2)
  45909. * @param uniform defines the webGL uniform location where to store the value
  45910. * @param array defines the array of float32 to store
  45911. */
  45912. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45913. /**
  45914. * Set the value of an uniform to an array of float32 (stored as vec3)
  45915. * @param uniform defines the webGL uniform location where to store the value
  45916. * @param array defines the array of float32 to store
  45917. */
  45918. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45919. /**
  45920. * Set the value of an uniform to an array of float32 (stored as vec4)
  45921. * @param uniform defines the webGL uniform location where to store the value
  45922. * @param array defines the array of float32 to store
  45923. */
  45924. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45925. /**
  45926. * Set the value of an uniform to an array of number
  45927. * @param uniform defines the webGL uniform location where to store the value
  45928. * @param array defines the array of number to store
  45929. */
  45930. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45931. /**
  45932. * Set the value of an uniform to an array of number (stored as vec2)
  45933. * @param uniform defines the webGL uniform location where to store the value
  45934. * @param array defines the array of number to store
  45935. */
  45936. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45937. /**
  45938. * Set the value of an uniform to an array of number (stored as vec3)
  45939. * @param uniform defines the webGL uniform location where to store the value
  45940. * @param array defines the array of number to store
  45941. */
  45942. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45943. /**
  45944. * Set the value of an uniform to an array of number (stored as vec4)
  45945. * @param uniform defines the webGL uniform location where to store the value
  45946. * @param array defines the array of number to store
  45947. */
  45948. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45949. /**
  45950. * Set the value of an uniform to an array of float32 (stored as matrices)
  45951. * @param uniform defines the webGL uniform location where to store the value
  45952. * @param matrices defines the array of float32 to store
  45953. */
  45954. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45955. /**
  45956. * Set the value of an uniform to a matrix (3x3)
  45957. * @param uniform defines the webGL uniform location where to store the value
  45958. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45959. */
  45960. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45961. /**
  45962. * Set the value of an uniform to a matrix (2x2)
  45963. * @param uniform defines the webGL uniform location where to store the value
  45964. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45965. */
  45966. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45967. /**
  45968. * Set the value of an uniform to a number (float)
  45969. * @param uniform defines the webGL uniform location where to store the value
  45970. * @param value defines the float number to store
  45971. */
  45972. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45973. /**
  45974. * Set the value of an uniform to a vec2
  45975. * @param uniform defines the webGL uniform location where to store the value
  45976. * @param x defines the 1st component of the value
  45977. * @param y defines the 2nd component of the value
  45978. */
  45979. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45980. /**
  45981. * Set the value of an uniform to a vec3
  45982. * @param uniform defines the webGL uniform location where to store the value
  45983. * @param x defines the 1st component of the value
  45984. * @param y defines the 2nd component of the value
  45985. * @param z defines the 3rd component of the value
  45986. */
  45987. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45988. /**
  45989. * Set the value of an uniform to a boolean
  45990. * @param uniform defines the webGL uniform location where to store the value
  45991. * @param bool defines the boolean to store
  45992. */
  45993. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45994. /**
  45995. * Set the value of an uniform to a vec4
  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. * @param w defines the 4th component of the value
  46001. */
  46002. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46003. /**
  46004. * Sets the current alpha mode
  46005. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46006. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46007. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46008. */
  46009. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46010. /**
  46011. * Bind webGl buffers directly to the webGL context
  46012. * @param vertexBuffers defines the vertex buffer to bind
  46013. * @param indexBuffer defines the index buffer to bind
  46014. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46015. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46016. * @param effect defines the effect associated with the vertex buffer
  46017. */
  46018. bindBuffers(vertexBuffers: {
  46019. [key: string]: VertexBuffer;
  46020. }, indexBuffer: DataBuffer, effect: Effect): void;
  46021. /**
  46022. * Force the entire cache to be cleared
  46023. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46024. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46025. */
  46026. wipeCaches(bruteForce?: boolean): void;
  46027. /**
  46028. * Send a draw order
  46029. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46030. * @param indexStart defines the starting index
  46031. * @param indexCount defines the number of index to draw
  46032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46033. */
  46034. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46035. /**
  46036. * Draw a list of indexed primitives
  46037. * @param fillMode defines the primitive to use
  46038. * @param indexStart defines the starting index
  46039. * @param indexCount defines the number of index to draw
  46040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46041. */
  46042. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46043. /**
  46044. * Draw a list of unindexed primitives
  46045. * @param fillMode defines the primitive to use
  46046. * @param verticesStart defines the index of first vertex to draw
  46047. * @param verticesCount defines the count of vertices to draw
  46048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46049. */
  46050. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46051. /** @hidden */
  46052. _createTexture(): WebGLTexture;
  46053. /** @hidden */
  46054. _releaseTexture(texture: InternalTexture): void;
  46055. /**
  46056. * Usually called from Texture.ts.
  46057. * Passed information to create a WebGLTexture
  46058. * @param urlArg defines a value which contains one of the following:
  46059. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46060. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46061. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46062. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46063. * @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)
  46064. * @param scene needed for loading to the correct scene
  46065. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46066. * @param onLoad optional callback to be called upon successful completion
  46067. * @param onError optional callback to be called upon failure
  46068. * @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
  46069. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46070. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46071. * @param forcedExtension defines the extension to use to pick the right loader
  46072. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46073. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46074. */
  46075. 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;
  46076. /**
  46077. * Creates a new render target texture
  46078. * @param size defines the size of the texture
  46079. * @param options defines the options used to create the texture
  46080. * @returns a new render target texture stored in an InternalTexture
  46081. */
  46082. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46083. /**
  46084. * Update the sampling mode of a given texture
  46085. * @param samplingMode defines the required sampling mode
  46086. * @param texture defines the texture to update
  46087. */
  46088. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46089. /**
  46090. * Binds the frame buffer to the specified texture.
  46091. * @param texture The texture to render to or null for the default canvas
  46092. * @param faceIndex The face of the texture to render to in case of cube texture
  46093. * @param requiredWidth The width of the target to render to
  46094. * @param requiredHeight The height of the target to render to
  46095. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46096. * @param depthStencilTexture The depth stencil texture to use to render
  46097. * @param lodLevel defines le lod level to bind to the frame buffer
  46098. */
  46099. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46100. /**
  46101. * Unbind the current render target texture from the webGL context
  46102. * @param texture defines the render target texture to unbind
  46103. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46104. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46105. */
  46106. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46107. /**
  46108. * Creates a dynamic vertex buffer
  46109. * @param vertices the data for the dynamic vertex buffer
  46110. * @returns the new WebGL dynamic buffer
  46111. */
  46112. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46113. /**
  46114. * Update the content of a dynamic texture
  46115. * @param texture defines the texture to update
  46116. * @param canvas defines the canvas containing the source
  46117. * @param invertY defines if data must be stored with Y axis inverted
  46118. * @param premulAlpha defines if alpha is stored as premultiplied
  46119. * @param format defines the format of the data
  46120. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46121. */
  46122. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46123. /**
  46124. * Gets a boolean indicating if all created effects are ready
  46125. * @returns true if all effects are ready
  46126. */
  46127. areAllEffectsReady(): boolean;
  46128. /**
  46129. * @hidden
  46130. * Get the current error code of the webGL context
  46131. * @returns the error code
  46132. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46133. */
  46134. getError(): number;
  46135. /** @hidden */
  46136. _getUnpackAlignement(): number;
  46137. /** @hidden */
  46138. _unpackFlipY(value: boolean): void;
  46139. /**
  46140. * Update a dynamic index buffer
  46141. * @param indexBuffer defines the target index buffer
  46142. * @param indices defines the data to update
  46143. * @param offset defines the offset in the target index buffer where update should start
  46144. */
  46145. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46146. /**
  46147. * Updates a dynamic vertex buffer.
  46148. * @param vertexBuffer the vertex buffer to update
  46149. * @param vertices the data used to update the vertex buffer
  46150. * @param byteOffset the byte offset of the data (optional)
  46151. * @param byteLength the byte length of the data (optional)
  46152. */
  46153. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46154. /** @hidden */
  46155. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46156. /** @hidden */
  46157. _bindTexture(channel: number, texture: InternalTexture): void;
  46158. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46159. /**
  46160. * 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
  46161. */
  46162. releaseEffects(): void;
  46163. displayLoadingUI(): void;
  46164. hideLoadingUI(): void;
  46165. /** @hidden */
  46166. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46167. /** @hidden */
  46168. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46169. /** @hidden */
  46170. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46171. /** @hidden */
  46172. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46173. }
  46174. }
  46175. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46176. import { Nullable, int } from "babylonjs/types";
  46177. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46178. /** @hidden */
  46179. export class _OcclusionDataStorage {
  46180. /** @hidden */
  46181. occlusionInternalRetryCounter: number;
  46182. /** @hidden */
  46183. isOcclusionQueryInProgress: boolean;
  46184. /** @hidden */
  46185. isOccluded: boolean;
  46186. /** @hidden */
  46187. occlusionRetryCount: number;
  46188. /** @hidden */
  46189. occlusionType: number;
  46190. /** @hidden */
  46191. occlusionQueryAlgorithmType: number;
  46192. }
  46193. module "babylonjs/Engines/engine" {
  46194. interface Engine {
  46195. /**
  46196. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46197. * @return the new query
  46198. */
  46199. createQuery(): WebGLQuery;
  46200. /**
  46201. * Delete and release a webGL query
  46202. * @param query defines the query to delete
  46203. * @return the current engine
  46204. */
  46205. deleteQuery(query: WebGLQuery): Engine;
  46206. /**
  46207. * Check if a given query has resolved and got its value
  46208. * @param query defines the query to check
  46209. * @returns true if the query got its value
  46210. */
  46211. isQueryResultAvailable(query: WebGLQuery): boolean;
  46212. /**
  46213. * Gets the value of a given query
  46214. * @param query defines the query to check
  46215. * @returns the value of the query
  46216. */
  46217. getQueryResult(query: WebGLQuery): number;
  46218. /**
  46219. * Initiates an occlusion query
  46220. * @param algorithmType defines the algorithm to use
  46221. * @param query defines the query to use
  46222. * @returns the current engine
  46223. * @see http://doc.babylonjs.com/features/occlusionquery
  46224. */
  46225. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46226. /**
  46227. * Ends an occlusion query
  46228. * @see http://doc.babylonjs.com/features/occlusionquery
  46229. * @param algorithmType defines the algorithm to use
  46230. * @returns the current engine
  46231. */
  46232. endOcclusionQuery(algorithmType: number): Engine;
  46233. /**
  46234. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46235. * Please note that only one query can be issued at a time
  46236. * @returns a time token used to track the time span
  46237. */
  46238. startTimeQuery(): Nullable<_TimeToken>;
  46239. /**
  46240. * Ends a time query
  46241. * @param token defines the token used to measure the time span
  46242. * @returns the time spent (in ns)
  46243. */
  46244. endTimeQuery(token: _TimeToken): int;
  46245. /** @hidden */
  46246. _currentNonTimestampToken: Nullable<_TimeToken>;
  46247. /** @hidden */
  46248. _createTimeQuery(): WebGLQuery;
  46249. /** @hidden */
  46250. _deleteTimeQuery(query: WebGLQuery): void;
  46251. /** @hidden */
  46252. _getGlAlgorithmType(algorithmType: number): number;
  46253. /** @hidden */
  46254. _getTimeQueryResult(query: WebGLQuery): any;
  46255. /** @hidden */
  46256. _getTimeQueryAvailability(query: WebGLQuery): any;
  46257. }
  46258. }
  46259. module "babylonjs/Meshes/abstractMesh" {
  46260. interface AbstractMesh {
  46261. /**
  46262. * Backing filed
  46263. * @hidden
  46264. */
  46265. __occlusionDataStorage: _OcclusionDataStorage;
  46266. /**
  46267. * Access property
  46268. * @hidden
  46269. */
  46270. _occlusionDataStorage: _OcclusionDataStorage;
  46271. /**
  46272. * 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.
  46273. * The default value is -1 which means don't break the query and wait till the result
  46274. * @see http://doc.babylonjs.com/features/occlusionquery
  46275. */
  46276. occlusionRetryCount: number;
  46277. /**
  46278. * 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:
  46279. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46280. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46281. * * 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.
  46282. * @see http://doc.babylonjs.com/features/occlusionquery
  46283. */
  46284. occlusionType: number;
  46285. /**
  46286. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46287. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46288. * * 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.
  46289. * @see http://doc.babylonjs.com/features/occlusionquery
  46290. */
  46291. occlusionQueryAlgorithmType: number;
  46292. /**
  46293. * 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
  46294. * @see http://doc.babylonjs.com/features/occlusionquery
  46295. */
  46296. isOccluded: boolean;
  46297. /**
  46298. * Flag to check the progress status of the query
  46299. * @see http://doc.babylonjs.com/features/occlusionquery
  46300. */
  46301. isOcclusionQueryInProgress: boolean;
  46302. }
  46303. }
  46304. }
  46305. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46306. import { Nullable } from "babylonjs/types";
  46307. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46308. /** @hidden */
  46309. export var _forceTransformFeedbackToBundle: boolean;
  46310. module "babylonjs/Engines/engine" {
  46311. interface Engine {
  46312. /**
  46313. * Creates a webGL transform feedback object
  46314. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46315. * @returns the webGL transform feedback object
  46316. */
  46317. createTransformFeedback(): WebGLTransformFeedback;
  46318. /**
  46319. * Delete a webGL transform feedback object
  46320. * @param value defines the webGL transform feedback object to delete
  46321. */
  46322. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46323. /**
  46324. * Bind a webGL transform feedback object to the webgl context
  46325. * @param value defines the webGL transform feedback object to bind
  46326. */
  46327. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46328. /**
  46329. * Begins a transform feedback operation
  46330. * @param usePoints defines if points or triangles must be used
  46331. */
  46332. beginTransformFeedback(usePoints: boolean): void;
  46333. /**
  46334. * Ends a transform feedback operation
  46335. */
  46336. endTransformFeedback(): void;
  46337. /**
  46338. * Specify the varyings to use with transform feedback
  46339. * @param program defines the associated webGL program
  46340. * @param value defines the list of strings representing the varying names
  46341. */
  46342. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46343. /**
  46344. * Bind a webGL buffer for a transform feedback operation
  46345. * @param value defines the webGL buffer to bind
  46346. */
  46347. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46348. }
  46349. }
  46350. }
  46351. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46352. import { Scene } from "babylonjs/scene";
  46353. import { Engine } from "babylonjs/Engines/engine";
  46354. import { Texture } from "babylonjs/Materials/Textures/texture";
  46355. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46356. import "babylonjs/Engines/Extensions/engine.multiRender";
  46357. /**
  46358. * Creation options of the multi render target texture.
  46359. */
  46360. export interface IMultiRenderTargetOptions {
  46361. /**
  46362. * Define if the texture needs to create mip maps after render.
  46363. */
  46364. generateMipMaps?: boolean;
  46365. /**
  46366. * Define the types of all the draw buffers we want to create
  46367. */
  46368. types?: number[];
  46369. /**
  46370. * Define the sampling modes of all the draw buffers we want to create
  46371. */
  46372. samplingModes?: number[];
  46373. /**
  46374. * Define if a depth buffer is required
  46375. */
  46376. generateDepthBuffer?: boolean;
  46377. /**
  46378. * Define if a stencil buffer is required
  46379. */
  46380. generateStencilBuffer?: boolean;
  46381. /**
  46382. * Define if a depth texture is required instead of a depth buffer
  46383. */
  46384. generateDepthTexture?: boolean;
  46385. /**
  46386. * Define the number of desired draw buffers
  46387. */
  46388. textureCount?: number;
  46389. /**
  46390. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46391. */
  46392. doNotChangeAspectRatio?: boolean;
  46393. /**
  46394. * Define the default type of the buffers we are creating
  46395. */
  46396. defaultType?: number;
  46397. }
  46398. /**
  46399. * A multi render target, like a render target provides the ability to render to a texture.
  46400. * Unlike the render target, it can render to several draw buffers in one draw.
  46401. * This is specially interesting in deferred rendering or for any effects requiring more than
  46402. * just one color from a single pass.
  46403. */
  46404. export class MultiRenderTarget extends RenderTargetTexture {
  46405. private _internalTextures;
  46406. private _textures;
  46407. private _multiRenderTargetOptions;
  46408. /**
  46409. * Get if draw buffers are currently supported by the used hardware and browser.
  46410. */
  46411. readonly isSupported: boolean;
  46412. /**
  46413. * Get the list of textures generated by the multi render target.
  46414. */
  46415. readonly textures: Texture[];
  46416. /**
  46417. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46418. */
  46419. readonly depthTexture: Texture;
  46420. /**
  46421. * Set the wrapping mode on U of all the textures we are rendering to.
  46422. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46423. */
  46424. wrapU: number;
  46425. /**
  46426. * Set the wrapping mode on V of all the textures we are rendering to.
  46427. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46428. */
  46429. wrapV: number;
  46430. /**
  46431. * Instantiate a new multi render target texture.
  46432. * A multi render target, like a render target provides the ability to render to a texture.
  46433. * Unlike the render target, it can render to several draw buffers in one draw.
  46434. * This is specially interesting in deferred rendering or for any effects requiring more than
  46435. * just one color from a single pass.
  46436. * @param name Define the name of the texture
  46437. * @param size Define the size of the buffers to render to
  46438. * @param count Define the number of target we are rendering into
  46439. * @param scene Define the scene the texture belongs to
  46440. * @param options Define the options used to create the multi render target
  46441. */
  46442. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46443. /** @hidden */
  46444. _rebuild(): void;
  46445. private _createInternalTextures;
  46446. private _createTextures;
  46447. /**
  46448. * Define the number of samples used if MSAA is enabled.
  46449. */
  46450. samples: number;
  46451. /**
  46452. * Resize all the textures in the multi render target.
  46453. * Be carrefull as it will recreate all the data in the new texture.
  46454. * @param size Define the new size
  46455. */
  46456. resize(size: any): void;
  46457. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46458. /**
  46459. * Dispose the render targets and their associated resources
  46460. */
  46461. dispose(): void;
  46462. /**
  46463. * Release all the underlying texture used as draw buffers.
  46464. */
  46465. releaseInternalTextures(): void;
  46466. }
  46467. }
  46468. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46469. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46470. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46471. import { Nullable } from "babylonjs/types";
  46472. module "babylonjs/Engines/thinEngine" {
  46473. interface ThinEngine {
  46474. /**
  46475. * Unbind a list of render target textures from the webGL context
  46476. * This is used only when drawBuffer extension or webGL2 are active
  46477. * @param textures defines the render target textures to unbind
  46478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46480. */
  46481. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46482. /**
  46483. * Create a multi render target texture
  46484. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46485. * @param size defines the size of the texture
  46486. * @param options defines the creation options
  46487. * @returns the cube texture as an InternalTexture
  46488. */
  46489. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46490. /**
  46491. * Update the sample count for a given multiple render target texture
  46492. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46493. * @param textures defines the textures to update
  46494. * @param samples defines the sample count to set
  46495. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46496. */
  46497. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46498. }
  46499. }
  46500. }
  46501. declare module "babylonjs/Engines/Extensions/engine.views" {
  46502. import { Camera } from "babylonjs/Cameras/camera";
  46503. import { Nullable } from "babylonjs/types";
  46504. /**
  46505. * Class used to define an additional view for the engine
  46506. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46507. */
  46508. export class EngineView {
  46509. /** Defines the canvas where to render the view */
  46510. target: HTMLCanvasElement;
  46511. /** Defines an optional camera used to render the view (will use active camera else) */
  46512. camera?: Camera;
  46513. }
  46514. module "babylonjs/Engines/engine" {
  46515. interface Engine {
  46516. /**
  46517. * Gets or sets the HTML element to use for attaching events
  46518. */
  46519. inputElement: Nullable<HTMLElement>;
  46520. /**
  46521. * Gets the current engine view
  46522. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46523. */
  46524. activeView: Nullable<EngineView>;
  46525. /** Gets or sets the list of views */
  46526. views: EngineView[];
  46527. /**
  46528. * Register a new child canvas
  46529. * @param canvas defines the canvas to register
  46530. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46531. * @returns the associated view
  46532. */
  46533. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46534. /**
  46535. * Remove a registered child canvas
  46536. * @param canvas defines the canvas to remove
  46537. * @returns the current engine
  46538. */
  46539. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46540. }
  46541. }
  46542. }
  46543. declare module "babylonjs/Engines/Extensions/index" {
  46544. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46545. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46546. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46547. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46548. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46549. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46550. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46551. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46552. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46553. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46554. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46555. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46556. export * from "babylonjs/Engines/Extensions/engine.views";
  46557. }
  46558. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46559. import { Nullable } from "babylonjs/types";
  46560. /**
  46561. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46562. */
  46563. export interface CubeMapInfo {
  46564. /**
  46565. * The pixel array for the front face.
  46566. * This is stored in format, left to right, up to down format.
  46567. */
  46568. front: Nullable<ArrayBufferView>;
  46569. /**
  46570. * The pixel array for the back face.
  46571. * This is stored in format, left to right, up to down format.
  46572. */
  46573. back: Nullable<ArrayBufferView>;
  46574. /**
  46575. * The pixel array for the left face.
  46576. * This is stored in format, left to right, up to down format.
  46577. */
  46578. left: Nullable<ArrayBufferView>;
  46579. /**
  46580. * The pixel array for the right face.
  46581. * This is stored in format, left to right, up to down format.
  46582. */
  46583. right: Nullable<ArrayBufferView>;
  46584. /**
  46585. * The pixel array for the up face.
  46586. * This is stored in format, left to right, up to down format.
  46587. */
  46588. up: Nullable<ArrayBufferView>;
  46589. /**
  46590. * The pixel array for the down face.
  46591. * This is stored in format, left to right, up to down format.
  46592. */
  46593. down: Nullable<ArrayBufferView>;
  46594. /**
  46595. * The size of the cubemap stored.
  46596. *
  46597. * Each faces will be size * size pixels.
  46598. */
  46599. size: number;
  46600. /**
  46601. * The format of the texture.
  46602. *
  46603. * RGBA, RGB.
  46604. */
  46605. format: number;
  46606. /**
  46607. * The type of the texture data.
  46608. *
  46609. * UNSIGNED_INT, FLOAT.
  46610. */
  46611. type: number;
  46612. /**
  46613. * Specifies whether the texture is in gamma space.
  46614. */
  46615. gammaSpace: boolean;
  46616. }
  46617. /**
  46618. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46619. */
  46620. export class PanoramaToCubeMapTools {
  46621. private static FACE_FRONT;
  46622. private static FACE_BACK;
  46623. private static FACE_RIGHT;
  46624. private static FACE_LEFT;
  46625. private static FACE_DOWN;
  46626. private static FACE_UP;
  46627. /**
  46628. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46629. *
  46630. * @param float32Array The source data.
  46631. * @param inputWidth The width of the input panorama.
  46632. * @param inputHeight The height of the input panorama.
  46633. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46634. * @return The cubemap data
  46635. */
  46636. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46637. private static CreateCubemapTexture;
  46638. private static CalcProjectionSpherical;
  46639. }
  46640. }
  46641. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46642. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46644. import { Nullable } from "babylonjs/types";
  46645. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46646. /**
  46647. * Helper class dealing with the extraction of spherical polynomial dataArray
  46648. * from a cube map.
  46649. */
  46650. export class CubeMapToSphericalPolynomialTools {
  46651. private static FileFaces;
  46652. /**
  46653. * Converts a texture to the according Spherical Polynomial data.
  46654. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46655. *
  46656. * @param texture The texture to extract the information from.
  46657. * @return The Spherical Polynomial data.
  46658. */
  46659. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46660. /**
  46661. * Converts a cubemap to the according Spherical Polynomial data.
  46662. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46663. *
  46664. * @param cubeInfo The Cube map to extract the information from.
  46665. * @return The Spherical Polynomial data.
  46666. */
  46667. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46668. }
  46669. }
  46670. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46671. import { Nullable } from "babylonjs/types";
  46672. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46673. module "babylonjs/Materials/Textures/baseTexture" {
  46674. interface BaseTexture {
  46675. /**
  46676. * Get the polynomial representation of the texture data.
  46677. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46678. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46679. */
  46680. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46681. }
  46682. }
  46683. }
  46684. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46685. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46686. /** @hidden */
  46687. export var rgbdEncodePixelShader: {
  46688. name: string;
  46689. shader: string;
  46690. };
  46691. }
  46692. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46693. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46694. /** @hidden */
  46695. export var rgbdDecodePixelShader: {
  46696. name: string;
  46697. shader: string;
  46698. };
  46699. }
  46700. declare module "babylonjs/Misc/environmentTextureTools" {
  46701. import { Nullable } from "babylonjs/types";
  46702. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46703. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46704. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46705. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46706. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46707. import "babylonjs/Shaders/rgbdEncode.fragment";
  46708. import "babylonjs/Shaders/rgbdDecode.fragment";
  46709. /**
  46710. * Raw texture data and descriptor sufficient for WebGL texture upload
  46711. */
  46712. export interface EnvironmentTextureInfo {
  46713. /**
  46714. * Version of the environment map
  46715. */
  46716. version: number;
  46717. /**
  46718. * Width of image
  46719. */
  46720. width: number;
  46721. /**
  46722. * Irradiance information stored in the file.
  46723. */
  46724. irradiance: any;
  46725. /**
  46726. * Specular information stored in the file.
  46727. */
  46728. specular: any;
  46729. }
  46730. /**
  46731. * Defines One Image in the file. It requires only the position in the file
  46732. * as well as the length.
  46733. */
  46734. interface BufferImageData {
  46735. /**
  46736. * Length of the image data.
  46737. */
  46738. length: number;
  46739. /**
  46740. * Position of the data from the null terminator delimiting the end of the JSON.
  46741. */
  46742. position: number;
  46743. }
  46744. /**
  46745. * Defines the specular data enclosed in the file.
  46746. * This corresponds to the version 1 of the data.
  46747. */
  46748. export interface EnvironmentTextureSpecularInfoV1 {
  46749. /**
  46750. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46751. */
  46752. specularDataPosition?: number;
  46753. /**
  46754. * This contains all the images data needed to reconstruct the cubemap.
  46755. */
  46756. mipmaps: Array<BufferImageData>;
  46757. /**
  46758. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46759. */
  46760. lodGenerationScale: number;
  46761. }
  46762. /**
  46763. * Sets of helpers addressing the serialization and deserialization of environment texture
  46764. * stored in a BabylonJS env file.
  46765. * Those files are usually stored as .env files.
  46766. */
  46767. export class EnvironmentTextureTools {
  46768. /**
  46769. * Magic number identifying the env file.
  46770. */
  46771. private static _MagicBytes;
  46772. /**
  46773. * Gets the environment info from an env file.
  46774. * @param data The array buffer containing the .env bytes.
  46775. * @returns the environment file info (the json header) if successfully parsed.
  46776. */
  46777. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46778. /**
  46779. * Creates an environment texture from a loaded cube texture.
  46780. * @param texture defines the cube texture to convert in env file
  46781. * @return a promise containing the environment data if succesfull.
  46782. */
  46783. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46784. /**
  46785. * Creates a JSON representation of the spherical data.
  46786. * @param texture defines the texture containing the polynomials
  46787. * @return the JSON representation of the spherical info
  46788. */
  46789. private static _CreateEnvTextureIrradiance;
  46790. /**
  46791. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46792. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46793. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46794. * @return the views described by info providing access to the underlying buffer
  46795. */
  46796. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46797. /**
  46798. * Uploads the texture info contained in the env file to the GPU.
  46799. * @param texture defines the internal texture to upload to
  46800. * @param arrayBuffer defines the buffer cotaining the data to load
  46801. * @param info defines the texture info retrieved through the GetEnvInfo method
  46802. * @returns a promise
  46803. */
  46804. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46805. private static _OnImageReadyAsync;
  46806. /**
  46807. * Uploads the levels of image data to the GPU.
  46808. * @param texture defines the internal texture to upload to
  46809. * @param imageData defines the array buffer views of image data [mipmap][face]
  46810. * @returns a promise
  46811. */
  46812. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46813. /**
  46814. * Uploads spherical polynomials information to the texture.
  46815. * @param texture defines the texture we are trying to upload the information to
  46816. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46817. */
  46818. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46819. /** @hidden */
  46820. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46821. }
  46822. }
  46823. declare module "babylonjs/Maths/math.vertexFormat" {
  46824. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46825. /**
  46826. * Contains position and normal vectors for a vertex
  46827. */
  46828. export class PositionNormalVertex {
  46829. /** the position of the vertex (defaut: 0,0,0) */
  46830. position: Vector3;
  46831. /** the normal of the vertex (defaut: 0,1,0) */
  46832. normal: Vector3;
  46833. /**
  46834. * Creates a PositionNormalVertex
  46835. * @param position the position of the vertex (defaut: 0,0,0)
  46836. * @param normal the normal of the vertex (defaut: 0,1,0)
  46837. */
  46838. constructor(
  46839. /** the position of the vertex (defaut: 0,0,0) */
  46840. position?: Vector3,
  46841. /** the normal of the vertex (defaut: 0,1,0) */
  46842. normal?: Vector3);
  46843. /**
  46844. * Clones the PositionNormalVertex
  46845. * @returns the cloned PositionNormalVertex
  46846. */
  46847. clone(): PositionNormalVertex;
  46848. }
  46849. /**
  46850. * Contains position, normal and uv vectors for a vertex
  46851. */
  46852. export class PositionNormalTextureVertex {
  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. /** the uv of the vertex (default: 0,0) */
  46858. uv: Vector2;
  46859. /**
  46860. * Creates a PositionNormalTextureVertex
  46861. * @param position the position of the vertex (defaut: 0,0,0)
  46862. * @param normal the normal of the vertex (defaut: 0,1,0)
  46863. * @param uv the uv of the vertex (default: 0,0)
  46864. */
  46865. constructor(
  46866. /** the position of the vertex (defaut: 0,0,0) */
  46867. position?: Vector3,
  46868. /** the normal of the vertex (defaut: 0,1,0) */
  46869. normal?: Vector3,
  46870. /** the uv of the vertex (default: 0,0) */
  46871. uv?: Vector2);
  46872. /**
  46873. * Clones the PositionNormalTextureVertex
  46874. * @returns the cloned PositionNormalTextureVertex
  46875. */
  46876. clone(): PositionNormalTextureVertex;
  46877. }
  46878. }
  46879. declare module "babylonjs/Maths/math" {
  46880. export * from "babylonjs/Maths/math.axis";
  46881. export * from "babylonjs/Maths/math.color";
  46882. export * from "babylonjs/Maths/math.constants";
  46883. export * from "babylonjs/Maths/math.frustum";
  46884. export * from "babylonjs/Maths/math.path";
  46885. export * from "babylonjs/Maths/math.plane";
  46886. export * from "babylonjs/Maths/math.size";
  46887. export * from "babylonjs/Maths/math.vector";
  46888. export * from "babylonjs/Maths/math.vertexFormat";
  46889. export * from "babylonjs/Maths/math.viewport";
  46890. }
  46891. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46892. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46893. /** @hidden */
  46894. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46895. private _genericAttributeLocation;
  46896. private _varyingLocationCount;
  46897. private _varyingLocationMap;
  46898. private _replacements;
  46899. private _textureCount;
  46900. private _uniforms;
  46901. lineProcessor(line: string): string;
  46902. attributeProcessor(attribute: string): string;
  46903. varyingProcessor(varying: string, isFragment: boolean): string;
  46904. uniformProcessor(uniform: string): string;
  46905. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46906. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46907. }
  46908. }
  46909. declare module "babylonjs/Engines/nativeEngine" {
  46910. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46911. import { Engine } from "babylonjs/Engines/engine";
  46912. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46915. import { Effect } from "babylonjs/Materials/effect";
  46916. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46917. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46918. import { Scene } from "babylonjs/scene";
  46919. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46920. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46921. /**
  46922. * Container for accessors for natively-stored mesh data buffers.
  46923. */
  46924. class NativeDataBuffer extends DataBuffer {
  46925. /**
  46926. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46927. */
  46928. nativeIndexBuffer?: any;
  46929. /**
  46930. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46931. */
  46932. nativeVertexBuffer?: any;
  46933. }
  46934. /** @hidden */
  46935. class NativeTexture extends InternalTexture {
  46936. getInternalTexture(): InternalTexture;
  46937. getViewCount(): number;
  46938. }
  46939. /** @hidden */
  46940. export class NativeEngine extends Engine {
  46941. private readonly _native;
  46942. getHardwareScalingLevel(): number;
  46943. constructor();
  46944. /**
  46945. * Can be used to override the current requestAnimationFrame requester.
  46946. * @hidden
  46947. */
  46948. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46949. /**
  46950. * Override default engine behavior.
  46951. * @param color
  46952. * @param backBuffer
  46953. * @param depth
  46954. * @param stencil
  46955. */
  46956. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46957. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46958. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46959. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46960. recordVertexArrayObject(vertexBuffers: {
  46961. [key: string]: VertexBuffer;
  46962. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46963. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46964. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46965. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46966. /**
  46967. * Draw a list of indexed primitives
  46968. * @param fillMode defines the primitive to use
  46969. * @param indexStart defines the starting index
  46970. * @param indexCount defines the number of index to draw
  46971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46972. */
  46973. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46974. /**
  46975. * Draw a list of unindexed primitives
  46976. * @param fillMode defines the primitive to use
  46977. * @param verticesStart defines the index of first vertex to draw
  46978. * @param verticesCount defines the count of vertices to draw
  46979. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46980. */
  46981. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46982. createPipelineContext(): IPipelineContext;
  46983. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46984. /** @hidden */
  46985. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46986. /** @hidden */
  46987. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46988. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46989. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46990. protected _setProgram(program: WebGLProgram): void;
  46991. _releaseEffect(effect: Effect): void;
  46992. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46993. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46994. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46995. bindSamplers(effect: Effect): void;
  46996. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46997. getRenderWidth(useScreen?: boolean): number;
  46998. getRenderHeight(useScreen?: boolean): number;
  46999. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47000. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47001. /**
  47002. * Set the z offset to apply to current rendering
  47003. * @param value defines the offset to apply
  47004. */
  47005. setZOffset(value: number): void;
  47006. /**
  47007. * Gets the current value of the zOffset
  47008. * @returns the current zOffset state
  47009. */
  47010. getZOffset(): number;
  47011. /**
  47012. * Enable or disable depth buffering
  47013. * @param enable defines the state to set
  47014. */
  47015. setDepthBuffer(enable: boolean): void;
  47016. /**
  47017. * Gets a boolean indicating if depth writing is enabled
  47018. * @returns the current depth writing state
  47019. */
  47020. getDepthWrite(): boolean;
  47021. /**
  47022. * Enable or disable depth writing
  47023. * @param enable defines the state to set
  47024. */
  47025. setDepthWrite(enable: boolean): void;
  47026. /**
  47027. * Enable or disable color writing
  47028. * @param enable defines the state to set
  47029. */
  47030. setColorWrite(enable: boolean): void;
  47031. /**
  47032. * Gets a boolean indicating if color writing is enabled
  47033. * @returns the current color writing state
  47034. */
  47035. getColorWrite(): boolean;
  47036. /**
  47037. * Sets alpha constants used by some alpha blending modes
  47038. * @param r defines the red component
  47039. * @param g defines the green component
  47040. * @param b defines the blue component
  47041. * @param a defines the alpha component
  47042. */
  47043. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47044. /**
  47045. * Sets the current alpha mode
  47046. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47047. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47048. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47049. */
  47050. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47051. /**
  47052. * Gets the current alpha mode
  47053. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47054. * @returns the current alpha mode
  47055. */
  47056. getAlphaMode(): number;
  47057. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47058. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47059. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47060. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47061. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47062. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47063. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47064. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47065. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47066. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47067. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47068. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47069. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47070. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47071. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47072. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47073. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47074. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47075. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47076. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47077. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47078. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47079. wipeCaches(bruteForce?: boolean): void;
  47080. _createTexture(): WebGLTexture;
  47081. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47082. /**
  47083. * Usually called from BABYLON.Texture.ts.
  47084. * Passed information to create a WebGLTexture
  47085. * @param urlArg defines a value which contains one of the following:
  47086. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47087. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47088. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47089. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47090. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47091. * @param scene needed for loading to the correct scene
  47092. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47093. * @param onLoad optional callback to be called upon successful completion
  47094. * @param onError optional callback to be called upon failure
  47095. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47096. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47097. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47098. * @param forcedExtension defines the extension to use to pick the right loader
  47099. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47100. */
  47101. 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;
  47102. /**
  47103. * Creates a cube texture
  47104. * @param rootUrl defines the url where the files to load is located
  47105. * @param scene defines the current scene
  47106. * @param files defines the list of files to load (1 per face)
  47107. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47108. * @param onLoad defines an optional callback raised when the texture is loaded
  47109. * @param onError defines an optional callback raised if there is an issue to load the texture
  47110. * @param format defines the format of the data
  47111. * @param forcedExtension defines the extension to use to pick the right loader
  47112. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47113. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47114. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47115. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47116. * @returns the cube texture as an InternalTexture
  47117. */
  47118. 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;
  47119. private _getSamplingFilter;
  47120. private static _GetNativeTextureFormat;
  47121. createRenderTargetTexture(size: number | {
  47122. width: number;
  47123. height: number;
  47124. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47125. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47126. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47127. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47128. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47129. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47130. /**
  47131. * Updates a dynamic vertex buffer.
  47132. * @param vertexBuffer the vertex buffer to update
  47133. * @param data the data used to update the vertex buffer
  47134. * @param byteOffset the byte offset of the data (optional)
  47135. * @param byteLength the byte length of the data (optional)
  47136. */
  47137. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47138. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47139. private _updateAnisotropicLevel;
  47140. private _getAddressMode;
  47141. /** @hidden */
  47142. _bindTexture(channel: number, texture: InternalTexture): void;
  47143. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47144. releaseEffects(): void;
  47145. /** @hidden */
  47146. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47147. /** @hidden */
  47148. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47149. /** @hidden */
  47150. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47151. /** @hidden */
  47152. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47153. }
  47154. }
  47155. declare module "babylonjs/Engines/index" {
  47156. export * from "babylonjs/Engines/constants";
  47157. export * from "babylonjs/Engines/engineCapabilities";
  47158. export * from "babylonjs/Engines/instancingAttributeInfo";
  47159. export * from "babylonjs/Engines/thinEngine";
  47160. export * from "babylonjs/Engines/engine";
  47161. export * from "babylonjs/Engines/engineStore";
  47162. export * from "babylonjs/Engines/nullEngine";
  47163. export * from "babylonjs/Engines/Extensions/index";
  47164. export * from "babylonjs/Engines/IPipelineContext";
  47165. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47166. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47167. export * from "babylonjs/Engines/nativeEngine";
  47168. }
  47169. declare module "babylonjs/Events/clipboardEvents" {
  47170. /**
  47171. * Gather the list of clipboard event types as constants.
  47172. */
  47173. export class ClipboardEventTypes {
  47174. /**
  47175. * The clipboard event is fired when a copy command is active (pressed).
  47176. */
  47177. static readonly COPY: number;
  47178. /**
  47179. * The clipboard event is fired when a cut command is active (pressed).
  47180. */
  47181. static readonly CUT: number;
  47182. /**
  47183. * The clipboard event is fired when a paste command is active (pressed).
  47184. */
  47185. static readonly PASTE: number;
  47186. }
  47187. /**
  47188. * This class is used to store clipboard related info for the onClipboardObservable event.
  47189. */
  47190. export class ClipboardInfo {
  47191. /**
  47192. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47193. */
  47194. type: number;
  47195. /**
  47196. * Defines the related dom event
  47197. */
  47198. event: ClipboardEvent;
  47199. /**
  47200. *Creates an instance of ClipboardInfo.
  47201. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47202. * @param event Defines the related dom event
  47203. */
  47204. constructor(
  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. * Get the clipboard event's type from the keycode.
  47215. * @param keyCode Defines the keyCode for the current keyboard event.
  47216. * @return {number}
  47217. */
  47218. static GetTypeFromCharacter(keyCode: number): number;
  47219. }
  47220. }
  47221. declare module "babylonjs/Events/index" {
  47222. export * from "babylonjs/Events/keyboardEvents";
  47223. export * from "babylonjs/Events/pointerEvents";
  47224. export * from "babylonjs/Events/clipboardEvents";
  47225. }
  47226. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47227. import { Scene } from "babylonjs/scene";
  47228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47229. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47230. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47231. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47232. /**
  47233. * Google Daydream controller
  47234. */
  47235. export class DaydreamController extends WebVRController {
  47236. /**
  47237. * Base Url for the controller model.
  47238. */
  47239. static MODEL_BASE_URL: string;
  47240. /**
  47241. * File name for the controller model.
  47242. */
  47243. static MODEL_FILENAME: string;
  47244. /**
  47245. * Gamepad Id prefix used to identify Daydream Controller.
  47246. */
  47247. static readonly GAMEPAD_ID_PREFIX: string;
  47248. /**
  47249. * Creates a new DaydreamController from a gamepad
  47250. * @param vrGamepad the gamepad that the controller should be created from
  47251. */
  47252. constructor(vrGamepad: any);
  47253. /**
  47254. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47255. * @param scene scene in which to add meshes
  47256. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47257. */
  47258. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47259. /**
  47260. * Called once for each button that changed state since the last frame
  47261. * @param buttonIdx Which button index changed
  47262. * @param state New state of the button
  47263. * @param changes Which properties on the state changed since last frame
  47264. */
  47265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47266. }
  47267. }
  47268. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47269. import { Scene } from "babylonjs/scene";
  47270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47271. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47272. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47273. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47274. /**
  47275. * Gear VR Controller
  47276. */
  47277. export class GearVRController extends WebVRController {
  47278. /**
  47279. * Base Url for the controller model.
  47280. */
  47281. static MODEL_BASE_URL: string;
  47282. /**
  47283. * File name for the controller model.
  47284. */
  47285. static MODEL_FILENAME: string;
  47286. /**
  47287. * Gamepad Id prefix used to identify this controller.
  47288. */
  47289. static readonly GAMEPAD_ID_PREFIX: string;
  47290. private readonly _buttonIndexToObservableNameMap;
  47291. /**
  47292. * Creates a new GearVRController from a gamepad
  47293. * @param vrGamepad the gamepad that the controller should be created from
  47294. */
  47295. constructor(vrGamepad: any);
  47296. /**
  47297. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47298. * @param scene scene in which to add meshes
  47299. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47300. */
  47301. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47302. /**
  47303. * Called once for each button that changed state since the last frame
  47304. * @param buttonIdx Which button index changed
  47305. * @param state New state of the button
  47306. * @param changes Which properties on the state changed since last frame
  47307. */
  47308. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47309. }
  47310. }
  47311. declare module "babylonjs/Gamepads/Controllers/index" {
  47312. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47313. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47314. export * from "babylonjs/Gamepads/Controllers/genericController";
  47315. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47316. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47317. export * from "babylonjs/Gamepads/Controllers/viveController";
  47318. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47319. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47320. }
  47321. declare module "babylonjs/Gamepads/index" {
  47322. export * from "babylonjs/Gamepads/Controllers/index";
  47323. export * from "babylonjs/Gamepads/gamepad";
  47324. export * from "babylonjs/Gamepads/gamepadManager";
  47325. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47326. export * from "babylonjs/Gamepads/xboxGamepad";
  47327. export * from "babylonjs/Gamepads/dualShockGamepad";
  47328. }
  47329. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47330. import { Scene } from "babylonjs/scene";
  47331. import { Vector4 } from "babylonjs/Maths/math.vector";
  47332. import { Color4 } from "babylonjs/Maths/math.color";
  47333. import { Mesh } from "babylonjs/Meshes/mesh";
  47334. import { Nullable } from "babylonjs/types";
  47335. /**
  47336. * Class containing static functions to help procedurally build meshes
  47337. */
  47338. export class PolyhedronBuilder {
  47339. /**
  47340. * Creates a polyhedron mesh
  47341. * * 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
  47342. * * The parameter `size` (positive float, default 1) sets the polygon size
  47343. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47344. * * 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`
  47345. * * 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
  47346. * * 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)`)
  47347. * * 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
  47348. * * 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
  47349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47352. * @param name defines the name of the mesh
  47353. * @param options defines the options used to create the mesh
  47354. * @param scene defines the hosting scene
  47355. * @returns the polyhedron mesh
  47356. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47357. */
  47358. static CreatePolyhedron(name: string, options: {
  47359. type?: number;
  47360. size?: number;
  47361. sizeX?: number;
  47362. sizeY?: number;
  47363. sizeZ?: number;
  47364. custom?: any;
  47365. faceUV?: Vector4[];
  47366. faceColors?: Color4[];
  47367. flat?: boolean;
  47368. updatable?: boolean;
  47369. sideOrientation?: number;
  47370. frontUVs?: Vector4;
  47371. backUVs?: Vector4;
  47372. }, scene?: Nullable<Scene>): Mesh;
  47373. }
  47374. }
  47375. declare module "babylonjs/Gizmos/scaleGizmo" {
  47376. import { Observable } from "babylonjs/Misc/observable";
  47377. import { Nullable } from "babylonjs/types";
  47378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47380. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47381. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47382. /**
  47383. * Gizmo that enables scaling a mesh along 3 axis
  47384. */
  47385. export class ScaleGizmo extends Gizmo {
  47386. /**
  47387. * Internal gizmo used for interactions on the x axis
  47388. */
  47389. xGizmo: AxisScaleGizmo;
  47390. /**
  47391. * Internal gizmo used for interactions on the y axis
  47392. */
  47393. yGizmo: AxisScaleGizmo;
  47394. /**
  47395. * Internal gizmo used for interactions on the z axis
  47396. */
  47397. zGizmo: AxisScaleGizmo;
  47398. /**
  47399. * Internal gizmo used to scale all axis equally
  47400. */
  47401. uniformScaleGizmo: AxisScaleGizmo;
  47402. private _meshAttached;
  47403. private _updateGizmoRotationToMatchAttachedMesh;
  47404. private _snapDistance;
  47405. private _scaleRatio;
  47406. private _uniformScalingMesh;
  47407. private _octahedron;
  47408. /** Fires an event when any of it's sub gizmos are dragged */
  47409. onDragStartObservable: Observable<unknown>;
  47410. /** Fires an event when any of it's sub gizmos are released from dragging */
  47411. onDragEndObservable: Observable<unknown>;
  47412. attachedMesh: Nullable<AbstractMesh>;
  47413. /**
  47414. * Creates a ScaleGizmo
  47415. * @param gizmoLayer The utility layer the gizmo will be added to
  47416. */
  47417. constructor(gizmoLayer?: UtilityLayerRenderer);
  47418. updateGizmoRotationToMatchAttachedMesh: boolean;
  47419. /**
  47420. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47421. */
  47422. snapDistance: number;
  47423. /**
  47424. * Ratio for the scale of the gizmo (Default: 1)
  47425. */
  47426. scaleRatio: number;
  47427. /**
  47428. * Disposes of the gizmo
  47429. */
  47430. dispose(): void;
  47431. }
  47432. }
  47433. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47434. import { Observable } from "babylonjs/Misc/observable";
  47435. import { Nullable } from "babylonjs/types";
  47436. import { Vector3 } from "babylonjs/Maths/math.vector";
  47437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47438. import { Mesh } from "babylonjs/Meshes/mesh";
  47439. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47440. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47442. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47443. import { Color3 } from "babylonjs/Maths/math.color";
  47444. /**
  47445. * Single axis scale gizmo
  47446. */
  47447. export class AxisScaleGizmo extends Gizmo {
  47448. /**
  47449. * Drag behavior responsible for the gizmos dragging interactions
  47450. */
  47451. dragBehavior: PointerDragBehavior;
  47452. private _pointerObserver;
  47453. /**
  47454. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47455. */
  47456. snapDistance: number;
  47457. /**
  47458. * Event that fires each time the gizmo snaps to a new location.
  47459. * * snapDistance is the the change in distance
  47460. */
  47461. onSnapObservable: Observable<{
  47462. snapDistance: number;
  47463. }>;
  47464. /**
  47465. * If the scaling operation should be done on all axis (default: false)
  47466. */
  47467. uniformScaling: boolean;
  47468. private _isEnabled;
  47469. private _parent;
  47470. private _arrow;
  47471. private _coloredMaterial;
  47472. private _hoverMaterial;
  47473. /**
  47474. * Creates an AxisScaleGizmo
  47475. * @param gizmoLayer The utility layer the gizmo will be added to
  47476. * @param dragAxis The axis which the gizmo will be able to scale on
  47477. * @param color The color of the gizmo
  47478. */
  47479. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47481. /**
  47482. * If the gizmo is enabled
  47483. */
  47484. isEnabled: boolean;
  47485. /**
  47486. * Disposes of the gizmo
  47487. */
  47488. dispose(): void;
  47489. /**
  47490. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47491. * @param mesh The mesh to replace the default mesh of the gizmo
  47492. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47493. */
  47494. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47495. }
  47496. }
  47497. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47498. import { Observable } from "babylonjs/Misc/observable";
  47499. import { Nullable } from "babylonjs/types";
  47500. import { Vector3 } from "babylonjs/Maths/math.vector";
  47501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47502. import { Mesh } from "babylonjs/Meshes/mesh";
  47503. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47504. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47505. import { Color3 } from "babylonjs/Maths/math.color";
  47506. import "babylonjs/Meshes/Builders/boxBuilder";
  47507. /**
  47508. * Bounding box gizmo
  47509. */
  47510. export class BoundingBoxGizmo extends Gizmo {
  47511. private _lineBoundingBox;
  47512. private _rotateSpheresParent;
  47513. private _scaleBoxesParent;
  47514. private _boundingDimensions;
  47515. private _renderObserver;
  47516. private _pointerObserver;
  47517. private _scaleDragSpeed;
  47518. private _tmpQuaternion;
  47519. private _tmpVector;
  47520. private _tmpRotationMatrix;
  47521. /**
  47522. * 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)
  47523. */
  47524. ignoreChildren: boolean;
  47525. /**
  47526. * 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)
  47527. */
  47528. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47529. /**
  47530. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47531. */
  47532. rotationSphereSize: number;
  47533. /**
  47534. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47535. */
  47536. scaleBoxSize: number;
  47537. /**
  47538. * 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)
  47539. */
  47540. fixedDragMeshScreenSize: boolean;
  47541. /**
  47542. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47543. */
  47544. fixedDragMeshScreenSizeDistanceFactor: number;
  47545. /**
  47546. * Fired when a rotation sphere or scale box is dragged
  47547. */
  47548. onDragStartObservable: Observable<{}>;
  47549. /**
  47550. * Fired when a scale box is dragged
  47551. */
  47552. onScaleBoxDragObservable: Observable<{}>;
  47553. /**
  47554. * Fired when a scale box drag is ended
  47555. */
  47556. onScaleBoxDragEndObservable: Observable<{}>;
  47557. /**
  47558. * Fired when a rotation sphere is dragged
  47559. */
  47560. onRotationSphereDragObservable: Observable<{}>;
  47561. /**
  47562. * Fired when a rotation sphere drag is ended
  47563. */
  47564. onRotationSphereDragEndObservable: Observable<{}>;
  47565. /**
  47566. * 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)
  47567. */
  47568. scalePivot: Nullable<Vector3>;
  47569. /**
  47570. * Mesh used as a pivot to rotate the attached mesh
  47571. */
  47572. private _anchorMesh;
  47573. private _existingMeshScale;
  47574. private _dragMesh;
  47575. private pointerDragBehavior;
  47576. private coloredMaterial;
  47577. private hoverColoredMaterial;
  47578. /**
  47579. * Sets the color of the bounding box gizmo
  47580. * @param color the color to set
  47581. */
  47582. setColor(color: Color3): void;
  47583. /**
  47584. * Creates an BoundingBoxGizmo
  47585. * @param gizmoLayer The utility layer the gizmo will be added to
  47586. * @param color The color of the gizmo
  47587. */
  47588. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47589. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47590. private _selectNode;
  47591. /**
  47592. * Updates the bounding box information for the Gizmo
  47593. */
  47594. updateBoundingBox(): void;
  47595. private _updateRotationSpheres;
  47596. private _updateScaleBoxes;
  47597. /**
  47598. * Enables rotation on the specified axis and disables rotation on the others
  47599. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47600. */
  47601. setEnabledRotationAxis(axis: string): void;
  47602. /**
  47603. * Enables/disables scaling
  47604. * @param enable if scaling should be enabled
  47605. */
  47606. setEnabledScaling(enable: boolean): void;
  47607. private _updateDummy;
  47608. /**
  47609. * Enables a pointer drag behavior on the bounding box of the gizmo
  47610. */
  47611. enableDragBehavior(): void;
  47612. /**
  47613. * Disposes of the gizmo
  47614. */
  47615. dispose(): void;
  47616. /**
  47617. * 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)
  47618. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47619. * @returns the bounding box mesh with the passed in mesh as a child
  47620. */
  47621. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47622. /**
  47623. * CustomMeshes are not supported by this gizmo
  47624. * @param mesh The mesh to replace the default mesh of the gizmo
  47625. */
  47626. setCustomMesh(mesh: Mesh): void;
  47627. }
  47628. }
  47629. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47630. import { Observable } from "babylonjs/Misc/observable";
  47631. import { Nullable } from "babylonjs/types";
  47632. import { Vector3 } from "babylonjs/Maths/math.vector";
  47633. import { Color3 } from "babylonjs/Maths/math.color";
  47634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47635. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47636. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47637. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47638. import "babylonjs/Meshes/Builders/linesBuilder";
  47639. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47640. /**
  47641. * Single plane rotation gizmo
  47642. */
  47643. export class PlaneRotationGizmo extends Gizmo {
  47644. /**
  47645. * Drag behavior responsible for the gizmos dragging interactions
  47646. */
  47647. dragBehavior: PointerDragBehavior;
  47648. private _pointerObserver;
  47649. /**
  47650. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47651. */
  47652. snapDistance: number;
  47653. /**
  47654. * Event that fires each time the gizmo snaps to a new location.
  47655. * * snapDistance is the the change in distance
  47656. */
  47657. onSnapObservable: Observable<{
  47658. snapDistance: number;
  47659. }>;
  47660. private _isEnabled;
  47661. private _parent;
  47662. /**
  47663. * Creates a PlaneRotationGizmo
  47664. * @param gizmoLayer The utility layer the gizmo will be added to
  47665. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47666. * @param color The color of the gizmo
  47667. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47668. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47669. */
  47670. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47672. /**
  47673. * If the gizmo is enabled
  47674. */
  47675. isEnabled: boolean;
  47676. /**
  47677. * Disposes of the gizmo
  47678. */
  47679. dispose(): void;
  47680. }
  47681. }
  47682. declare module "babylonjs/Gizmos/rotationGizmo" {
  47683. import { Observable } from "babylonjs/Misc/observable";
  47684. import { Nullable } from "babylonjs/types";
  47685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47686. import { Mesh } from "babylonjs/Meshes/mesh";
  47687. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47688. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47689. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47690. /**
  47691. * Gizmo that enables rotating a mesh along 3 axis
  47692. */
  47693. export class RotationGizmo extends Gizmo {
  47694. /**
  47695. * Internal gizmo used for interactions on the x axis
  47696. */
  47697. xGizmo: PlaneRotationGizmo;
  47698. /**
  47699. * Internal gizmo used for interactions on the y axis
  47700. */
  47701. yGizmo: PlaneRotationGizmo;
  47702. /**
  47703. * Internal gizmo used for interactions on the z axis
  47704. */
  47705. zGizmo: PlaneRotationGizmo;
  47706. /** Fires an event when any of it's sub gizmos are dragged */
  47707. onDragStartObservable: Observable<unknown>;
  47708. /** Fires an event when any of it's sub gizmos are released from dragging */
  47709. onDragEndObservable: Observable<unknown>;
  47710. private _meshAttached;
  47711. attachedMesh: Nullable<AbstractMesh>;
  47712. /**
  47713. * Creates a RotationGizmo
  47714. * @param gizmoLayer The utility layer the gizmo will be added to
  47715. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47716. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47717. */
  47718. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47719. updateGizmoRotationToMatchAttachedMesh: boolean;
  47720. /**
  47721. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47722. */
  47723. snapDistance: number;
  47724. /**
  47725. * Ratio for the scale of the gizmo (Default: 1)
  47726. */
  47727. scaleRatio: number;
  47728. /**
  47729. * Disposes of the gizmo
  47730. */
  47731. dispose(): void;
  47732. /**
  47733. * CustomMeshes are not supported by this gizmo
  47734. * @param mesh The mesh to replace the default mesh of the gizmo
  47735. */
  47736. setCustomMesh(mesh: Mesh): void;
  47737. }
  47738. }
  47739. declare module "babylonjs/Gizmos/gizmoManager" {
  47740. import { Observable } from "babylonjs/Misc/observable";
  47741. import { Nullable } from "babylonjs/types";
  47742. import { Scene, IDisposable } from "babylonjs/scene";
  47743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47745. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47746. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47747. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47748. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47749. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47750. /**
  47751. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47752. */
  47753. export class GizmoManager implements IDisposable {
  47754. private scene;
  47755. /**
  47756. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47757. */
  47758. gizmos: {
  47759. positionGizmo: Nullable<PositionGizmo>;
  47760. rotationGizmo: Nullable<RotationGizmo>;
  47761. scaleGizmo: Nullable<ScaleGizmo>;
  47762. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47763. };
  47764. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47765. clearGizmoOnEmptyPointerEvent: boolean;
  47766. /** Fires an event when the manager is attached to a mesh */
  47767. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47768. private _gizmosEnabled;
  47769. private _pointerObserver;
  47770. private _attachedMesh;
  47771. private _boundingBoxColor;
  47772. private _defaultUtilityLayer;
  47773. private _defaultKeepDepthUtilityLayer;
  47774. /**
  47775. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47776. */
  47777. boundingBoxDragBehavior: SixDofDragBehavior;
  47778. /**
  47779. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47780. */
  47781. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47782. /**
  47783. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47784. */
  47785. usePointerToAttachGizmos: boolean;
  47786. /**
  47787. * Utility layer that the bounding box gizmo belongs to
  47788. */
  47789. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47790. /**
  47791. * Utility layer that all gizmos besides bounding box belong to
  47792. */
  47793. readonly utilityLayer: UtilityLayerRenderer;
  47794. /**
  47795. * Instatiates a gizmo manager
  47796. * @param scene the scene to overlay the gizmos on top of
  47797. */
  47798. constructor(scene: Scene);
  47799. /**
  47800. * Attaches a set of gizmos to the specified mesh
  47801. * @param mesh The mesh the gizmo's should be attached to
  47802. */
  47803. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47804. /**
  47805. * If the position gizmo is enabled
  47806. */
  47807. positionGizmoEnabled: boolean;
  47808. /**
  47809. * If the rotation gizmo is enabled
  47810. */
  47811. rotationGizmoEnabled: boolean;
  47812. /**
  47813. * If the scale gizmo is enabled
  47814. */
  47815. scaleGizmoEnabled: boolean;
  47816. /**
  47817. * If the boundingBox gizmo is enabled
  47818. */
  47819. boundingBoxGizmoEnabled: boolean;
  47820. /**
  47821. * Disposes of the gizmo manager
  47822. */
  47823. dispose(): void;
  47824. }
  47825. }
  47826. declare module "babylonjs/Lights/directionalLight" {
  47827. import { Camera } from "babylonjs/Cameras/camera";
  47828. import { Scene } from "babylonjs/scene";
  47829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47831. import { Light } from "babylonjs/Lights/light";
  47832. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47833. import { Effect } from "babylonjs/Materials/effect";
  47834. /**
  47835. * A directional light is defined by a direction (what a surprise!).
  47836. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47837. * 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.
  47838. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47839. */
  47840. export class DirectionalLight extends ShadowLight {
  47841. private _shadowFrustumSize;
  47842. /**
  47843. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47844. */
  47845. /**
  47846. * Specifies a fix frustum size for the shadow generation.
  47847. */
  47848. shadowFrustumSize: number;
  47849. private _shadowOrthoScale;
  47850. /**
  47851. * Gets the shadow projection scale against the optimal computed one.
  47852. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47853. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47854. */
  47855. /**
  47856. * Sets the shadow projection scale against the optimal computed one.
  47857. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47858. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47859. */
  47860. shadowOrthoScale: number;
  47861. /**
  47862. * Automatically compute the projection matrix to best fit (including all the casters)
  47863. * on each frame.
  47864. */
  47865. autoUpdateExtends: boolean;
  47866. private _orthoLeft;
  47867. private _orthoRight;
  47868. private _orthoTop;
  47869. private _orthoBottom;
  47870. /**
  47871. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47872. * The directional light is emitted from everywhere in the given direction.
  47873. * It can cast shadows.
  47874. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47875. * @param name The friendly name of the light
  47876. * @param direction The direction of the light
  47877. * @param scene The scene the light belongs to
  47878. */
  47879. constructor(name: string, direction: Vector3, scene: Scene);
  47880. /**
  47881. * Returns the string "DirectionalLight".
  47882. * @return The class name
  47883. */
  47884. getClassName(): string;
  47885. /**
  47886. * Returns the integer 1.
  47887. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47888. */
  47889. getTypeID(): number;
  47890. /**
  47891. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47892. * Returns the DirectionalLight Shadow projection matrix.
  47893. */
  47894. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47895. /**
  47896. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47897. * Returns the DirectionalLight Shadow projection matrix.
  47898. */
  47899. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47900. /**
  47901. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47902. * Returns the DirectionalLight Shadow projection matrix.
  47903. */
  47904. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47905. protected _buildUniformLayout(): void;
  47906. /**
  47907. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47908. * @param effect The effect to update
  47909. * @param lightIndex The index of the light in the effect to update
  47910. * @returns The directional light
  47911. */
  47912. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47913. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47914. /**
  47915. * Gets the minZ used for shadow according to both the scene and the light.
  47916. *
  47917. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47918. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47919. * @param activeCamera The camera we are returning the min for
  47920. * @returns the depth min z
  47921. */
  47922. getDepthMinZ(activeCamera: Camera): number;
  47923. /**
  47924. * Gets the maxZ used for shadow according to both the scene and the light.
  47925. *
  47926. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47927. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47928. * @param activeCamera The camera we are returning the max for
  47929. * @returns the depth max z
  47930. */
  47931. getDepthMaxZ(activeCamera: Camera): number;
  47932. /**
  47933. * Prepares the list of defines specific to the light type.
  47934. * @param defines the list of defines
  47935. * @param lightIndex defines the index of the light for the effect
  47936. */
  47937. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47938. }
  47939. }
  47940. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47941. import { Mesh } from "babylonjs/Meshes/mesh";
  47942. /**
  47943. * Class containing static functions to help procedurally build meshes
  47944. */
  47945. export class HemisphereBuilder {
  47946. /**
  47947. * Creates a hemisphere mesh
  47948. * @param name defines the name of the mesh
  47949. * @param options defines the options used to create the mesh
  47950. * @param scene defines the hosting scene
  47951. * @returns the hemisphere mesh
  47952. */
  47953. static CreateHemisphere(name: string, options: {
  47954. segments?: number;
  47955. diameter?: number;
  47956. sideOrientation?: number;
  47957. }, scene: any): Mesh;
  47958. }
  47959. }
  47960. declare module "babylonjs/Lights/spotLight" {
  47961. import { Nullable } from "babylonjs/types";
  47962. import { Scene } from "babylonjs/scene";
  47963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47965. import { Effect } from "babylonjs/Materials/effect";
  47966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47967. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47968. /**
  47969. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47970. * These values define a cone of light starting from the position, emitting toward the direction.
  47971. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47972. * and the exponent defines the speed of the decay of the light with distance (reach).
  47973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47974. */
  47975. export class SpotLight extends ShadowLight {
  47976. private _angle;
  47977. private _innerAngle;
  47978. private _cosHalfAngle;
  47979. private _lightAngleScale;
  47980. private _lightAngleOffset;
  47981. /**
  47982. * Gets the cone angle of the spot light in Radians.
  47983. */
  47984. /**
  47985. * Sets the cone angle of the spot light in Radians.
  47986. */
  47987. angle: number;
  47988. /**
  47989. * Only used in gltf falloff mode, this defines the angle where
  47990. * the directional falloff will start before cutting at angle which could be seen
  47991. * as outer angle.
  47992. */
  47993. /**
  47994. * Only used in gltf falloff mode, this defines the angle where
  47995. * the directional falloff will start before cutting at angle which could be seen
  47996. * as outer angle.
  47997. */
  47998. innerAngle: number;
  47999. private _shadowAngleScale;
  48000. /**
  48001. * Allows scaling the angle of the light for shadow generation only.
  48002. */
  48003. /**
  48004. * Allows scaling the angle of the light for shadow generation only.
  48005. */
  48006. shadowAngleScale: number;
  48007. /**
  48008. * The light decay speed with the distance from the emission spot.
  48009. */
  48010. exponent: number;
  48011. private _projectionTextureMatrix;
  48012. /**
  48013. * Allows reading the projecton texture
  48014. */
  48015. readonly projectionTextureMatrix: Matrix;
  48016. protected _projectionTextureLightNear: number;
  48017. /**
  48018. * Gets the near clip of the Spotlight for texture projection.
  48019. */
  48020. /**
  48021. * Sets the near clip of the Spotlight for texture projection.
  48022. */
  48023. projectionTextureLightNear: number;
  48024. protected _projectionTextureLightFar: number;
  48025. /**
  48026. * Gets the far clip of the Spotlight for texture projection.
  48027. */
  48028. /**
  48029. * Sets the far clip of the Spotlight for texture projection.
  48030. */
  48031. projectionTextureLightFar: number;
  48032. protected _projectionTextureUpDirection: Vector3;
  48033. /**
  48034. * Gets the Up vector of the Spotlight for texture projection.
  48035. */
  48036. /**
  48037. * Sets the Up vector of the Spotlight for texture projection.
  48038. */
  48039. projectionTextureUpDirection: Vector3;
  48040. private _projectionTexture;
  48041. /**
  48042. * Gets the projection texture of the light.
  48043. */
  48044. /**
  48045. * Sets the projection texture of the light.
  48046. */
  48047. projectionTexture: Nullable<BaseTexture>;
  48048. private _projectionTextureViewLightDirty;
  48049. private _projectionTextureProjectionLightDirty;
  48050. private _projectionTextureDirty;
  48051. private _projectionTextureViewTargetVector;
  48052. private _projectionTextureViewLightMatrix;
  48053. private _projectionTextureProjectionLightMatrix;
  48054. private _projectionTextureScalingMatrix;
  48055. /**
  48056. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48057. * It can cast shadows.
  48058. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48059. * @param name The light friendly name
  48060. * @param position The position of the spot light in the scene
  48061. * @param direction The direction of the light in the scene
  48062. * @param angle The cone angle of the light in Radians
  48063. * @param exponent The light decay speed with the distance from the emission spot
  48064. * @param scene The scene the lights belongs to
  48065. */
  48066. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48067. /**
  48068. * Returns the string "SpotLight".
  48069. * @returns the class name
  48070. */
  48071. getClassName(): string;
  48072. /**
  48073. * Returns the integer 2.
  48074. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48075. */
  48076. getTypeID(): number;
  48077. /**
  48078. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48079. */
  48080. protected _setDirection(value: Vector3): void;
  48081. /**
  48082. * Overrides the position setter to recompute the projection texture view light Matrix.
  48083. */
  48084. protected _setPosition(value: Vector3): void;
  48085. /**
  48086. * 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.
  48087. * Returns the SpotLight.
  48088. */
  48089. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48090. protected _computeProjectionTextureViewLightMatrix(): void;
  48091. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48092. /**
  48093. * Main function for light texture projection matrix computing.
  48094. */
  48095. protected _computeProjectionTextureMatrix(): void;
  48096. protected _buildUniformLayout(): void;
  48097. private _computeAngleValues;
  48098. /**
  48099. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48100. * @param effect The effect to update
  48101. * @param lightIndex The index of the light in the effect to update
  48102. * @returns The spot light
  48103. */
  48104. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48105. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48106. /**
  48107. * Disposes the light and the associated resources.
  48108. */
  48109. dispose(): void;
  48110. /**
  48111. * Prepares the list of defines specific to the light type.
  48112. * @param defines the list of defines
  48113. * @param lightIndex defines the index of the light for the effect
  48114. */
  48115. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48116. }
  48117. }
  48118. declare module "babylonjs/Gizmos/lightGizmo" {
  48119. import { Nullable } from "babylonjs/types";
  48120. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48121. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48122. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48123. import { Light } from "babylonjs/Lights/light";
  48124. /**
  48125. * Gizmo that enables viewing a light
  48126. */
  48127. export class LightGizmo extends Gizmo {
  48128. private _lightMesh;
  48129. private _material;
  48130. private cachedPosition;
  48131. private cachedForward;
  48132. /**
  48133. * Creates a LightGizmo
  48134. * @param gizmoLayer The utility layer the gizmo will be added to
  48135. */
  48136. constructor(gizmoLayer?: UtilityLayerRenderer);
  48137. private _light;
  48138. /**
  48139. * The light that the gizmo is attached to
  48140. */
  48141. light: Nullable<Light>;
  48142. /**
  48143. * Gets the material used to render the light gizmo
  48144. */
  48145. readonly material: StandardMaterial;
  48146. /**
  48147. * @hidden
  48148. * Updates the gizmo to match the attached mesh's position/rotation
  48149. */
  48150. protected _update(): void;
  48151. private static _Scale;
  48152. /**
  48153. * Creates the lines for a light mesh
  48154. */
  48155. private static _createLightLines;
  48156. /**
  48157. * Disposes of the light gizmo
  48158. */
  48159. dispose(): void;
  48160. private static _CreateHemisphericLightMesh;
  48161. private static _CreatePointLightMesh;
  48162. private static _CreateSpotLightMesh;
  48163. private static _CreateDirectionalLightMesh;
  48164. }
  48165. }
  48166. declare module "babylonjs/Gizmos/index" {
  48167. export * from "babylonjs/Gizmos/axisDragGizmo";
  48168. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48169. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48170. export * from "babylonjs/Gizmos/gizmo";
  48171. export * from "babylonjs/Gizmos/gizmoManager";
  48172. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48173. export * from "babylonjs/Gizmos/positionGizmo";
  48174. export * from "babylonjs/Gizmos/rotationGizmo";
  48175. export * from "babylonjs/Gizmos/scaleGizmo";
  48176. export * from "babylonjs/Gizmos/lightGizmo";
  48177. export * from "babylonjs/Gizmos/planeDragGizmo";
  48178. }
  48179. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48180. /** @hidden */
  48181. export var backgroundFragmentDeclaration: {
  48182. name: string;
  48183. shader: string;
  48184. };
  48185. }
  48186. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48187. /** @hidden */
  48188. export var backgroundUboDeclaration: {
  48189. name: string;
  48190. shader: string;
  48191. };
  48192. }
  48193. declare module "babylonjs/Shaders/background.fragment" {
  48194. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48195. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48196. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48197. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48198. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48199. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48201. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48202. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48203. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48204. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48205. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48206. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48207. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48208. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48209. /** @hidden */
  48210. export var backgroundPixelShader: {
  48211. name: string;
  48212. shader: string;
  48213. };
  48214. }
  48215. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48216. /** @hidden */
  48217. export var backgroundVertexDeclaration: {
  48218. name: string;
  48219. shader: string;
  48220. };
  48221. }
  48222. declare module "babylonjs/Shaders/background.vertex" {
  48223. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48224. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48225. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48226. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48227. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48228. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48229. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48230. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48231. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48232. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48233. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48234. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48235. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48236. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48237. /** @hidden */
  48238. export var backgroundVertexShader: {
  48239. name: string;
  48240. shader: string;
  48241. };
  48242. }
  48243. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48244. import { Nullable, int, float } from "babylonjs/types";
  48245. import { Scene } from "babylonjs/scene";
  48246. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48249. import { Mesh } from "babylonjs/Meshes/mesh";
  48250. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48251. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48252. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48254. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48255. import { Color3 } from "babylonjs/Maths/math.color";
  48256. import "babylonjs/Shaders/background.fragment";
  48257. import "babylonjs/Shaders/background.vertex";
  48258. /**
  48259. * Background material used to create an efficient environement around your scene.
  48260. */
  48261. export class BackgroundMaterial extends PushMaterial {
  48262. /**
  48263. * Standard reflectance value at parallel view angle.
  48264. */
  48265. static StandardReflectance0: number;
  48266. /**
  48267. * Standard reflectance value at grazing angle.
  48268. */
  48269. static StandardReflectance90: number;
  48270. protected _primaryColor: Color3;
  48271. /**
  48272. * Key light Color (multiply against the environement texture)
  48273. */
  48274. primaryColor: Color3;
  48275. protected __perceptualColor: Nullable<Color3>;
  48276. /**
  48277. * Experimental Internal Use Only.
  48278. *
  48279. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48280. * This acts as a helper to set the primary color to a more "human friendly" value.
  48281. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48282. * output color as close as possible from the chosen value.
  48283. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48284. * part of lighting setup.)
  48285. */
  48286. _perceptualColor: Nullable<Color3>;
  48287. protected _primaryColorShadowLevel: float;
  48288. /**
  48289. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48290. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48291. */
  48292. primaryColorShadowLevel: float;
  48293. protected _primaryColorHighlightLevel: float;
  48294. /**
  48295. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48296. * The primary color is used at the level chosen to define what the white area would look.
  48297. */
  48298. primaryColorHighlightLevel: float;
  48299. protected _reflectionTexture: Nullable<BaseTexture>;
  48300. /**
  48301. * Reflection Texture used in the material.
  48302. * Should be author in a specific way for the best result (refer to the documentation).
  48303. */
  48304. reflectionTexture: Nullable<BaseTexture>;
  48305. protected _reflectionBlur: float;
  48306. /**
  48307. * Reflection Texture level of blur.
  48308. *
  48309. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48310. * texture twice.
  48311. */
  48312. reflectionBlur: float;
  48313. protected _diffuseTexture: Nullable<BaseTexture>;
  48314. /**
  48315. * Diffuse Texture used in the material.
  48316. * Should be author in a specific way for the best result (refer to the documentation).
  48317. */
  48318. diffuseTexture: Nullable<BaseTexture>;
  48319. protected _shadowLights: Nullable<IShadowLight[]>;
  48320. /**
  48321. * Specify the list of lights casting shadow on the material.
  48322. * All scene shadow lights will be included if null.
  48323. */
  48324. shadowLights: Nullable<IShadowLight[]>;
  48325. protected _shadowLevel: float;
  48326. /**
  48327. * Helps adjusting the shadow to a softer level if required.
  48328. * 0 means black shadows and 1 means no shadows.
  48329. */
  48330. shadowLevel: float;
  48331. protected _sceneCenter: Vector3;
  48332. /**
  48333. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48334. * It is usually zero but might be interesting to modify according to your setup.
  48335. */
  48336. sceneCenter: Vector3;
  48337. protected _opacityFresnel: boolean;
  48338. /**
  48339. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48340. * This helps ensuring a nice transition when the camera goes under the ground.
  48341. */
  48342. opacityFresnel: boolean;
  48343. protected _reflectionFresnel: boolean;
  48344. /**
  48345. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48346. * This helps adding a mirror texture on the ground.
  48347. */
  48348. reflectionFresnel: boolean;
  48349. protected _reflectionFalloffDistance: number;
  48350. /**
  48351. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48352. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48353. */
  48354. reflectionFalloffDistance: number;
  48355. protected _reflectionAmount: number;
  48356. /**
  48357. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48358. */
  48359. reflectionAmount: number;
  48360. protected _reflectionReflectance0: number;
  48361. /**
  48362. * This specifies the weight of the reflection at grazing angle.
  48363. */
  48364. reflectionReflectance0: number;
  48365. protected _reflectionReflectance90: number;
  48366. /**
  48367. * This specifies the weight of the reflection at a perpendicular point of view.
  48368. */
  48369. reflectionReflectance90: number;
  48370. /**
  48371. * Sets the reflection reflectance fresnel values according to the default standard
  48372. * empirically know to work well :-)
  48373. */
  48374. reflectionStandardFresnelWeight: number;
  48375. protected _useRGBColor: boolean;
  48376. /**
  48377. * Helps to directly use the maps channels instead of their level.
  48378. */
  48379. useRGBColor: boolean;
  48380. protected _enableNoise: boolean;
  48381. /**
  48382. * This helps reducing the banding effect that could occur on the background.
  48383. */
  48384. enableNoise: boolean;
  48385. /**
  48386. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48387. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48388. * Recommended to be keep at 1.0 except for special cases.
  48389. */
  48390. fovMultiplier: number;
  48391. private _fovMultiplier;
  48392. /**
  48393. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48394. */
  48395. useEquirectangularFOV: boolean;
  48396. private _maxSimultaneousLights;
  48397. /**
  48398. * Number of Simultaneous lights allowed on the material.
  48399. */
  48400. maxSimultaneousLights: int;
  48401. /**
  48402. * Default configuration related to image processing available in the Background Material.
  48403. */
  48404. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48405. /**
  48406. * Keep track of the image processing observer to allow dispose and replace.
  48407. */
  48408. private _imageProcessingObserver;
  48409. /**
  48410. * Attaches a new image processing configuration to the PBR Material.
  48411. * @param configuration (if null the scene configuration will be use)
  48412. */
  48413. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48414. /**
  48415. * Gets the image processing configuration used either in this material.
  48416. */
  48417. /**
  48418. * Sets the Default image processing configuration used either in the this material.
  48419. *
  48420. * If sets to null, the scene one is in use.
  48421. */
  48422. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48423. /**
  48424. * Gets wether the color curves effect is enabled.
  48425. */
  48426. /**
  48427. * Sets wether the color curves effect is enabled.
  48428. */
  48429. cameraColorCurvesEnabled: boolean;
  48430. /**
  48431. * Gets wether the color grading effect is enabled.
  48432. */
  48433. /**
  48434. * Gets wether the color grading effect is enabled.
  48435. */
  48436. cameraColorGradingEnabled: boolean;
  48437. /**
  48438. * Gets wether tonemapping is enabled or not.
  48439. */
  48440. /**
  48441. * Sets wether tonemapping is enabled or not
  48442. */
  48443. cameraToneMappingEnabled: boolean;
  48444. /**
  48445. * The camera exposure used on this material.
  48446. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48447. * This corresponds to a photographic exposure.
  48448. */
  48449. /**
  48450. * The camera exposure used on this material.
  48451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48452. * This corresponds to a photographic exposure.
  48453. */
  48454. cameraExposure: float;
  48455. /**
  48456. * Gets The camera contrast used on this material.
  48457. */
  48458. /**
  48459. * Sets The camera contrast used on this material.
  48460. */
  48461. cameraContrast: float;
  48462. /**
  48463. * Gets the Color Grading 2D Lookup Texture.
  48464. */
  48465. /**
  48466. * Sets the Color Grading 2D Lookup Texture.
  48467. */
  48468. cameraColorGradingTexture: Nullable<BaseTexture>;
  48469. /**
  48470. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48471. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48472. * 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;
  48473. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48474. */
  48475. /**
  48476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48478. * 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;
  48479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48480. */
  48481. cameraColorCurves: Nullable<ColorCurves>;
  48482. /**
  48483. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48484. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48485. */
  48486. switchToBGR: boolean;
  48487. private _renderTargets;
  48488. private _reflectionControls;
  48489. private _white;
  48490. private _primaryShadowColor;
  48491. private _primaryHighlightColor;
  48492. /**
  48493. * Instantiates a Background Material in the given scene
  48494. * @param name The friendly name of the material
  48495. * @param scene The scene to add the material to
  48496. */
  48497. constructor(name: string, scene: Scene);
  48498. /**
  48499. * Gets a boolean indicating that current material needs to register RTT
  48500. */
  48501. readonly hasRenderTargetTextures: boolean;
  48502. /**
  48503. * The entire material has been created in order to prevent overdraw.
  48504. * @returns false
  48505. */
  48506. needAlphaTesting(): boolean;
  48507. /**
  48508. * The entire material has been created in order to prevent overdraw.
  48509. * @returns true if blending is enable
  48510. */
  48511. needAlphaBlending(): boolean;
  48512. /**
  48513. * Checks wether the material is ready to be rendered for a given mesh.
  48514. * @param mesh The mesh to render
  48515. * @param subMesh The submesh to check against
  48516. * @param useInstances Specify wether or not the material is used with instances
  48517. * @returns true if all the dependencies are ready (Textures, Effects...)
  48518. */
  48519. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48520. /**
  48521. * Compute the primary color according to the chosen perceptual color.
  48522. */
  48523. private _computePrimaryColorFromPerceptualColor;
  48524. /**
  48525. * Compute the highlights and shadow colors according to their chosen levels.
  48526. */
  48527. private _computePrimaryColors;
  48528. /**
  48529. * Build the uniform buffer used in the material.
  48530. */
  48531. buildUniformLayout(): void;
  48532. /**
  48533. * Unbind the material.
  48534. */
  48535. unbind(): void;
  48536. /**
  48537. * Bind only the world matrix to the material.
  48538. * @param world The world matrix to bind.
  48539. */
  48540. bindOnlyWorldMatrix(world: Matrix): void;
  48541. /**
  48542. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48543. * @param world The world matrix to bind.
  48544. * @param subMesh The submesh to bind for.
  48545. */
  48546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48547. /**
  48548. * Checks to see if a texture is used in the material.
  48549. * @param texture - Base texture to use.
  48550. * @returns - Boolean specifying if a texture is used in the material.
  48551. */
  48552. hasTexture(texture: BaseTexture): boolean;
  48553. /**
  48554. * Dispose the material.
  48555. * @param forceDisposeEffect Force disposal of the associated effect.
  48556. * @param forceDisposeTextures Force disposal of the associated textures.
  48557. */
  48558. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48559. /**
  48560. * Clones the material.
  48561. * @param name The cloned name.
  48562. * @returns The cloned material.
  48563. */
  48564. clone(name: string): BackgroundMaterial;
  48565. /**
  48566. * Serializes the current material to its JSON representation.
  48567. * @returns The JSON representation.
  48568. */
  48569. serialize(): any;
  48570. /**
  48571. * Gets the class name of the material
  48572. * @returns "BackgroundMaterial"
  48573. */
  48574. getClassName(): string;
  48575. /**
  48576. * Parse a JSON input to create back a background material.
  48577. * @param source The JSON data to parse
  48578. * @param scene The scene to create the parsed material in
  48579. * @param rootUrl The root url of the assets the material depends upon
  48580. * @returns the instantiated BackgroundMaterial.
  48581. */
  48582. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48583. }
  48584. }
  48585. declare module "babylonjs/Helpers/environmentHelper" {
  48586. import { Observable } from "babylonjs/Misc/observable";
  48587. import { Nullable } from "babylonjs/types";
  48588. import { Scene } from "babylonjs/scene";
  48589. import { Vector3 } from "babylonjs/Maths/math.vector";
  48590. import { Color3 } from "babylonjs/Maths/math.color";
  48591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48592. import { Mesh } from "babylonjs/Meshes/mesh";
  48593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48594. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48595. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48596. import "babylonjs/Meshes/Builders/planeBuilder";
  48597. import "babylonjs/Meshes/Builders/boxBuilder";
  48598. /**
  48599. * Represents the different options available during the creation of
  48600. * a Environment helper.
  48601. *
  48602. * This can control the default ground, skybox and image processing setup of your scene.
  48603. */
  48604. export interface IEnvironmentHelperOptions {
  48605. /**
  48606. * Specifies wether or not to create a ground.
  48607. * True by default.
  48608. */
  48609. createGround: boolean;
  48610. /**
  48611. * Specifies the ground size.
  48612. * 15 by default.
  48613. */
  48614. groundSize: number;
  48615. /**
  48616. * The texture used on the ground for the main color.
  48617. * Comes from the BabylonJS CDN by default.
  48618. *
  48619. * Remarks: Can be either a texture or a url.
  48620. */
  48621. groundTexture: string | BaseTexture;
  48622. /**
  48623. * The color mixed in the ground texture by default.
  48624. * BabylonJS clearColor by default.
  48625. */
  48626. groundColor: Color3;
  48627. /**
  48628. * Specifies the ground opacity.
  48629. * 1 by default.
  48630. */
  48631. groundOpacity: number;
  48632. /**
  48633. * Enables the ground to receive shadows.
  48634. * True by default.
  48635. */
  48636. enableGroundShadow: boolean;
  48637. /**
  48638. * Helps preventing the shadow to be fully black on the ground.
  48639. * 0.5 by default.
  48640. */
  48641. groundShadowLevel: number;
  48642. /**
  48643. * Creates a mirror texture attach to the ground.
  48644. * false by default.
  48645. */
  48646. enableGroundMirror: boolean;
  48647. /**
  48648. * Specifies the ground mirror size ratio.
  48649. * 0.3 by default as the default kernel is 64.
  48650. */
  48651. groundMirrorSizeRatio: number;
  48652. /**
  48653. * Specifies the ground mirror blur kernel size.
  48654. * 64 by default.
  48655. */
  48656. groundMirrorBlurKernel: number;
  48657. /**
  48658. * Specifies the ground mirror visibility amount.
  48659. * 1 by default
  48660. */
  48661. groundMirrorAmount: number;
  48662. /**
  48663. * Specifies the ground mirror reflectance weight.
  48664. * This uses the standard weight of the background material to setup the fresnel effect
  48665. * of the mirror.
  48666. * 1 by default.
  48667. */
  48668. groundMirrorFresnelWeight: number;
  48669. /**
  48670. * Specifies the ground mirror Falloff distance.
  48671. * This can helps reducing the size of the reflection.
  48672. * 0 by Default.
  48673. */
  48674. groundMirrorFallOffDistance: number;
  48675. /**
  48676. * Specifies the ground mirror texture type.
  48677. * Unsigned Int by Default.
  48678. */
  48679. groundMirrorTextureType: number;
  48680. /**
  48681. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48682. * the shown objects.
  48683. */
  48684. groundYBias: number;
  48685. /**
  48686. * Specifies wether or not to create a skybox.
  48687. * True by default.
  48688. */
  48689. createSkybox: boolean;
  48690. /**
  48691. * Specifies the skybox size.
  48692. * 20 by default.
  48693. */
  48694. skyboxSize: number;
  48695. /**
  48696. * The texture used on the skybox for the main color.
  48697. * Comes from the BabylonJS CDN by default.
  48698. *
  48699. * Remarks: Can be either a texture or a url.
  48700. */
  48701. skyboxTexture: string | BaseTexture;
  48702. /**
  48703. * The color mixed in the skybox texture by default.
  48704. * BabylonJS clearColor by default.
  48705. */
  48706. skyboxColor: Color3;
  48707. /**
  48708. * The background rotation around the Y axis of the scene.
  48709. * This helps aligning the key lights of your scene with the background.
  48710. * 0 by default.
  48711. */
  48712. backgroundYRotation: number;
  48713. /**
  48714. * Compute automatically the size of the elements to best fit with the scene.
  48715. */
  48716. sizeAuto: boolean;
  48717. /**
  48718. * Default position of the rootMesh if autoSize is not true.
  48719. */
  48720. rootPosition: Vector3;
  48721. /**
  48722. * Sets up the image processing in the scene.
  48723. * true by default.
  48724. */
  48725. setupImageProcessing: boolean;
  48726. /**
  48727. * The texture used as your environment texture in the scene.
  48728. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48729. *
  48730. * Remarks: Can be either a texture or a url.
  48731. */
  48732. environmentTexture: string | BaseTexture;
  48733. /**
  48734. * The value of the exposure to apply to the scene.
  48735. * 0.6 by default if setupImageProcessing is true.
  48736. */
  48737. cameraExposure: number;
  48738. /**
  48739. * The value of the contrast to apply to the scene.
  48740. * 1.6 by default if setupImageProcessing is true.
  48741. */
  48742. cameraContrast: number;
  48743. /**
  48744. * Specifies wether or not tonemapping should be enabled in the scene.
  48745. * true by default if setupImageProcessing is true.
  48746. */
  48747. toneMappingEnabled: boolean;
  48748. }
  48749. /**
  48750. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48751. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48752. * It also helps with the default setup of your imageProcessing configuration.
  48753. */
  48754. export class EnvironmentHelper {
  48755. /**
  48756. * Default ground texture URL.
  48757. */
  48758. private static _groundTextureCDNUrl;
  48759. /**
  48760. * Default skybox texture URL.
  48761. */
  48762. private static _skyboxTextureCDNUrl;
  48763. /**
  48764. * Default environment texture URL.
  48765. */
  48766. private static _environmentTextureCDNUrl;
  48767. /**
  48768. * Creates the default options for the helper.
  48769. */
  48770. private static _getDefaultOptions;
  48771. private _rootMesh;
  48772. /**
  48773. * Gets the root mesh created by the helper.
  48774. */
  48775. readonly rootMesh: Mesh;
  48776. private _skybox;
  48777. /**
  48778. * Gets the skybox created by the helper.
  48779. */
  48780. readonly skybox: Nullable<Mesh>;
  48781. private _skyboxTexture;
  48782. /**
  48783. * Gets the skybox texture created by the helper.
  48784. */
  48785. readonly skyboxTexture: Nullable<BaseTexture>;
  48786. private _skyboxMaterial;
  48787. /**
  48788. * Gets the skybox material created by the helper.
  48789. */
  48790. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48791. private _ground;
  48792. /**
  48793. * Gets the ground mesh created by the helper.
  48794. */
  48795. readonly ground: Nullable<Mesh>;
  48796. private _groundTexture;
  48797. /**
  48798. * Gets the ground texture created by the helper.
  48799. */
  48800. readonly groundTexture: Nullable<BaseTexture>;
  48801. private _groundMirror;
  48802. /**
  48803. * Gets the ground mirror created by the helper.
  48804. */
  48805. readonly groundMirror: Nullable<MirrorTexture>;
  48806. /**
  48807. * Gets the ground mirror render list to helps pushing the meshes
  48808. * you wish in the ground reflection.
  48809. */
  48810. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48811. private _groundMaterial;
  48812. /**
  48813. * Gets the ground material created by the helper.
  48814. */
  48815. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48816. /**
  48817. * Stores the creation options.
  48818. */
  48819. private readonly _scene;
  48820. private _options;
  48821. /**
  48822. * This observable will be notified with any error during the creation of the environment,
  48823. * mainly texture creation errors.
  48824. */
  48825. onErrorObservable: Observable<{
  48826. message?: string;
  48827. exception?: any;
  48828. }>;
  48829. /**
  48830. * constructor
  48831. * @param options Defines the options we want to customize the helper
  48832. * @param scene The scene to add the material to
  48833. */
  48834. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48835. /**
  48836. * Updates the background according to the new options
  48837. * @param options
  48838. */
  48839. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48840. /**
  48841. * Sets the primary color of all the available elements.
  48842. * @param color the main color to affect to the ground and the background
  48843. */
  48844. setMainColor(color: Color3): void;
  48845. /**
  48846. * Setup the image processing according to the specified options.
  48847. */
  48848. private _setupImageProcessing;
  48849. /**
  48850. * Setup the environment texture according to the specified options.
  48851. */
  48852. private _setupEnvironmentTexture;
  48853. /**
  48854. * Setup the background according to the specified options.
  48855. */
  48856. private _setupBackground;
  48857. /**
  48858. * Get the scene sizes according to the setup.
  48859. */
  48860. private _getSceneSize;
  48861. /**
  48862. * Setup the ground according to the specified options.
  48863. */
  48864. private _setupGround;
  48865. /**
  48866. * Setup the ground material according to the specified options.
  48867. */
  48868. private _setupGroundMaterial;
  48869. /**
  48870. * Setup the ground diffuse texture according to the specified options.
  48871. */
  48872. private _setupGroundDiffuseTexture;
  48873. /**
  48874. * Setup the ground mirror texture according to the specified options.
  48875. */
  48876. private _setupGroundMirrorTexture;
  48877. /**
  48878. * Setup the ground to receive the mirror texture.
  48879. */
  48880. private _setupMirrorInGroundMaterial;
  48881. /**
  48882. * Setup the skybox according to the specified options.
  48883. */
  48884. private _setupSkybox;
  48885. /**
  48886. * Setup the skybox material according to the specified options.
  48887. */
  48888. private _setupSkyboxMaterial;
  48889. /**
  48890. * Setup the skybox reflection texture according to the specified options.
  48891. */
  48892. private _setupSkyboxReflectionTexture;
  48893. private _errorHandler;
  48894. /**
  48895. * Dispose all the elements created by the Helper.
  48896. */
  48897. dispose(): void;
  48898. }
  48899. }
  48900. declare module "babylonjs/Helpers/photoDome" {
  48901. import { Observable } from "babylonjs/Misc/observable";
  48902. import { Nullable } from "babylonjs/types";
  48903. import { Scene } from "babylonjs/scene";
  48904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48905. import { Mesh } from "babylonjs/Meshes/mesh";
  48906. import { Texture } from "babylonjs/Materials/Textures/texture";
  48907. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48908. import "babylonjs/Meshes/Builders/sphereBuilder";
  48909. /**
  48910. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48911. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48912. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48913. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48914. */
  48915. export class PhotoDome extends TransformNode {
  48916. /**
  48917. * Define the image as a Monoscopic panoramic 360 image.
  48918. */
  48919. static readonly MODE_MONOSCOPIC: number;
  48920. /**
  48921. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48922. */
  48923. static readonly MODE_TOPBOTTOM: number;
  48924. /**
  48925. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48926. */
  48927. static readonly MODE_SIDEBYSIDE: number;
  48928. private _useDirectMapping;
  48929. /**
  48930. * The texture being displayed on the sphere
  48931. */
  48932. protected _photoTexture: Texture;
  48933. /**
  48934. * Gets or sets the texture being displayed on the sphere
  48935. */
  48936. photoTexture: Texture;
  48937. /**
  48938. * Observable raised when an error occured while loading the 360 image
  48939. */
  48940. onLoadErrorObservable: Observable<string>;
  48941. /**
  48942. * The skybox material
  48943. */
  48944. protected _material: BackgroundMaterial;
  48945. /**
  48946. * The surface used for the skybox
  48947. */
  48948. protected _mesh: Mesh;
  48949. /**
  48950. * Gets the mesh used for the skybox.
  48951. */
  48952. readonly mesh: Mesh;
  48953. /**
  48954. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48955. * Also see the options.resolution property.
  48956. */
  48957. fovMultiplier: number;
  48958. private _imageMode;
  48959. /**
  48960. * Gets or set the current video mode for the video. It can be:
  48961. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48962. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48963. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48964. */
  48965. imageMode: number;
  48966. /**
  48967. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48968. * @param name Element's name, child elements will append suffixes for their own names.
  48969. * @param urlsOfPhoto defines the url of the photo to display
  48970. * @param options defines an object containing optional or exposed sub element properties
  48971. * @param onError defines a callback called when an error occured while loading the texture
  48972. */
  48973. constructor(name: string, urlOfPhoto: string, options: {
  48974. resolution?: number;
  48975. size?: number;
  48976. useDirectMapping?: boolean;
  48977. faceForward?: boolean;
  48978. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48979. private _onBeforeCameraRenderObserver;
  48980. private _changeImageMode;
  48981. /**
  48982. * Releases resources associated with this node.
  48983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48985. */
  48986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48987. }
  48988. }
  48989. declare module "babylonjs/Misc/rgbdTextureTools" {
  48990. import "babylonjs/Shaders/rgbdDecode.fragment";
  48991. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48992. import { Texture } from "babylonjs/Materials/Textures/texture";
  48993. /**
  48994. * Class used to host RGBD texture specific utilities
  48995. */
  48996. export class RGBDTextureTools {
  48997. /**
  48998. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48999. * @param texture the texture to expand.
  49000. */
  49001. static ExpandRGBDTexture(texture: Texture): void;
  49002. }
  49003. }
  49004. declare module "babylonjs/Misc/brdfTextureTools" {
  49005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49006. import { Scene } from "babylonjs/scene";
  49007. /**
  49008. * Class used to host texture specific utilities
  49009. */
  49010. export class BRDFTextureTools {
  49011. /**
  49012. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49013. * @param scene defines the hosting scene
  49014. * @returns the environment BRDF texture
  49015. */
  49016. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49017. private static _environmentBRDFBase64Texture;
  49018. }
  49019. }
  49020. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49021. import { Nullable } from "babylonjs/types";
  49022. import { Color3 } from "babylonjs/Maths/math.color";
  49023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49024. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49025. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49026. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49027. import { Engine } from "babylonjs/Engines/engine";
  49028. import { Scene } from "babylonjs/scene";
  49029. /**
  49030. * @hidden
  49031. */
  49032. export interface IMaterialClearCoatDefines {
  49033. CLEARCOAT: boolean;
  49034. CLEARCOAT_DEFAULTIOR: boolean;
  49035. CLEARCOAT_TEXTURE: boolean;
  49036. CLEARCOAT_TEXTUREDIRECTUV: number;
  49037. CLEARCOAT_BUMP: boolean;
  49038. CLEARCOAT_BUMPDIRECTUV: number;
  49039. CLEARCOAT_TINT: boolean;
  49040. CLEARCOAT_TINT_TEXTURE: boolean;
  49041. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49042. /** @hidden */
  49043. _areTexturesDirty: boolean;
  49044. }
  49045. /**
  49046. * Define the code related to the clear coat parameters of the pbr material.
  49047. */
  49048. export class PBRClearCoatConfiguration {
  49049. /**
  49050. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49051. * The default fits with a polyurethane material.
  49052. */
  49053. private static readonly _DefaultIndexOfRefraction;
  49054. private _isEnabled;
  49055. /**
  49056. * Defines if the clear coat is enabled in the material.
  49057. */
  49058. isEnabled: boolean;
  49059. /**
  49060. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49061. */
  49062. intensity: number;
  49063. /**
  49064. * Defines the clear coat layer roughness.
  49065. */
  49066. roughness: number;
  49067. private _indexOfRefraction;
  49068. /**
  49069. * Defines the index of refraction of the clear coat.
  49070. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49071. * The default fits with a polyurethane material.
  49072. * Changing the default value is more performance intensive.
  49073. */
  49074. indexOfRefraction: number;
  49075. private _texture;
  49076. /**
  49077. * Stores the clear coat values in a texture.
  49078. */
  49079. texture: Nullable<BaseTexture>;
  49080. private _bumpTexture;
  49081. /**
  49082. * Define the clear coat specific bump texture.
  49083. */
  49084. bumpTexture: Nullable<BaseTexture>;
  49085. private _isTintEnabled;
  49086. /**
  49087. * Defines if the clear coat tint is enabled in the material.
  49088. */
  49089. isTintEnabled: boolean;
  49090. /**
  49091. * Defines the clear coat tint of the material.
  49092. * This is only use if tint is enabled
  49093. */
  49094. tintColor: Color3;
  49095. /**
  49096. * Defines the distance at which the tint color should be found in the
  49097. * clear coat media.
  49098. * This is only use if tint is enabled
  49099. */
  49100. tintColorAtDistance: number;
  49101. /**
  49102. * Defines the clear coat layer thickness.
  49103. * This is only use if tint is enabled
  49104. */
  49105. tintThickness: number;
  49106. private _tintTexture;
  49107. /**
  49108. * Stores the clear tint values in a texture.
  49109. * rgb is tint
  49110. * a is a thickness factor
  49111. */
  49112. tintTexture: Nullable<BaseTexture>;
  49113. /** @hidden */
  49114. private _internalMarkAllSubMeshesAsTexturesDirty;
  49115. /** @hidden */
  49116. _markAllSubMeshesAsTexturesDirty(): void;
  49117. /**
  49118. * Instantiate a new istance of clear coat configuration.
  49119. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49120. */
  49121. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49122. /**
  49123. * Gets wehter the submesh is ready to be used or not.
  49124. * @param defines the list of "defines" to update.
  49125. * @param scene defines the scene the material belongs to.
  49126. * @param engine defines the engine the material belongs to.
  49127. * @param disableBumpMap defines wether the material disables bump or not.
  49128. * @returns - boolean indicating that the submesh is ready or not.
  49129. */
  49130. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49131. /**
  49132. * Checks to see if a texture is used in the material.
  49133. * @param defines the list of "defines" to update.
  49134. * @param scene defines the scene to the material belongs to.
  49135. */
  49136. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49137. /**
  49138. * Binds the material data.
  49139. * @param uniformBuffer defines the Uniform buffer to fill in.
  49140. * @param scene defines the scene the material belongs to.
  49141. * @param engine defines the engine the material belongs to.
  49142. * @param disableBumpMap defines wether the material disables bump or not.
  49143. * @param isFrozen defines wether the material is frozen or not.
  49144. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49145. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49146. */
  49147. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49148. /**
  49149. * Checks to see if a texture is used in the material.
  49150. * @param texture - Base texture to use.
  49151. * @returns - Boolean specifying if a texture is used in the material.
  49152. */
  49153. hasTexture(texture: BaseTexture): boolean;
  49154. /**
  49155. * Returns an array of the actively used textures.
  49156. * @param activeTextures Array of BaseTextures
  49157. */
  49158. getActiveTextures(activeTextures: BaseTexture[]): void;
  49159. /**
  49160. * Returns the animatable textures.
  49161. * @param animatables Array of animatable textures.
  49162. */
  49163. getAnimatables(animatables: IAnimatable[]): void;
  49164. /**
  49165. * Disposes the resources of the material.
  49166. * @param forceDisposeTextures - Forces the disposal of all textures.
  49167. */
  49168. dispose(forceDisposeTextures?: boolean): void;
  49169. /**
  49170. * Get the current class name of the texture useful for serialization or dynamic coding.
  49171. * @returns "PBRClearCoatConfiguration"
  49172. */
  49173. getClassName(): string;
  49174. /**
  49175. * Add fallbacks to the effect fallbacks list.
  49176. * @param defines defines the Base texture to use.
  49177. * @param fallbacks defines the current fallback list.
  49178. * @param currentRank defines the current fallback rank.
  49179. * @returns the new fallback rank.
  49180. */
  49181. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49182. /**
  49183. * Add the required uniforms to the current list.
  49184. * @param uniforms defines the current uniform list.
  49185. */
  49186. static AddUniforms(uniforms: string[]): void;
  49187. /**
  49188. * Add the required samplers to the current list.
  49189. * @param samplers defines the current sampler list.
  49190. */
  49191. static AddSamplers(samplers: string[]): void;
  49192. /**
  49193. * Add the required uniforms to the current buffer.
  49194. * @param uniformBuffer defines the current uniform buffer.
  49195. */
  49196. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49197. /**
  49198. * Makes a duplicate of the current configuration into another one.
  49199. * @param clearCoatConfiguration define the config where to copy the info
  49200. */
  49201. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49202. /**
  49203. * Serializes this clear coat configuration.
  49204. * @returns - An object with the serialized config.
  49205. */
  49206. serialize(): any;
  49207. /**
  49208. * Parses a anisotropy Configuration from a serialized object.
  49209. * @param source - Serialized object.
  49210. * @param scene Defines the scene we are parsing for
  49211. * @param rootUrl Defines the rootUrl to load from
  49212. */
  49213. parse(source: any, scene: Scene, rootUrl: string): void;
  49214. }
  49215. }
  49216. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49217. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49219. import { Vector2 } from "babylonjs/Maths/math.vector";
  49220. import { Scene } from "babylonjs/scene";
  49221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49222. import { Nullable } from "babylonjs/types";
  49223. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49224. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49225. /**
  49226. * @hidden
  49227. */
  49228. export interface IMaterialAnisotropicDefines {
  49229. ANISOTROPIC: boolean;
  49230. ANISOTROPIC_TEXTURE: boolean;
  49231. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49232. MAINUV1: boolean;
  49233. _areTexturesDirty: boolean;
  49234. _needUVs: boolean;
  49235. }
  49236. /**
  49237. * Define the code related to the anisotropic parameters of the pbr material.
  49238. */
  49239. export class PBRAnisotropicConfiguration {
  49240. private _isEnabled;
  49241. /**
  49242. * Defines if the anisotropy is enabled in the material.
  49243. */
  49244. isEnabled: boolean;
  49245. /**
  49246. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49247. */
  49248. intensity: number;
  49249. /**
  49250. * Defines if the effect is along the tangents, bitangents or in between.
  49251. * By default, the effect is "strectching" the highlights along the tangents.
  49252. */
  49253. direction: Vector2;
  49254. private _texture;
  49255. /**
  49256. * Stores the anisotropy values in a texture.
  49257. * rg is direction (like normal from -1 to 1)
  49258. * b is a intensity
  49259. */
  49260. texture: Nullable<BaseTexture>;
  49261. /** @hidden */
  49262. private _internalMarkAllSubMeshesAsTexturesDirty;
  49263. /** @hidden */
  49264. _markAllSubMeshesAsTexturesDirty(): void;
  49265. /**
  49266. * Instantiate a new istance of anisotropy configuration.
  49267. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49268. */
  49269. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49270. /**
  49271. * Specifies that the submesh is ready to be used.
  49272. * @param defines the list of "defines" to update.
  49273. * @param scene defines the scene the material belongs to.
  49274. * @returns - boolean indicating that the submesh is ready or not.
  49275. */
  49276. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49277. /**
  49278. * Checks to see if a texture is used in the material.
  49279. * @param defines the list of "defines" to update.
  49280. * @param mesh the mesh we are preparing the defines for.
  49281. * @param scene defines the scene the material belongs to.
  49282. */
  49283. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49284. /**
  49285. * Binds the material data.
  49286. * @param uniformBuffer defines the Uniform buffer to fill in.
  49287. * @param scene defines the scene the material belongs to.
  49288. * @param isFrozen defines wether the material is frozen or not.
  49289. */
  49290. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49291. /**
  49292. * Checks to see if a texture is used in the material.
  49293. * @param texture - Base texture to use.
  49294. * @returns - Boolean specifying if a texture is used in the material.
  49295. */
  49296. hasTexture(texture: BaseTexture): boolean;
  49297. /**
  49298. * Returns an array of the actively used textures.
  49299. * @param activeTextures Array of BaseTextures
  49300. */
  49301. getActiveTextures(activeTextures: BaseTexture[]): void;
  49302. /**
  49303. * Returns the animatable textures.
  49304. * @param animatables Array of animatable textures.
  49305. */
  49306. getAnimatables(animatables: IAnimatable[]): void;
  49307. /**
  49308. * Disposes the resources of the material.
  49309. * @param forceDisposeTextures - Forces the disposal of all textures.
  49310. */
  49311. dispose(forceDisposeTextures?: boolean): void;
  49312. /**
  49313. * Get the current class name of the texture useful for serialization or dynamic coding.
  49314. * @returns "PBRAnisotropicConfiguration"
  49315. */
  49316. getClassName(): string;
  49317. /**
  49318. * Add fallbacks to the effect fallbacks list.
  49319. * @param defines defines the Base texture to use.
  49320. * @param fallbacks defines the current fallback list.
  49321. * @param currentRank defines the current fallback rank.
  49322. * @returns the new fallback rank.
  49323. */
  49324. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49325. /**
  49326. * Add the required uniforms to the current list.
  49327. * @param uniforms defines the current uniform list.
  49328. */
  49329. static AddUniforms(uniforms: string[]): void;
  49330. /**
  49331. * Add the required uniforms to the current buffer.
  49332. * @param uniformBuffer defines the current uniform buffer.
  49333. */
  49334. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49335. /**
  49336. * Add the required samplers to the current list.
  49337. * @param samplers defines the current sampler list.
  49338. */
  49339. static AddSamplers(samplers: string[]): void;
  49340. /**
  49341. * Makes a duplicate of the current configuration into another one.
  49342. * @param anisotropicConfiguration define the config where to copy the info
  49343. */
  49344. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49345. /**
  49346. * Serializes this anisotropy configuration.
  49347. * @returns - An object with the serialized config.
  49348. */
  49349. serialize(): any;
  49350. /**
  49351. * Parses a anisotropy Configuration from a serialized object.
  49352. * @param source - Serialized object.
  49353. * @param scene Defines the scene we are parsing for
  49354. * @param rootUrl Defines the rootUrl to load from
  49355. */
  49356. parse(source: any, scene: Scene, rootUrl: string): void;
  49357. }
  49358. }
  49359. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49360. import { Scene } from "babylonjs/scene";
  49361. /**
  49362. * @hidden
  49363. */
  49364. export interface IMaterialBRDFDefines {
  49365. BRDF_V_HEIGHT_CORRELATED: boolean;
  49366. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49367. SPHERICAL_HARMONICS: boolean;
  49368. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49369. /** @hidden */
  49370. _areMiscDirty: boolean;
  49371. }
  49372. /**
  49373. * Define the code related to the BRDF parameters of the pbr material.
  49374. */
  49375. export class PBRBRDFConfiguration {
  49376. /**
  49377. * Default value used for the energy conservation.
  49378. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49379. */
  49380. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49381. /**
  49382. * Default value used for the Smith Visibility Height Correlated mode.
  49383. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49384. */
  49385. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49386. /**
  49387. * Default value used for the IBL diffuse part.
  49388. * This can help switching back to the polynomials mode globally which is a tiny bit
  49389. * less GPU intensive at the drawback of a lower quality.
  49390. */
  49391. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49392. /**
  49393. * Default value used for activating energy conservation for the specular workflow.
  49394. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49395. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49396. */
  49397. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49398. private _useEnergyConservation;
  49399. /**
  49400. * Defines if the material uses energy conservation.
  49401. */
  49402. useEnergyConservation: boolean;
  49403. private _useSmithVisibilityHeightCorrelated;
  49404. /**
  49405. * LEGACY Mode set to false
  49406. * Defines if the material uses height smith correlated visibility term.
  49407. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49408. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49409. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49410. * Not relying on height correlated will also disable energy conservation.
  49411. */
  49412. useSmithVisibilityHeightCorrelated: boolean;
  49413. private _useSphericalHarmonics;
  49414. /**
  49415. * LEGACY Mode set to false
  49416. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49417. * diffuse part of the IBL.
  49418. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49419. * to the ground truth.
  49420. */
  49421. useSphericalHarmonics: boolean;
  49422. private _useSpecularGlossinessInputEnergyConservation;
  49423. /**
  49424. * Defines if the material uses energy conservation, when the specular workflow is active.
  49425. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49426. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49427. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49428. */
  49429. useSpecularGlossinessInputEnergyConservation: boolean;
  49430. /** @hidden */
  49431. private _internalMarkAllSubMeshesAsMiscDirty;
  49432. /** @hidden */
  49433. _markAllSubMeshesAsMiscDirty(): void;
  49434. /**
  49435. * Instantiate a new istance of clear coat configuration.
  49436. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49437. */
  49438. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49439. /**
  49440. * Checks to see if a texture is used in the material.
  49441. * @param defines the list of "defines" to update.
  49442. */
  49443. prepareDefines(defines: IMaterialBRDFDefines): void;
  49444. /**
  49445. * Get the current class name of the texture useful for serialization or dynamic coding.
  49446. * @returns "PBRClearCoatConfiguration"
  49447. */
  49448. getClassName(): string;
  49449. /**
  49450. * Makes a duplicate of the current configuration into another one.
  49451. * @param brdfConfiguration define the config where to copy the info
  49452. */
  49453. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49454. /**
  49455. * Serializes this BRDF configuration.
  49456. * @returns - An object with the serialized config.
  49457. */
  49458. serialize(): any;
  49459. /**
  49460. * Parses a anisotropy Configuration from a serialized object.
  49461. * @param source - Serialized object.
  49462. * @param scene Defines the scene we are parsing for
  49463. * @param rootUrl Defines the rootUrl to load from
  49464. */
  49465. parse(source: any, scene: Scene, rootUrl: string): void;
  49466. }
  49467. }
  49468. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49469. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49470. import { Color3 } from "babylonjs/Maths/math.color";
  49471. import { Scene } from "babylonjs/scene";
  49472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49473. import { Nullable } from "babylonjs/types";
  49474. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49475. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49476. /**
  49477. * @hidden
  49478. */
  49479. export interface IMaterialSheenDefines {
  49480. SHEEN: boolean;
  49481. SHEEN_TEXTURE: boolean;
  49482. SHEEN_TEXTUREDIRECTUV: number;
  49483. SHEEN_LINKWITHALBEDO: boolean;
  49484. /** @hidden */
  49485. _areTexturesDirty: boolean;
  49486. }
  49487. /**
  49488. * Define the code related to the Sheen parameters of the pbr material.
  49489. */
  49490. export class PBRSheenConfiguration {
  49491. private _isEnabled;
  49492. /**
  49493. * Defines if the material uses sheen.
  49494. */
  49495. isEnabled: boolean;
  49496. private _linkSheenWithAlbedo;
  49497. /**
  49498. * Defines if the sheen is linked to the sheen color.
  49499. */
  49500. linkSheenWithAlbedo: boolean;
  49501. /**
  49502. * Defines the sheen intensity.
  49503. */
  49504. intensity: number;
  49505. /**
  49506. * Defines the sheen color.
  49507. */
  49508. color: Color3;
  49509. private _texture;
  49510. /**
  49511. * Stores the sheen tint values in a texture.
  49512. * rgb is tint
  49513. * a is a intensity
  49514. */
  49515. texture: Nullable<BaseTexture>;
  49516. /** @hidden */
  49517. private _internalMarkAllSubMeshesAsTexturesDirty;
  49518. /** @hidden */
  49519. _markAllSubMeshesAsTexturesDirty(): void;
  49520. /**
  49521. * Instantiate a new istance of clear coat configuration.
  49522. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49523. */
  49524. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49525. /**
  49526. * Specifies that the submesh is ready to be used.
  49527. * @param defines the list of "defines" to update.
  49528. * @param scene defines the scene the material belongs to.
  49529. * @returns - boolean indicating that the submesh is ready or not.
  49530. */
  49531. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49532. /**
  49533. * Checks to see if a texture is used in the material.
  49534. * @param defines the list of "defines" to update.
  49535. * @param scene defines the scene the material belongs to.
  49536. */
  49537. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49538. /**
  49539. * Binds the material data.
  49540. * @param uniformBuffer defines the Uniform buffer to fill in.
  49541. * @param scene defines the scene the material belongs to.
  49542. * @param isFrozen defines wether the material is frozen or not.
  49543. */
  49544. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49545. /**
  49546. * Checks to see if a texture is used in the material.
  49547. * @param texture - Base texture to use.
  49548. * @returns - Boolean specifying if a texture is used in the material.
  49549. */
  49550. hasTexture(texture: BaseTexture): boolean;
  49551. /**
  49552. * Returns an array of the actively used textures.
  49553. * @param activeTextures Array of BaseTextures
  49554. */
  49555. getActiveTextures(activeTextures: BaseTexture[]): void;
  49556. /**
  49557. * Returns the animatable textures.
  49558. * @param animatables Array of animatable textures.
  49559. */
  49560. getAnimatables(animatables: IAnimatable[]): void;
  49561. /**
  49562. * Disposes the resources of the material.
  49563. * @param forceDisposeTextures - Forces the disposal of all textures.
  49564. */
  49565. dispose(forceDisposeTextures?: boolean): void;
  49566. /**
  49567. * Get the current class name of the texture useful for serialization or dynamic coding.
  49568. * @returns "PBRSheenConfiguration"
  49569. */
  49570. getClassName(): string;
  49571. /**
  49572. * Add fallbacks to the effect fallbacks list.
  49573. * @param defines defines the Base texture to use.
  49574. * @param fallbacks defines the current fallback list.
  49575. * @param currentRank defines the current fallback rank.
  49576. * @returns the new fallback rank.
  49577. */
  49578. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49579. /**
  49580. * Add the required uniforms to the current list.
  49581. * @param uniforms defines the current uniform list.
  49582. */
  49583. static AddUniforms(uniforms: string[]): void;
  49584. /**
  49585. * Add the required uniforms to the current buffer.
  49586. * @param uniformBuffer defines the current uniform buffer.
  49587. */
  49588. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49589. /**
  49590. * Add the required samplers to the current list.
  49591. * @param samplers defines the current sampler list.
  49592. */
  49593. static AddSamplers(samplers: string[]): void;
  49594. /**
  49595. * Makes a duplicate of the current configuration into another one.
  49596. * @param sheenConfiguration define the config where to copy the info
  49597. */
  49598. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49599. /**
  49600. * Serializes this BRDF configuration.
  49601. * @returns - An object with the serialized config.
  49602. */
  49603. serialize(): any;
  49604. /**
  49605. * Parses a anisotropy Configuration from a serialized object.
  49606. * @param source - Serialized object.
  49607. * @param scene Defines the scene we are parsing for
  49608. * @param rootUrl Defines the rootUrl to load from
  49609. */
  49610. parse(source: any, scene: Scene, rootUrl: string): void;
  49611. }
  49612. }
  49613. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49614. import { Nullable } from "babylonjs/types";
  49615. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49616. import { Color3 } from "babylonjs/Maths/math.color";
  49617. import { SmartArray } from "babylonjs/Misc/smartArray";
  49618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49619. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49620. import { Effect } from "babylonjs/Materials/effect";
  49621. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49622. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49623. import { Engine } from "babylonjs/Engines/engine";
  49624. import { Scene } from "babylonjs/scene";
  49625. /**
  49626. * @hidden
  49627. */
  49628. export interface IMaterialSubSurfaceDefines {
  49629. SUBSURFACE: boolean;
  49630. SS_REFRACTION: boolean;
  49631. SS_TRANSLUCENCY: boolean;
  49632. SS_SCATERRING: boolean;
  49633. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49634. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49635. SS_REFRACTIONMAP_3D: boolean;
  49636. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49637. SS_LODINREFRACTIONALPHA: boolean;
  49638. SS_GAMMAREFRACTION: boolean;
  49639. SS_RGBDREFRACTION: boolean;
  49640. SS_LINEARSPECULARREFRACTION: boolean;
  49641. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49642. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49643. /** @hidden */
  49644. _areTexturesDirty: boolean;
  49645. }
  49646. /**
  49647. * Define the code related to the sub surface parameters of the pbr material.
  49648. */
  49649. export class PBRSubSurfaceConfiguration {
  49650. private _isRefractionEnabled;
  49651. /**
  49652. * Defines if the refraction is enabled in the material.
  49653. */
  49654. isRefractionEnabled: boolean;
  49655. private _isTranslucencyEnabled;
  49656. /**
  49657. * Defines if the translucency is enabled in the material.
  49658. */
  49659. isTranslucencyEnabled: boolean;
  49660. private _isScatteringEnabled;
  49661. /**
  49662. * Defines the refraction intensity of the material.
  49663. * The refraction when enabled replaces the Diffuse part of the material.
  49664. * The intensity helps transitionning between diffuse and refraction.
  49665. */
  49666. refractionIntensity: number;
  49667. /**
  49668. * Defines the translucency intensity of the material.
  49669. * When translucency has been enabled, this defines how much of the "translucency"
  49670. * is addded to the diffuse part of the material.
  49671. */
  49672. translucencyIntensity: number;
  49673. /**
  49674. * Defines the scattering intensity of the material.
  49675. * When scattering has been enabled, this defines how much of the "scattered light"
  49676. * is addded to the diffuse part of the material.
  49677. */
  49678. scatteringIntensity: number;
  49679. private _thicknessTexture;
  49680. /**
  49681. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49682. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49683. * 0 would mean minimumThickness
  49684. * 1 would mean maximumThickness
  49685. * The other channels might be use as a mask to vary the different effects intensity.
  49686. */
  49687. thicknessTexture: Nullable<BaseTexture>;
  49688. private _refractionTexture;
  49689. /**
  49690. * Defines the texture to use for refraction.
  49691. */
  49692. refractionTexture: Nullable<BaseTexture>;
  49693. private _indexOfRefraction;
  49694. /**
  49695. * Defines the index of refraction used in the material.
  49696. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49697. */
  49698. indexOfRefraction: number;
  49699. private _invertRefractionY;
  49700. /**
  49701. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49702. */
  49703. invertRefractionY: boolean;
  49704. private _linkRefractionWithTransparency;
  49705. /**
  49706. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49707. * Materials half opaque for instance using refraction could benefit from this control.
  49708. */
  49709. linkRefractionWithTransparency: boolean;
  49710. /**
  49711. * Defines the minimum thickness stored in the thickness map.
  49712. * If no thickness map is defined, this value will be used to simulate thickness.
  49713. */
  49714. minimumThickness: number;
  49715. /**
  49716. * Defines the maximum thickness stored in the thickness map.
  49717. */
  49718. maximumThickness: number;
  49719. /**
  49720. * Defines the volume tint of the material.
  49721. * This is used for both translucency and scattering.
  49722. */
  49723. tintColor: Color3;
  49724. /**
  49725. * Defines the distance at which the tint color should be found in the media.
  49726. * This is used for refraction only.
  49727. */
  49728. tintColorAtDistance: number;
  49729. /**
  49730. * Defines how far each channel transmit through the media.
  49731. * It is defined as a color to simplify it selection.
  49732. */
  49733. diffusionDistance: Color3;
  49734. private _useMaskFromThicknessTexture;
  49735. /**
  49736. * Stores the intensity of the different subsurface effects in the thickness texture.
  49737. * * the green channel is the translucency intensity.
  49738. * * the blue channel is the scattering intensity.
  49739. * * the alpha channel is the refraction intensity.
  49740. */
  49741. useMaskFromThicknessTexture: boolean;
  49742. /** @hidden */
  49743. private _internalMarkAllSubMeshesAsTexturesDirty;
  49744. /** @hidden */
  49745. _markAllSubMeshesAsTexturesDirty(): void;
  49746. /**
  49747. * Instantiate a new istance of sub surface configuration.
  49748. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49749. */
  49750. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49751. /**
  49752. * Gets wehter the submesh is ready to be used or not.
  49753. * @param defines the list of "defines" to update.
  49754. * @param scene defines the scene the material belongs to.
  49755. * @returns - boolean indicating that the submesh is ready or not.
  49756. */
  49757. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49758. /**
  49759. * Checks to see if a texture is used in the material.
  49760. * @param defines the list of "defines" to update.
  49761. * @param scene defines the scene to the material belongs to.
  49762. */
  49763. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49764. /**
  49765. * Binds the material data.
  49766. * @param uniformBuffer defines the Uniform buffer to fill in.
  49767. * @param scene defines the scene the material belongs to.
  49768. * @param engine defines the engine the material belongs to.
  49769. * @param isFrozen defines wether the material is frozen or not.
  49770. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49771. */
  49772. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49773. /**
  49774. * Unbinds the material from the mesh.
  49775. * @param activeEffect defines the effect that should be unbound from.
  49776. * @returns true if unbound, otherwise false
  49777. */
  49778. unbind(activeEffect: Effect): boolean;
  49779. /**
  49780. * Returns the texture used for refraction or null if none is used.
  49781. * @param scene defines the scene the material belongs to.
  49782. * @returns - Refraction texture if present. If no refraction texture and refraction
  49783. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49784. */
  49785. private _getRefractionTexture;
  49786. /**
  49787. * Returns true if alpha blending should be disabled.
  49788. */
  49789. readonly disableAlphaBlending: boolean;
  49790. /**
  49791. * Fills the list of render target textures.
  49792. * @param renderTargets the list of render targets to update
  49793. */
  49794. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49795. /**
  49796. * Checks to see if a texture is used in the material.
  49797. * @param texture - Base texture to use.
  49798. * @returns - Boolean specifying if a texture is used in the material.
  49799. */
  49800. hasTexture(texture: BaseTexture): boolean;
  49801. /**
  49802. * Gets a boolean indicating that current material needs to register RTT
  49803. * @returns true if this uses a render target otherwise false.
  49804. */
  49805. hasRenderTargetTextures(): boolean;
  49806. /**
  49807. * Returns an array of the actively used textures.
  49808. * @param activeTextures Array of BaseTextures
  49809. */
  49810. getActiveTextures(activeTextures: BaseTexture[]): void;
  49811. /**
  49812. * Returns the animatable textures.
  49813. * @param animatables Array of animatable textures.
  49814. */
  49815. getAnimatables(animatables: IAnimatable[]): void;
  49816. /**
  49817. * Disposes the resources of the material.
  49818. * @param forceDisposeTextures - Forces the disposal of all textures.
  49819. */
  49820. dispose(forceDisposeTextures?: boolean): void;
  49821. /**
  49822. * Get the current class name of the texture useful for serialization or dynamic coding.
  49823. * @returns "PBRSubSurfaceConfiguration"
  49824. */
  49825. getClassName(): string;
  49826. /**
  49827. * Add fallbacks to the effect fallbacks list.
  49828. * @param defines defines the Base texture to use.
  49829. * @param fallbacks defines the current fallback list.
  49830. * @param currentRank defines the current fallback rank.
  49831. * @returns the new fallback rank.
  49832. */
  49833. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49834. /**
  49835. * Add the required uniforms to the current list.
  49836. * @param uniforms defines the current uniform list.
  49837. */
  49838. static AddUniforms(uniforms: string[]): void;
  49839. /**
  49840. * Add the required samplers to the current list.
  49841. * @param samplers defines the current sampler list.
  49842. */
  49843. static AddSamplers(samplers: string[]): void;
  49844. /**
  49845. * Add the required uniforms to the current buffer.
  49846. * @param uniformBuffer defines the current uniform buffer.
  49847. */
  49848. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49849. /**
  49850. * Makes a duplicate of the current configuration into another one.
  49851. * @param configuration define the config where to copy the info
  49852. */
  49853. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49854. /**
  49855. * Serializes this Sub Surface configuration.
  49856. * @returns - An object with the serialized config.
  49857. */
  49858. serialize(): any;
  49859. /**
  49860. * Parses a anisotropy Configuration from a serialized object.
  49861. * @param source - Serialized object.
  49862. * @param scene Defines the scene we are parsing for
  49863. * @param rootUrl Defines the rootUrl to load from
  49864. */
  49865. parse(source: any, scene: Scene, rootUrl: string): void;
  49866. }
  49867. }
  49868. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49869. /** @hidden */
  49870. export var pbrFragmentDeclaration: {
  49871. name: string;
  49872. shader: string;
  49873. };
  49874. }
  49875. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49876. /** @hidden */
  49877. export var pbrUboDeclaration: {
  49878. name: string;
  49879. shader: string;
  49880. };
  49881. }
  49882. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49883. /** @hidden */
  49884. export var pbrFragmentExtraDeclaration: {
  49885. name: string;
  49886. shader: string;
  49887. };
  49888. }
  49889. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49890. /** @hidden */
  49891. export var pbrFragmentSamplersDeclaration: {
  49892. name: string;
  49893. shader: string;
  49894. };
  49895. }
  49896. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49897. /** @hidden */
  49898. export var pbrHelperFunctions: {
  49899. name: string;
  49900. shader: string;
  49901. };
  49902. }
  49903. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49904. /** @hidden */
  49905. export var harmonicsFunctions: {
  49906. name: string;
  49907. shader: string;
  49908. };
  49909. }
  49910. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49911. /** @hidden */
  49912. export var pbrDirectLightingSetupFunctions: {
  49913. name: string;
  49914. shader: string;
  49915. };
  49916. }
  49917. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49918. /** @hidden */
  49919. export var pbrDirectLightingFalloffFunctions: {
  49920. name: string;
  49921. shader: string;
  49922. };
  49923. }
  49924. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49925. /** @hidden */
  49926. export var pbrBRDFFunctions: {
  49927. name: string;
  49928. shader: string;
  49929. };
  49930. }
  49931. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49932. /** @hidden */
  49933. export var pbrDirectLightingFunctions: {
  49934. name: string;
  49935. shader: string;
  49936. };
  49937. }
  49938. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49939. /** @hidden */
  49940. export var pbrIBLFunctions: {
  49941. name: string;
  49942. shader: string;
  49943. };
  49944. }
  49945. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49946. /** @hidden */
  49947. export var pbrDebug: {
  49948. name: string;
  49949. shader: string;
  49950. };
  49951. }
  49952. declare module "babylonjs/Shaders/pbr.fragment" {
  49953. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49954. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49955. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49956. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49957. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49958. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49959. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49960. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49961. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49962. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49963. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49964. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49965. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49966. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49967. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49968. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49969. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49970. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49971. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49972. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49973. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49974. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49975. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49976. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49977. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49978. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49979. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49980. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49981. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49982. /** @hidden */
  49983. export var pbrPixelShader: {
  49984. name: string;
  49985. shader: string;
  49986. };
  49987. }
  49988. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49989. /** @hidden */
  49990. export var pbrVertexDeclaration: {
  49991. name: string;
  49992. shader: string;
  49993. };
  49994. }
  49995. declare module "babylonjs/Shaders/pbr.vertex" {
  49996. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49997. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49998. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49999. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50000. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50001. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50002. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50004. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50005. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50006. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50009. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50013. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50014. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50015. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50016. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50017. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50018. /** @hidden */
  50019. export var pbrVertexShader: {
  50020. name: string;
  50021. shader: string;
  50022. };
  50023. }
  50024. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50025. import { Nullable } from "babylonjs/types";
  50026. import { Scene } from "babylonjs/scene";
  50027. import { Matrix } from "babylonjs/Maths/math.vector";
  50028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50030. import { Mesh } from "babylonjs/Meshes/mesh";
  50031. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50032. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50033. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50034. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50035. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50036. import { Color3 } from "babylonjs/Maths/math.color";
  50037. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50038. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50039. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50040. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50042. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50043. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50044. import "babylonjs/Shaders/pbr.fragment";
  50045. import "babylonjs/Shaders/pbr.vertex";
  50046. /**
  50047. * Manages the defines for the PBR Material.
  50048. * @hidden
  50049. */
  50050. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50051. PBR: boolean;
  50052. MAINUV1: boolean;
  50053. MAINUV2: boolean;
  50054. UV1: boolean;
  50055. UV2: boolean;
  50056. ALBEDO: boolean;
  50057. ALBEDODIRECTUV: number;
  50058. VERTEXCOLOR: boolean;
  50059. AMBIENT: boolean;
  50060. AMBIENTDIRECTUV: number;
  50061. AMBIENTINGRAYSCALE: boolean;
  50062. OPACITY: boolean;
  50063. VERTEXALPHA: boolean;
  50064. OPACITYDIRECTUV: number;
  50065. OPACITYRGB: boolean;
  50066. ALPHATEST: boolean;
  50067. DEPTHPREPASS: boolean;
  50068. ALPHABLEND: boolean;
  50069. ALPHAFROMALBEDO: boolean;
  50070. ALPHATESTVALUE: string;
  50071. SPECULAROVERALPHA: boolean;
  50072. RADIANCEOVERALPHA: boolean;
  50073. ALPHAFRESNEL: boolean;
  50074. LINEARALPHAFRESNEL: boolean;
  50075. PREMULTIPLYALPHA: boolean;
  50076. EMISSIVE: boolean;
  50077. EMISSIVEDIRECTUV: number;
  50078. REFLECTIVITY: boolean;
  50079. REFLECTIVITYDIRECTUV: number;
  50080. SPECULARTERM: boolean;
  50081. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50082. MICROSURFACEAUTOMATIC: boolean;
  50083. LODBASEDMICROSFURACE: boolean;
  50084. MICROSURFACEMAP: boolean;
  50085. MICROSURFACEMAPDIRECTUV: number;
  50086. METALLICWORKFLOW: boolean;
  50087. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50088. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50089. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50090. AOSTOREINMETALMAPRED: boolean;
  50091. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50092. ENVIRONMENTBRDF: boolean;
  50093. ENVIRONMENTBRDF_RGBD: boolean;
  50094. NORMAL: boolean;
  50095. TANGENT: boolean;
  50096. BUMP: boolean;
  50097. BUMPDIRECTUV: number;
  50098. OBJECTSPACE_NORMALMAP: boolean;
  50099. PARALLAX: boolean;
  50100. PARALLAXOCCLUSION: boolean;
  50101. NORMALXYSCALE: boolean;
  50102. LIGHTMAP: boolean;
  50103. LIGHTMAPDIRECTUV: number;
  50104. USELIGHTMAPASSHADOWMAP: boolean;
  50105. GAMMALIGHTMAP: boolean;
  50106. RGBDLIGHTMAP: boolean;
  50107. REFLECTION: boolean;
  50108. REFLECTIONMAP_3D: boolean;
  50109. REFLECTIONMAP_SPHERICAL: boolean;
  50110. REFLECTIONMAP_PLANAR: boolean;
  50111. REFLECTIONMAP_CUBIC: boolean;
  50112. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50113. REFLECTIONMAP_PROJECTION: boolean;
  50114. REFLECTIONMAP_SKYBOX: boolean;
  50115. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50116. REFLECTIONMAP_EXPLICIT: boolean;
  50117. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50118. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50119. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50120. INVERTCUBICMAP: boolean;
  50121. USESPHERICALFROMREFLECTIONMAP: boolean;
  50122. USEIRRADIANCEMAP: boolean;
  50123. SPHERICAL_HARMONICS: boolean;
  50124. USESPHERICALINVERTEX: boolean;
  50125. REFLECTIONMAP_OPPOSITEZ: boolean;
  50126. LODINREFLECTIONALPHA: boolean;
  50127. GAMMAREFLECTION: boolean;
  50128. RGBDREFLECTION: boolean;
  50129. LINEARSPECULARREFLECTION: boolean;
  50130. RADIANCEOCCLUSION: boolean;
  50131. HORIZONOCCLUSION: boolean;
  50132. INSTANCES: boolean;
  50133. NUM_BONE_INFLUENCERS: number;
  50134. BonesPerMesh: number;
  50135. BONETEXTURE: boolean;
  50136. NONUNIFORMSCALING: boolean;
  50137. MORPHTARGETS: boolean;
  50138. MORPHTARGETS_NORMAL: boolean;
  50139. MORPHTARGETS_TANGENT: boolean;
  50140. MORPHTARGETS_UV: boolean;
  50141. NUM_MORPH_INFLUENCERS: number;
  50142. IMAGEPROCESSING: boolean;
  50143. VIGNETTE: boolean;
  50144. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50145. VIGNETTEBLENDMODEOPAQUE: boolean;
  50146. TONEMAPPING: boolean;
  50147. TONEMAPPING_ACES: boolean;
  50148. CONTRAST: boolean;
  50149. COLORCURVES: boolean;
  50150. COLORGRADING: boolean;
  50151. COLORGRADING3D: boolean;
  50152. SAMPLER3DGREENDEPTH: boolean;
  50153. SAMPLER3DBGRMAP: boolean;
  50154. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50155. EXPOSURE: boolean;
  50156. MULTIVIEW: boolean;
  50157. USEPHYSICALLIGHTFALLOFF: boolean;
  50158. USEGLTFLIGHTFALLOFF: boolean;
  50159. TWOSIDEDLIGHTING: boolean;
  50160. SHADOWFLOAT: boolean;
  50161. CLIPPLANE: boolean;
  50162. CLIPPLANE2: boolean;
  50163. CLIPPLANE3: boolean;
  50164. CLIPPLANE4: boolean;
  50165. POINTSIZE: boolean;
  50166. FOG: boolean;
  50167. LOGARITHMICDEPTH: boolean;
  50168. FORCENORMALFORWARD: boolean;
  50169. SPECULARAA: boolean;
  50170. CLEARCOAT: boolean;
  50171. CLEARCOAT_DEFAULTIOR: boolean;
  50172. CLEARCOAT_TEXTURE: boolean;
  50173. CLEARCOAT_TEXTUREDIRECTUV: number;
  50174. CLEARCOAT_BUMP: boolean;
  50175. CLEARCOAT_BUMPDIRECTUV: number;
  50176. CLEARCOAT_TINT: boolean;
  50177. CLEARCOAT_TINT_TEXTURE: boolean;
  50178. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50179. ANISOTROPIC: boolean;
  50180. ANISOTROPIC_TEXTURE: boolean;
  50181. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50182. BRDF_V_HEIGHT_CORRELATED: boolean;
  50183. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50184. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50185. SHEEN: boolean;
  50186. SHEEN_TEXTURE: boolean;
  50187. SHEEN_TEXTUREDIRECTUV: number;
  50188. SHEEN_LINKWITHALBEDO: boolean;
  50189. SUBSURFACE: boolean;
  50190. SS_REFRACTION: boolean;
  50191. SS_TRANSLUCENCY: boolean;
  50192. SS_SCATERRING: boolean;
  50193. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50194. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50195. SS_REFRACTIONMAP_3D: boolean;
  50196. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50197. SS_LODINREFRACTIONALPHA: boolean;
  50198. SS_GAMMAREFRACTION: boolean;
  50199. SS_RGBDREFRACTION: boolean;
  50200. SS_LINEARSPECULARREFRACTION: boolean;
  50201. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50202. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50203. UNLIT: boolean;
  50204. DEBUGMODE: number;
  50205. /**
  50206. * Initializes the PBR Material defines.
  50207. */
  50208. constructor();
  50209. /**
  50210. * Resets the PBR Material defines.
  50211. */
  50212. reset(): void;
  50213. }
  50214. /**
  50215. * The Physically based material base class of BJS.
  50216. *
  50217. * This offers the main features of a standard PBR material.
  50218. * For more information, please refer to the documentation :
  50219. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50220. */
  50221. export abstract class PBRBaseMaterial extends PushMaterial {
  50222. /**
  50223. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50224. */
  50225. static readonly PBRMATERIAL_OPAQUE: number;
  50226. /**
  50227. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50228. */
  50229. static readonly PBRMATERIAL_ALPHATEST: number;
  50230. /**
  50231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50232. */
  50233. static readonly PBRMATERIAL_ALPHABLEND: number;
  50234. /**
  50235. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50236. * They are also discarded below the alpha cutoff threshold to improve performances.
  50237. */
  50238. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50239. /**
  50240. * Defines the default value of how much AO map is occluding the analytical lights
  50241. * (point spot...).
  50242. */
  50243. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50244. /**
  50245. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50246. */
  50247. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50248. /**
  50249. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50250. * to enhance interoperability with other engines.
  50251. */
  50252. static readonly LIGHTFALLOFF_GLTF: number;
  50253. /**
  50254. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50255. * to enhance interoperability with other materials.
  50256. */
  50257. static readonly LIGHTFALLOFF_STANDARD: number;
  50258. /**
  50259. * Intensity of the direct lights e.g. the four lights available in your scene.
  50260. * This impacts both the direct diffuse and specular highlights.
  50261. */
  50262. protected _directIntensity: number;
  50263. /**
  50264. * Intensity of the emissive part of the material.
  50265. * This helps controlling the emissive effect without modifying the emissive color.
  50266. */
  50267. protected _emissiveIntensity: number;
  50268. /**
  50269. * Intensity of the environment e.g. how much the environment will light the object
  50270. * either through harmonics for rough material or through the refelction for shiny ones.
  50271. */
  50272. protected _environmentIntensity: number;
  50273. /**
  50274. * This is a special control allowing the reduction of the specular highlights coming from the
  50275. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50276. */
  50277. protected _specularIntensity: number;
  50278. /**
  50279. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50280. */
  50281. private _lightingInfos;
  50282. /**
  50283. * Debug Control allowing disabling the bump map on this material.
  50284. */
  50285. protected _disableBumpMap: boolean;
  50286. /**
  50287. * AKA Diffuse Texture in standard nomenclature.
  50288. */
  50289. protected _albedoTexture: Nullable<BaseTexture>;
  50290. /**
  50291. * AKA Occlusion Texture in other nomenclature.
  50292. */
  50293. protected _ambientTexture: Nullable<BaseTexture>;
  50294. /**
  50295. * AKA Occlusion Texture Intensity in other nomenclature.
  50296. */
  50297. protected _ambientTextureStrength: number;
  50298. /**
  50299. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50300. * 1 means it completely occludes it
  50301. * 0 mean it has no impact
  50302. */
  50303. protected _ambientTextureImpactOnAnalyticalLights: number;
  50304. /**
  50305. * Stores the alpha values in a texture.
  50306. */
  50307. protected _opacityTexture: Nullable<BaseTexture>;
  50308. /**
  50309. * Stores the reflection values in a texture.
  50310. */
  50311. protected _reflectionTexture: Nullable<BaseTexture>;
  50312. /**
  50313. * Stores the emissive values in a texture.
  50314. */
  50315. protected _emissiveTexture: Nullable<BaseTexture>;
  50316. /**
  50317. * AKA Specular texture in other nomenclature.
  50318. */
  50319. protected _reflectivityTexture: Nullable<BaseTexture>;
  50320. /**
  50321. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50322. */
  50323. protected _metallicTexture: Nullable<BaseTexture>;
  50324. /**
  50325. * Specifies the metallic scalar of the metallic/roughness workflow.
  50326. * Can also be used to scale the metalness values of the metallic texture.
  50327. */
  50328. protected _metallic: Nullable<number>;
  50329. /**
  50330. * Specifies the roughness scalar of the metallic/roughness workflow.
  50331. * Can also be used to scale the roughness values of the metallic texture.
  50332. */
  50333. protected _roughness: Nullable<number>;
  50334. /**
  50335. * Specifies the an F0 factor to help configuring the material F0.
  50336. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50337. * to 0.5 the previously hard coded value stays the same.
  50338. * Can also be used to scale the F0 values of the metallic texture.
  50339. */
  50340. protected _metallicF0Factor: number;
  50341. /**
  50342. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50343. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50344. * your expectation as it multiplies with the texture data.
  50345. */
  50346. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50347. /**
  50348. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50349. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50350. */
  50351. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50352. /**
  50353. * Stores surface normal data used to displace a mesh in a texture.
  50354. */
  50355. protected _bumpTexture: Nullable<BaseTexture>;
  50356. /**
  50357. * Stores the pre-calculated light information of a mesh in a texture.
  50358. */
  50359. protected _lightmapTexture: Nullable<BaseTexture>;
  50360. /**
  50361. * The color of a material in ambient lighting.
  50362. */
  50363. protected _ambientColor: Color3;
  50364. /**
  50365. * AKA Diffuse Color in other nomenclature.
  50366. */
  50367. protected _albedoColor: Color3;
  50368. /**
  50369. * AKA Specular Color in other nomenclature.
  50370. */
  50371. protected _reflectivityColor: Color3;
  50372. /**
  50373. * The color applied when light is reflected from a material.
  50374. */
  50375. protected _reflectionColor: Color3;
  50376. /**
  50377. * The color applied when light is emitted from a material.
  50378. */
  50379. protected _emissiveColor: Color3;
  50380. /**
  50381. * AKA Glossiness in other nomenclature.
  50382. */
  50383. protected _microSurface: number;
  50384. /**
  50385. * Specifies that the material will use the light map as a show map.
  50386. */
  50387. protected _useLightmapAsShadowmap: boolean;
  50388. /**
  50389. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50390. * makes the reflect vector face the model (under horizon).
  50391. */
  50392. protected _useHorizonOcclusion: boolean;
  50393. /**
  50394. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50395. * too much the area relying on ambient texture to define their ambient occlusion.
  50396. */
  50397. protected _useRadianceOcclusion: boolean;
  50398. /**
  50399. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50400. */
  50401. protected _useAlphaFromAlbedoTexture: boolean;
  50402. /**
  50403. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50404. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50405. */
  50406. protected _useSpecularOverAlpha: boolean;
  50407. /**
  50408. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50409. */
  50410. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50411. /**
  50412. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50413. */
  50414. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50415. /**
  50416. * Specifies if the metallic texture contains the roughness information in its green channel.
  50417. */
  50418. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50419. /**
  50420. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50421. */
  50422. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50423. /**
  50424. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50425. */
  50426. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50427. /**
  50428. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50429. */
  50430. protected _useAmbientInGrayScale: boolean;
  50431. /**
  50432. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50433. * The material will try to infer what glossiness each pixel should be.
  50434. */
  50435. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50436. /**
  50437. * Defines the falloff type used in this material.
  50438. * It by default is Physical.
  50439. */
  50440. protected _lightFalloff: number;
  50441. /**
  50442. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50443. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50444. */
  50445. protected _useRadianceOverAlpha: boolean;
  50446. /**
  50447. * Allows using an object space normal map (instead of tangent space).
  50448. */
  50449. protected _useObjectSpaceNormalMap: boolean;
  50450. /**
  50451. * Allows using the bump map in parallax mode.
  50452. */
  50453. protected _useParallax: boolean;
  50454. /**
  50455. * Allows using the bump map in parallax occlusion mode.
  50456. */
  50457. protected _useParallaxOcclusion: boolean;
  50458. /**
  50459. * Controls the scale bias of the parallax mode.
  50460. */
  50461. protected _parallaxScaleBias: number;
  50462. /**
  50463. * If sets to true, disables all the lights affecting the material.
  50464. */
  50465. protected _disableLighting: boolean;
  50466. /**
  50467. * Number of Simultaneous lights allowed on the material.
  50468. */
  50469. protected _maxSimultaneousLights: number;
  50470. /**
  50471. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50472. */
  50473. protected _invertNormalMapX: boolean;
  50474. /**
  50475. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50476. */
  50477. protected _invertNormalMapY: boolean;
  50478. /**
  50479. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50480. */
  50481. protected _twoSidedLighting: boolean;
  50482. /**
  50483. * Defines the alpha limits in alpha test mode.
  50484. */
  50485. protected _alphaCutOff: number;
  50486. /**
  50487. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50488. */
  50489. protected _forceAlphaTest: boolean;
  50490. /**
  50491. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50492. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50493. */
  50494. protected _useAlphaFresnel: boolean;
  50495. /**
  50496. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50497. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50498. */
  50499. protected _useLinearAlphaFresnel: boolean;
  50500. /**
  50501. * The transparency mode of the material.
  50502. */
  50503. protected _transparencyMode: Nullable<number>;
  50504. /**
  50505. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50506. * from cos thetav and roughness:
  50507. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50508. */
  50509. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50510. /**
  50511. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50512. */
  50513. protected _forceIrradianceInFragment: boolean;
  50514. /**
  50515. * Force normal to face away from face.
  50516. */
  50517. protected _forceNormalForward: boolean;
  50518. /**
  50519. * Enables specular anti aliasing in the PBR shader.
  50520. * It will both interacts on the Geometry for analytical and IBL lighting.
  50521. * It also prefilter the roughness map based on the bump values.
  50522. */
  50523. protected _enableSpecularAntiAliasing: boolean;
  50524. /**
  50525. * Default configuration related to image processing available in the PBR Material.
  50526. */
  50527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50528. /**
  50529. * Keep track of the image processing observer to allow dispose and replace.
  50530. */
  50531. private _imageProcessingObserver;
  50532. /**
  50533. * Attaches a new image processing configuration to the PBR Material.
  50534. * @param configuration
  50535. */
  50536. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50537. /**
  50538. * Stores the available render targets.
  50539. */
  50540. private _renderTargets;
  50541. /**
  50542. * Sets the global ambient color for the material used in lighting calculations.
  50543. */
  50544. private _globalAmbientColor;
  50545. /**
  50546. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50547. */
  50548. private _useLogarithmicDepth;
  50549. /**
  50550. * If set to true, no lighting calculations will be applied.
  50551. */
  50552. private _unlit;
  50553. private _debugMode;
  50554. /**
  50555. * @hidden
  50556. * This is reserved for the inspector.
  50557. * Defines the material debug mode.
  50558. * It helps seeing only some components of the material while troubleshooting.
  50559. */
  50560. debugMode: number;
  50561. /**
  50562. * @hidden
  50563. * This is reserved for the inspector.
  50564. * Specify from where on screen the debug mode should start.
  50565. * The value goes from -1 (full screen) to 1 (not visible)
  50566. * It helps with side by side comparison against the final render
  50567. * This defaults to -1
  50568. */
  50569. private debugLimit;
  50570. /**
  50571. * @hidden
  50572. * This is reserved for the inspector.
  50573. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50574. * You can use the factor to better multiply the final value.
  50575. */
  50576. private debugFactor;
  50577. /**
  50578. * Defines the clear coat layer parameters for the material.
  50579. */
  50580. readonly clearCoat: PBRClearCoatConfiguration;
  50581. /**
  50582. * Defines the anisotropic parameters for the material.
  50583. */
  50584. readonly anisotropy: PBRAnisotropicConfiguration;
  50585. /**
  50586. * Defines the BRDF parameters for the material.
  50587. */
  50588. readonly brdf: PBRBRDFConfiguration;
  50589. /**
  50590. * Defines the Sheen parameters for the material.
  50591. */
  50592. readonly sheen: PBRSheenConfiguration;
  50593. /**
  50594. * Defines the SubSurface parameters for the material.
  50595. */
  50596. readonly subSurface: PBRSubSurfaceConfiguration;
  50597. /**
  50598. * Custom callback helping to override the default shader used in the material.
  50599. */
  50600. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50601. protected _rebuildInParallel: boolean;
  50602. /**
  50603. * Instantiates a new PBRMaterial instance.
  50604. *
  50605. * @param name The material name
  50606. * @param scene The scene the material will be use in.
  50607. */
  50608. constructor(name: string, scene: Scene);
  50609. /**
  50610. * Gets a boolean indicating that current material needs to register RTT
  50611. */
  50612. readonly hasRenderTargetTextures: boolean;
  50613. /**
  50614. * Gets the name of the material class.
  50615. */
  50616. getClassName(): string;
  50617. /**
  50618. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50619. */
  50620. /**
  50621. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50622. */
  50623. useLogarithmicDepth: boolean;
  50624. /**
  50625. * Gets the current transparency mode.
  50626. */
  50627. /**
  50628. * Sets the transparency mode of the material.
  50629. *
  50630. * | Value | Type | Description |
  50631. * | ----- | ----------------------------------- | ----------- |
  50632. * | 0 | OPAQUE | |
  50633. * | 1 | ALPHATEST | |
  50634. * | 2 | ALPHABLEND | |
  50635. * | 3 | ALPHATESTANDBLEND | |
  50636. *
  50637. */
  50638. transparencyMode: Nullable<number>;
  50639. /**
  50640. * Returns true if alpha blending should be disabled.
  50641. */
  50642. private readonly _disableAlphaBlending;
  50643. /**
  50644. * Specifies whether or not this material should be rendered in alpha blend mode.
  50645. */
  50646. needAlphaBlending(): boolean;
  50647. /**
  50648. * Specifies if the mesh will require alpha blending.
  50649. * @param mesh - BJS mesh.
  50650. */
  50651. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50652. /**
  50653. * Specifies whether or not this material should be rendered in alpha test mode.
  50654. */
  50655. needAlphaTesting(): boolean;
  50656. /**
  50657. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50658. */
  50659. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50660. /**
  50661. * Gets the texture used for the alpha test.
  50662. */
  50663. getAlphaTestTexture(): Nullable<BaseTexture>;
  50664. /**
  50665. * Specifies that the submesh is ready to be used.
  50666. * @param mesh - BJS mesh.
  50667. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50668. * @param useInstances - Specifies that instances should be used.
  50669. * @returns - boolean indicating that the submesh is ready or not.
  50670. */
  50671. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50672. /**
  50673. * Specifies if the material uses metallic roughness workflow.
  50674. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50675. */
  50676. isMetallicWorkflow(): boolean;
  50677. private _prepareEffect;
  50678. private _prepareDefines;
  50679. /**
  50680. * Force shader compilation
  50681. */
  50682. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50683. /**
  50684. * Initializes the uniform buffer layout for the shader.
  50685. */
  50686. buildUniformLayout(): void;
  50687. /**
  50688. * Unbinds the material from the mesh
  50689. */
  50690. unbind(): void;
  50691. /**
  50692. * Binds the submesh data.
  50693. * @param world - The world matrix.
  50694. * @param mesh - The BJS mesh.
  50695. * @param subMesh - A submesh of the BJS mesh.
  50696. */
  50697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50698. /**
  50699. * Returns the animatable textures.
  50700. * @returns - Array of animatable textures.
  50701. */
  50702. getAnimatables(): IAnimatable[];
  50703. /**
  50704. * Returns the texture used for reflections.
  50705. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50706. */
  50707. private _getReflectionTexture;
  50708. /**
  50709. * Returns an array of the actively used textures.
  50710. * @returns - Array of BaseTextures
  50711. */
  50712. getActiveTextures(): BaseTexture[];
  50713. /**
  50714. * Checks to see if a texture is used in the material.
  50715. * @param texture - Base texture to use.
  50716. * @returns - Boolean specifying if a texture is used in the material.
  50717. */
  50718. hasTexture(texture: BaseTexture): boolean;
  50719. /**
  50720. * Disposes the resources of the material.
  50721. * @param forceDisposeEffect - Forces the disposal of effects.
  50722. * @param forceDisposeTextures - Forces the disposal of all textures.
  50723. */
  50724. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50725. }
  50726. }
  50727. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50728. import { Nullable } from "babylonjs/types";
  50729. import { Scene } from "babylonjs/scene";
  50730. import { Color3 } from "babylonjs/Maths/math.color";
  50731. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50732. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50734. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50735. /**
  50736. * The Physically based material of BJS.
  50737. *
  50738. * This offers the main features of a standard PBR material.
  50739. * For more information, please refer to the documentation :
  50740. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50741. */
  50742. export class PBRMaterial extends PBRBaseMaterial {
  50743. /**
  50744. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50745. */
  50746. static readonly PBRMATERIAL_OPAQUE: number;
  50747. /**
  50748. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50749. */
  50750. static readonly PBRMATERIAL_ALPHATEST: number;
  50751. /**
  50752. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50753. */
  50754. static readonly PBRMATERIAL_ALPHABLEND: number;
  50755. /**
  50756. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50757. * They are also discarded below the alpha cutoff threshold to improve performances.
  50758. */
  50759. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50760. /**
  50761. * Defines the default value of how much AO map is occluding the analytical lights
  50762. * (point spot...).
  50763. */
  50764. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50765. /**
  50766. * Intensity of the direct lights e.g. the four lights available in your scene.
  50767. * This impacts both the direct diffuse and specular highlights.
  50768. */
  50769. directIntensity: number;
  50770. /**
  50771. * Intensity of the emissive part of the material.
  50772. * This helps controlling the emissive effect without modifying the emissive color.
  50773. */
  50774. emissiveIntensity: number;
  50775. /**
  50776. * Intensity of the environment e.g. how much the environment will light the object
  50777. * either through harmonics for rough material or through the refelction for shiny ones.
  50778. */
  50779. environmentIntensity: number;
  50780. /**
  50781. * This is a special control allowing the reduction of the specular highlights coming from the
  50782. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50783. */
  50784. specularIntensity: number;
  50785. /**
  50786. * Debug Control allowing disabling the bump map on this material.
  50787. */
  50788. disableBumpMap: boolean;
  50789. /**
  50790. * AKA Diffuse Texture in standard nomenclature.
  50791. */
  50792. albedoTexture: BaseTexture;
  50793. /**
  50794. * AKA Occlusion Texture in other nomenclature.
  50795. */
  50796. ambientTexture: BaseTexture;
  50797. /**
  50798. * AKA Occlusion Texture Intensity in other nomenclature.
  50799. */
  50800. ambientTextureStrength: number;
  50801. /**
  50802. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50803. * 1 means it completely occludes it
  50804. * 0 mean it has no impact
  50805. */
  50806. ambientTextureImpactOnAnalyticalLights: number;
  50807. /**
  50808. * Stores the alpha values in a texture.
  50809. */
  50810. opacityTexture: BaseTexture;
  50811. /**
  50812. * Stores the reflection values in a texture.
  50813. */
  50814. reflectionTexture: Nullable<BaseTexture>;
  50815. /**
  50816. * Stores the emissive values in a texture.
  50817. */
  50818. emissiveTexture: BaseTexture;
  50819. /**
  50820. * AKA Specular texture in other nomenclature.
  50821. */
  50822. reflectivityTexture: BaseTexture;
  50823. /**
  50824. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50825. */
  50826. metallicTexture: BaseTexture;
  50827. /**
  50828. * Specifies the metallic scalar of the metallic/roughness workflow.
  50829. * Can also be used to scale the metalness values of the metallic texture.
  50830. */
  50831. metallic: Nullable<number>;
  50832. /**
  50833. * Specifies the roughness scalar of the metallic/roughness workflow.
  50834. * Can also be used to scale the roughness values of the metallic texture.
  50835. */
  50836. roughness: Nullable<number>;
  50837. /**
  50838. * Specifies the an F0 factor to help configuring the material F0.
  50839. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50840. * to 0.5 the previously hard coded value stays the same.
  50841. * Can also be used to scale the F0 values of the metallic texture.
  50842. */
  50843. metallicF0Factor: number;
  50844. /**
  50845. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50846. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50847. * your expectation as it multiplies with the texture data.
  50848. */
  50849. useMetallicF0FactorFromMetallicTexture: boolean;
  50850. /**
  50851. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50852. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50853. */
  50854. microSurfaceTexture: BaseTexture;
  50855. /**
  50856. * Stores surface normal data used to displace a mesh in a texture.
  50857. */
  50858. bumpTexture: BaseTexture;
  50859. /**
  50860. * Stores the pre-calculated light information of a mesh in a texture.
  50861. */
  50862. lightmapTexture: BaseTexture;
  50863. /**
  50864. * Stores the refracted light information in a texture.
  50865. */
  50866. refractionTexture: Nullable<BaseTexture>;
  50867. /**
  50868. * The color of a material in ambient lighting.
  50869. */
  50870. ambientColor: Color3;
  50871. /**
  50872. * AKA Diffuse Color in other nomenclature.
  50873. */
  50874. albedoColor: Color3;
  50875. /**
  50876. * AKA Specular Color in other nomenclature.
  50877. */
  50878. reflectivityColor: Color3;
  50879. /**
  50880. * The color reflected from the material.
  50881. */
  50882. reflectionColor: Color3;
  50883. /**
  50884. * The color emitted from the material.
  50885. */
  50886. emissiveColor: Color3;
  50887. /**
  50888. * AKA Glossiness in other nomenclature.
  50889. */
  50890. microSurface: number;
  50891. /**
  50892. * source material index of refraction (IOR)' / 'destination material IOR.
  50893. */
  50894. indexOfRefraction: number;
  50895. /**
  50896. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50897. */
  50898. invertRefractionY: boolean;
  50899. /**
  50900. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50901. * Materials half opaque for instance using refraction could benefit from this control.
  50902. */
  50903. linkRefractionWithTransparency: boolean;
  50904. /**
  50905. * If true, the light map contains occlusion information instead of lighting info.
  50906. */
  50907. useLightmapAsShadowmap: boolean;
  50908. /**
  50909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50910. */
  50911. useAlphaFromAlbedoTexture: boolean;
  50912. /**
  50913. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50914. */
  50915. forceAlphaTest: boolean;
  50916. /**
  50917. * Defines the alpha limits in alpha test mode.
  50918. */
  50919. alphaCutOff: number;
  50920. /**
  50921. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50922. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50923. */
  50924. useSpecularOverAlpha: boolean;
  50925. /**
  50926. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50927. */
  50928. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50929. /**
  50930. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50931. */
  50932. useRoughnessFromMetallicTextureAlpha: boolean;
  50933. /**
  50934. * Specifies if the metallic texture contains the roughness information in its green channel.
  50935. */
  50936. useRoughnessFromMetallicTextureGreen: boolean;
  50937. /**
  50938. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50939. */
  50940. useMetallnessFromMetallicTextureBlue: boolean;
  50941. /**
  50942. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50943. */
  50944. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50945. /**
  50946. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50947. */
  50948. useAmbientInGrayScale: boolean;
  50949. /**
  50950. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50951. * The material will try to infer what glossiness each pixel should be.
  50952. */
  50953. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50954. /**
  50955. * BJS is using an harcoded light falloff based on a manually sets up range.
  50956. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50957. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50958. */
  50959. /**
  50960. * BJS is using an harcoded light falloff based on a manually sets up range.
  50961. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50962. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50963. */
  50964. usePhysicalLightFalloff: boolean;
  50965. /**
  50966. * In order to support the falloff compatibility with gltf, a special mode has been added
  50967. * to reproduce the gltf light falloff.
  50968. */
  50969. /**
  50970. * In order to support the falloff compatibility with gltf, a special mode has been added
  50971. * to reproduce the gltf light falloff.
  50972. */
  50973. useGLTFLightFalloff: boolean;
  50974. /**
  50975. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50976. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50977. */
  50978. useRadianceOverAlpha: boolean;
  50979. /**
  50980. * Allows using an object space normal map (instead of tangent space).
  50981. */
  50982. useObjectSpaceNormalMap: boolean;
  50983. /**
  50984. * Allows using the bump map in parallax mode.
  50985. */
  50986. useParallax: boolean;
  50987. /**
  50988. * Allows using the bump map in parallax occlusion mode.
  50989. */
  50990. useParallaxOcclusion: boolean;
  50991. /**
  50992. * Controls the scale bias of the parallax mode.
  50993. */
  50994. parallaxScaleBias: number;
  50995. /**
  50996. * If sets to true, disables all the lights affecting the material.
  50997. */
  50998. disableLighting: boolean;
  50999. /**
  51000. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51001. */
  51002. forceIrradianceInFragment: boolean;
  51003. /**
  51004. * Number of Simultaneous lights allowed on the material.
  51005. */
  51006. maxSimultaneousLights: number;
  51007. /**
  51008. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51009. */
  51010. invertNormalMapX: boolean;
  51011. /**
  51012. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51013. */
  51014. invertNormalMapY: boolean;
  51015. /**
  51016. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51017. */
  51018. twoSidedLighting: boolean;
  51019. /**
  51020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51021. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51022. */
  51023. useAlphaFresnel: boolean;
  51024. /**
  51025. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51026. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51027. */
  51028. useLinearAlphaFresnel: boolean;
  51029. /**
  51030. * Let user defines the brdf lookup texture used for IBL.
  51031. * A default 8bit version is embedded but you could point at :
  51032. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51033. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51034. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51035. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51036. */
  51037. environmentBRDFTexture: Nullable<BaseTexture>;
  51038. /**
  51039. * Force normal to face away from face.
  51040. */
  51041. forceNormalForward: boolean;
  51042. /**
  51043. * Enables specular anti aliasing in the PBR shader.
  51044. * It will both interacts on the Geometry for analytical and IBL lighting.
  51045. * It also prefilter the roughness map based on the bump values.
  51046. */
  51047. enableSpecularAntiAliasing: boolean;
  51048. /**
  51049. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51050. * makes the reflect vector face the model (under horizon).
  51051. */
  51052. useHorizonOcclusion: boolean;
  51053. /**
  51054. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51055. * too much the area relying on ambient texture to define their ambient occlusion.
  51056. */
  51057. useRadianceOcclusion: boolean;
  51058. /**
  51059. * If set to true, no lighting calculations will be applied.
  51060. */
  51061. unlit: boolean;
  51062. /**
  51063. * Gets the image processing configuration used either in this material.
  51064. */
  51065. /**
  51066. * Sets the Default image processing configuration used either in the this material.
  51067. *
  51068. * If sets to null, the scene one is in use.
  51069. */
  51070. imageProcessingConfiguration: ImageProcessingConfiguration;
  51071. /**
  51072. * Gets wether the color curves effect is enabled.
  51073. */
  51074. /**
  51075. * Sets wether the color curves effect is enabled.
  51076. */
  51077. cameraColorCurvesEnabled: boolean;
  51078. /**
  51079. * Gets wether the color grading effect is enabled.
  51080. */
  51081. /**
  51082. * Gets wether the color grading effect is enabled.
  51083. */
  51084. cameraColorGradingEnabled: boolean;
  51085. /**
  51086. * Gets wether tonemapping is enabled or not.
  51087. */
  51088. /**
  51089. * Sets wether tonemapping is enabled or not
  51090. */
  51091. cameraToneMappingEnabled: boolean;
  51092. /**
  51093. * The camera exposure used on this material.
  51094. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51095. * This corresponds to a photographic exposure.
  51096. */
  51097. /**
  51098. * The camera exposure used on this material.
  51099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51100. * This corresponds to a photographic exposure.
  51101. */
  51102. cameraExposure: number;
  51103. /**
  51104. * Gets The camera contrast used on this material.
  51105. */
  51106. /**
  51107. * Sets The camera contrast used on this material.
  51108. */
  51109. cameraContrast: number;
  51110. /**
  51111. * Gets the Color Grading 2D Lookup Texture.
  51112. */
  51113. /**
  51114. * Sets the Color Grading 2D Lookup Texture.
  51115. */
  51116. cameraColorGradingTexture: Nullable<BaseTexture>;
  51117. /**
  51118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51120. * 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;
  51121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51122. */
  51123. /**
  51124. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51125. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51126. * 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;
  51127. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51128. */
  51129. cameraColorCurves: Nullable<ColorCurves>;
  51130. /**
  51131. * Instantiates a new PBRMaterial instance.
  51132. *
  51133. * @param name The material name
  51134. * @param scene The scene the material will be use in.
  51135. */
  51136. constructor(name: string, scene: Scene);
  51137. /**
  51138. * Returns the name of this material class.
  51139. */
  51140. getClassName(): string;
  51141. /**
  51142. * Makes a duplicate of the current material.
  51143. * @param name - name to use for the new material.
  51144. */
  51145. clone(name: string): PBRMaterial;
  51146. /**
  51147. * Serializes this PBR Material.
  51148. * @returns - An object with the serialized material.
  51149. */
  51150. serialize(): any;
  51151. /**
  51152. * Parses a PBR Material from a serialized object.
  51153. * @param source - Serialized object.
  51154. * @param scene - BJS scene instance.
  51155. * @param rootUrl - url for the scene object
  51156. * @returns - PBRMaterial
  51157. */
  51158. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51159. }
  51160. }
  51161. declare module "babylonjs/Misc/dds" {
  51162. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51164. import { Nullable } from "babylonjs/types";
  51165. import { Scene } from "babylonjs/scene";
  51166. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51167. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51168. /**
  51169. * Direct draw surface info
  51170. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51171. */
  51172. export interface DDSInfo {
  51173. /**
  51174. * Width of the texture
  51175. */
  51176. width: number;
  51177. /**
  51178. * Width of the texture
  51179. */
  51180. height: number;
  51181. /**
  51182. * Number of Mipmaps for the texture
  51183. * @see https://en.wikipedia.org/wiki/Mipmap
  51184. */
  51185. mipmapCount: number;
  51186. /**
  51187. * If the textures format is a known fourCC format
  51188. * @see https://www.fourcc.org/
  51189. */
  51190. isFourCC: boolean;
  51191. /**
  51192. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51193. */
  51194. isRGB: boolean;
  51195. /**
  51196. * If the texture is a lumincance format
  51197. */
  51198. isLuminance: boolean;
  51199. /**
  51200. * If this is a cube texture
  51201. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51202. */
  51203. isCube: boolean;
  51204. /**
  51205. * If the texture is a compressed format eg. FOURCC_DXT1
  51206. */
  51207. isCompressed: boolean;
  51208. /**
  51209. * The dxgiFormat of the texture
  51210. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51211. */
  51212. dxgiFormat: number;
  51213. /**
  51214. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51215. */
  51216. textureType: number;
  51217. /**
  51218. * Sphericle polynomial created for the dds texture
  51219. */
  51220. sphericalPolynomial?: SphericalPolynomial;
  51221. }
  51222. /**
  51223. * Class used to provide DDS decompression tools
  51224. */
  51225. export class DDSTools {
  51226. /**
  51227. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51228. */
  51229. static StoreLODInAlphaChannel: boolean;
  51230. /**
  51231. * Gets DDS information from an array buffer
  51232. * @param arrayBuffer defines the array buffer to read data from
  51233. * @returns the DDS information
  51234. */
  51235. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51236. private static _FloatView;
  51237. private static _Int32View;
  51238. private static _ToHalfFloat;
  51239. private static _FromHalfFloat;
  51240. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51241. private static _GetHalfFloatRGBAArrayBuffer;
  51242. private static _GetFloatRGBAArrayBuffer;
  51243. private static _GetFloatAsUIntRGBAArrayBuffer;
  51244. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51245. private static _GetRGBAArrayBuffer;
  51246. private static _ExtractLongWordOrder;
  51247. private static _GetRGBArrayBuffer;
  51248. private static _GetLuminanceArrayBuffer;
  51249. /**
  51250. * Uploads DDS Levels to a Babylon Texture
  51251. * @hidden
  51252. */
  51253. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51254. }
  51255. module "babylonjs/Engines/thinEngine" {
  51256. interface ThinEngine {
  51257. /**
  51258. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51259. * @param rootUrl defines the url where the file to load is located
  51260. * @param scene defines the current scene
  51261. * @param lodScale defines scale to apply to the mip map selection
  51262. * @param lodOffset defines offset to apply to the mip map selection
  51263. * @param onLoad defines an optional callback raised when the texture is loaded
  51264. * @param onError defines an optional callback raised if there is an issue to load the texture
  51265. * @param format defines the format of the data
  51266. * @param forcedExtension defines the extension to use to pick the right loader
  51267. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51268. * @returns the cube texture as an InternalTexture
  51269. */
  51270. 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;
  51271. }
  51272. }
  51273. }
  51274. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51275. import { Nullable } from "babylonjs/types";
  51276. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51277. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51278. /**
  51279. * Implementation of the DDS Texture Loader.
  51280. * @hidden
  51281. */
  51282. export class _DDSTextureLoader implements IInternalTextureLoader {
  51283. /**
  51284. * Defines wether the loader supports cascade loading the different faces.
  51285. */
  51286. readonly supportCascades: boolean;
  51287. /**
  51288. * This returns if the loader support the current file information.
  51289. * @param extension defines the file extension of the file being loaded
  51290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51291. * @param fallback defines the fallback internal texture if any
  51292. * @param isBase64 defines whether the texture is encoded as a base64
  51293. * @param isBuffer defines whether the texture data are stored as a buffer
  51294. * @returns true if the loader can load the specified file
  51295. */
  51296. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51297. /**
  51298. * Transform the url before loading if required.
  51299. * @param rootUrl the url of the texture
  51300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51301. * @returns the transformed texture
  51302. */
  51303. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51304. /**
  51305. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51306. * @param rootUrl the url of the texture
  51307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51308. * @returns the fallback texture
  51309. */
  51310. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51311. /**
  51312. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51313. * @param data contains the texture data
  51314. * @param texture defines the BabylonJS internal texture
  51315. * @param createPolynomials will be true if polynomials have been requested
  51316. * @param onLoad defines the callback to trigger once the texture is ready
  51317. * @param onError defines the callback to trigger in case of error
  51318. */
  51319. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51320. /**
  51321. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51322. * @param data contains the texture data
  51323. * @param texture defines the BabylonJS internal texture
  51324. * @param callback defines the method to call once ready to upload
  51325. */
  51326. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51327. }
  51328. }
  51329. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51330. import { Nullable } from "babylonjs/types";
  51331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51332. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51333. /**
  51334. * Implementation of the ENV Texture Loader.
  51335. * @hidden
  51336. */
  51337. export class _ENVTextureLoader implements IInternalTextureLoader {
  51338. /**
  51339. * Defines wether the loader supports cascade loading the different faces.
  51340. */
  51341. readonly supportCascades: boolean;
  51342. /**
  51343. * This returns if the loader support the current file information.
  51344. * @param extension defines the file extension of the file being loaded
  51345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51346. * @param fallback defines the fallback internal texture if any
  51347. * @param isBase64 defines whether the texture is encoded as a base64
  51348. * @param isBuffer defines whether the texture data are stored as a buffer
  51349. * @returns true if the loader can load the specified file
  51350. */
  51351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51352. /**
  51353. * Transform the url before loading if required.
  51354. * @param rootUrl the url of the texture
  51355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51356. * @returns the transformed texture
  51357. */
  51358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51359. /**
  51360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51361. * @param rootUrl the url of the texture
  51362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51363. * @returns the fallback texture
  51364. */
  51365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51366. /**
  51367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51368. * @param data contains the texture data
  51369. * @param texture defines the BabylonJS internal texture
  51370. * @param createPolynomials will be true if polynomials have been requested
  51371. * @param onLoad defines the callback to trigger once the texture is ready
  51372. * @param onError defines the callback to trigger in case of error
  51373. */
  51374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51375. /**
  51376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51377. * @param data contains the texture data
  51378. * @param texture defines the BabylonJS internal texture
  51379. * @param callback defines the method to call once ready to upload
  51380. */
  51381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51382. }
  51383. }
  51384. declare module "babylonjs/Misc/khronosTextureContainer" {
  51385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51386. /**
  51387. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51388. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51389. */
  51390. export class KhronosTextureContainer {
  51391. /** contents of the KTX container file */
  51392. arrayBuffer: any;
  51393. private static HEADER_LEN;
  51394. private static COMPRESSED_2D;
  51395. private static COMPRESSED_3D;
  51396. private static TEX_2D;
  51397. private static TEX_3D;
  51398. /**
  51399. * Gets the openGL type
  51400. */
  51401. glType: number;
  51402. /**
  51403. * Gets the openGL type size
  51404. */
  51405. glTypeSize: number;
  51406. /**
  51407. * Gets the openGL format
  51408. */
  51409. glFormat: number;
  51410. /**
  51411. * Gets the openGL internal format
  51412. */
  51413. glInternalFormat: number;
  51414. /**
  51415. * Gets the base internal format
  51416. */
  51417. glBaseInternalFormat: number;
  51418. /**
  51419. * Gets image width in pixel
  51420. */
  51421. pixelWidth: number;
  51422. /**
  51423. * Gets image height in pixel
  51424. */
  51425. pixelHeight: number;
  51426. /**
  51427. * Gets image depth in pixels
  51428. */
  51429. pixelDepth: number;
  51430. /**
  51431. * Gets the number of array elements
  51432. */
  51433. numberOfArrayElements: number;
  51434. /**
  51435. * Gets the number of faces
  51436. */
  51437. numberOfFaces: number;
  51438. /**
  51439. * Gets the number of mipmap levels
  51440. */
  51441. numberOfMipmapLevels: number;
  51442. /**
  51443. * Gets the bytes of key value data
  51444. */
  51445. bytesOfKeyValueData: number;
  51446. /**
  51447. * Gets the load type
  51448. */
  51449. loadType: number;
  51450. /**
  51451. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51452. */
  51453. isInvalid: boolean;
  51454. /**
  51455. * Creates a new KhronosTextureContainer
  51456. * @param arrayBuffer contents of the KTX container file
  51457. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51458. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51459. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51460. */
  51461. constructor(
  51462. /** contents of the KTX container file */
  51463. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51464. /**
  51465. * Uploads KTX content to a Babylon Texture.
  51466. * It is assumed that the texture has already been created & is currently bound
  51467. * @hidden
  51468. */
  51469. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51470. private _upload2DCompressedLevels;
  51471. }
  51472. }
  51473. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51474. import { Nullable } from "babylonjs/types";
  51475. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51476. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51477. /**
  51478. * Implementation of the KTX Texture Loader.
  51479. * @hidden
  51480. */
  51481. export class _KTXTextureLoader implements IInternalTextureLoader {
  51482. /**
  51483. * Defines wether the loader supports cascade loading the different faces.
  51484. */
  51485. readonly supportCascades: boolean;
  51486. /**
  51487. * This returns if the loader support the current file information.
  51488. * @param extension defines the file extension of the file being loaded
  51489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51490. * @param fallback defines the fallback internal texture if any
  51491. * @param isBase64 defines whether the texture is encoded as a base64
  51492. * @param isBuffer defines whether the texture data are stored as a buffer
  51493. * @returns true if the loader can load the specified file
  51494. */
  51495. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51496. /**
  51497. * Transform the url before loading if required.
  51498. * @param rootUrl the url of the texture
  51499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51500. * @returns the transformed texture
  51501. */
  51502. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51503. /**
  51504. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51505. * @param rootUrl the url of the texture
  51506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51507. * @returns the fallback texture
  51508. */
  51509. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51510. /**
  51511. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51512. * @param data contains the texture data
  51513. * @param texture defines the BabylonJS internal texture
  51514. * @param createPolynomials will be true if polynomials have been requested
  51515. * @param onLoad defines the callback to trigger once the texture is ready
  51516. * @param onError defines the callback to trigger in case of error
  51517. */
  51518. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51519. /**
  51520. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51521. * @param data contains the texture data
  51522. * @param texture defines the BabylonJS internal texture
  51523. * @param callback defines the method to call once ready to upload
  51524. */
  51525. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51526. }
  51527. }
  51528. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51529. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51530. import { Scene } from "babylonjs/scene";
  51531. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51532. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51533. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51534. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51535. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51536. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51538. /**
  51539. * Options for the default xr helper
  51540. */
  51541. export class WebXRDefaultExperienceOptions {
  51542. /**
  51543. * Floor meshes that should be used for teleporting
  51544. */
  51545. floorMeshes: Array<AbstractMesh>;
  51546. /**
  51547. * Enable or disable default UI to enter XR
  51548. */
  51549. disableDefaultUI: boolean;
  51550. }
  51551. /**
  51552. * Default experience which provides a similar setup to the previous webVRExperience
  51553. */
  51554. export class WebXRDefaultExperience {
  51555. /**
  51556. * Base experience
  51557. */
  51558. baseExperience: WebXRExperienceHelper;
  51559. /**
  51560. * Input experience extension
  51561. */
  51562. input: WebXRInput;
  51563. /**
  51564. * Loads the controller models
  51565. */
  51566. controllerModelLoader: WebXRControllerModelLoader;
  51567. /**
  51568. * Enables laser pointer and selection
  51569. */
  51570. pointerSelection: WebXRControllerPointerSelection;
  51571. /**
  51572. * Enables teleportation
  51573. */
  51574. teleportation: WebXRControllerTeleportation;
  51575. /**
  51576. * Enables ui for enetering/exiting xr
  51577. */
  51578. enterExitUI: WebXREnterExitUI;
  51579. /**
  51580. * Default target xr should render to
  51581. */
  51582. renderTarget: WebXRRenderTarget;
  51583. /**
  51584. * Creates the default xr experience
  51585. * @param scene scene
  51586. * @param options options for basic configuration
  51587. * @returns resulting WebXRDefaultExperience
  51588. */
  51589. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51590. private constructor();
  51591. /**
  51592. * DIsposes of the experience helper
  51593. */
  51594. dispose(): void;
  51595. }
  51596. }
  51597. declare module "babylonjs/Helpers/sceneHelpers" {
  51598. import { Nullable } from "babylonjs/types";
  51599. import { Mesh } from "babylonjs/Meshes/mesh";
  51600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51601. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51602. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51603. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51604. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51605. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51606. import "babylonjs/Meshes/Builders/boxBuilder";
  51607. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51608. /** @hidden */
  51609. export var _forceSceneHelpersToBundle: boolean;
  51610. module "babylonjs/scene" {
  51611. interface Scene {
  51612. /**
  51613. * Creates a default light for the scene.
  51614. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51615. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51616. */
  51617. createDefaultLight(replace?: boolean): void;
  51618. /**
  51619. * Creates a default camera for the scene.
  51620. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51621. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51622. * @param replace has default false, when true replaces the active camera in the scene
  51623. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51624. */
  51625. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51626. /**
  51627. * Creates a default camera and a default light.
  51628. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51629. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51630. * @param replace has the default false, when true replaces the active camera/light in the scene
  51631. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51632. */
  51633. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51634. /**
  51635. * Creates a new sky box
  51636. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51637. * @param environmentTexture defines the texture to use as environment texture
  51638. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51639. * @param scale defines the overall scale of the skybox
  51640. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51641. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51642. * @returns a new mesh holding the sky box
  51643. */
  51644. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51645. /**
  51646. * Creates a new environment
  51647. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51648. * @param options defines the options you can use to configure the environment
  51649. * @returns the new EnvironmentHelper
  51650. */
  51651. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51652. /**
  51653. * Creates a new VREXperienceHelper
  51654. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51655. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51656. * @returns a new VREXperienceHelper
  51657. */
  51658. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51659. /**
  51660. * Creates a new WebXRDefaultExperience
  51661. * @see http://doc.babylonjs.com/how_to/webxr
  51662. * @param options experience options
  51663. * @returns a promise for a new WebXRDefaultExperience
  51664. */
  51665. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51666. }
  51667. }
  51668. }
  51669. declare module "babylonjs/Helpers/videoDome" {
  51670. import { Scene } from "babylonjs/scene";
  51671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51672. import { Mesh } from "babylonjs/Meshes/mesh";
  51673. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51674. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51675. import "babylonjs/Meshes/Builders/sphereBuilder";
  51676. /**
  51677. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51678. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51679. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51680. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51681. */
  51682. export class VideoDome extends TransformNode {
  51683. /**
  51684. * Define the video source as a Monoscopic panoramic 360 video.
  51685. */
  51686. static readonly MODE_MONOSCOPIC: number;
  51687. /**
  51688. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51689. */
  51690. static readonly MODE_TOPBOTTOM: number;
  51691. /**
  51692. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51693. */
  51694. static readonly MODE_SIDEBYSIDE: number;
  51695. private _halfDome;
  51696. private _useDirectMapping;
  51697. /**
  51698. * The video texture being displayed on the sphere
  51699. */
  51700. protected _videoTexture: VideoTexture;
  51701. /**
  51702. * Gets the video texture being displayed on the sphere
  51703. */
  51704. readonly videoTexture: VideoTexture;
  51705. /**
  51706. * The skybox material
  51707. */
  51708. protected _material: BackgroundMaterial;
  51709. /**
  51710. * The surface used for the skybox
  51711. */
  51712. protected _mesh: Mesh;
  51713. /**
  51714. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51715. */
  51716. private _halfDomeMask;
  51717. /**
  51718. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51719. * Also see the options.resolution property.
  51720. */
  51721. fovMultiplier: number;
  51722. private _videoMode;
  51723. /**
  51724. * Gets or set the current video mode for the video. It can be:
  51725. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51726. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51727. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51728. */
  51729. videoMode: number;
  51730. /**
  51731. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51732. *
  51733. */
  51734. /**
  51735. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51736. */
  51737. halfDome: boolean;
  51738. /**
  51739. * Oberserver used in Stereoscopic VR Mode.
  51740. */
  51741. private _onBeforeCameraRenderObserver;
  51742. /**
  51743. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51744. * @param name Element's name, child elements will append suffixes for their own names.
  51745. * @param urlsOrVideo defines the url(s) or the video element to use
  51746. * @param options An object containing optional or exposed sub element properties
  51747. */
  51748. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51749. resolution?: number;
  51750. clickToPlay?: boolean;
  51751. autoPlay?: boolean;
  51752. loop?: boolean;
  51753. size?: number;
  51754. poster?: string;
  51755. faceForward?: boolean;
  51756. useDirectMapping?: boolean;
  51757. halfDomeMode?: boolean;
  51758. }, scene: Scene);
  51759. private _changeVideoMode;
  51760. /**
  51761. * Releases resources associated with this node.
  51762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51764. */
  51765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51766. }
  51767. }
  51768. declare module "babylonjs/Helpers/index" {
  51769. export * from "babylonjs/Helpers/environmentHelper";
  51770. export * from "babylonjs/Helpers/photoDome";
  51771. export * from "babylonjs/Helpers/sceneHelpers";
  51772. export * from "babylonjs/Helpers/videoDome";
  51773. }
  51774. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51775. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51776. import { IDisposable } from "babylonjs/scene";
  51777. import { Engine } from "babylonjs/Engines/engine";
  51778. /**
  51779. * This class can be used to get instrumentation data from a Babylon engine
  51780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51781. */
  51782. export class EngineInstrumentation implements IDisposable {
  51783. /**
  51784. * Define the instrumented engine.
  51785. */
  51786. engine: Engine;
  51787. private _captureGPUFrameTime;
  51788. private _gpuFrameTimeToken;
  51789. private _gpuFrameTime;
  51790. private _captureShaderCompilationTime;
  51791. private _shaderCompilationTime;
  51792. private _onBeginFrameObserver;
  51793. private _onEndFrameObserver;
  51794. private _onBeforeShaderCompilationObserver;
  51795. private _onAfterShaderCompilationObserver;
  51796. /**
  51797. * Gets the perf counter used for GPU frame time
  51798. */
  51799. readonly gpuFrameTimeCounter: PerfCounter;
  51800. /**
  51801. * Gets the GPU frame time capture status
  51802. */
  51803. /**
  51804. * Enable or disable the GPU frame time capture
  51805. */
  51806. captureGPUFrameTime: boolean;
  51807. /**
  51808. * Gets the perf counter used for shader compilation time
  51809. */
  51810. readonly shaderCompilationTimeCounter: PerfCounter;
  51811. /**
  51812. * Gets the shader compilation time capture status
  51813. */
  51814. /**
  51815. * Enable or disable the shader compilation time capture
  51816. */
  51817. captureShaderCompilationTime: boolean;
  51818. /**
  51819. * Instantiates a new engine instrumentation.
  51820. * This class can be used to get instrumentation data from a Babylon engine
  51821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51822. * @param engine Defines the engine to instrument
  51823. */
  51824. constructor(
  51825. /**
  51826. * Define the instrumented engine.
  51827. */
  51828. engine: Engine);
  51829. /**
  51830. * Dispose and release associated resources.
  51831. */
  51832. dispose(): void;
  51833. }
  51834. }
  51835. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51836. import { Scene, IDisposable } from "babylonjs/scene";
  51837. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51838. /**
  51839. * This class can be used to get instrumentation data from a Babylon engine
  51840. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51841. */
  51842. export class SceneInstrumentation implements IDisposable {
  51843. /**
  51844. * Defines the scene to instrument
  51845. */
  51846. scene: Scene;
  51847. private _captureActiveMeshesEvaluationTime;
  51848. private _activeMeshesEvaluationTime;
  51849. private _captureRenderTargetsRenderTime;
  51850. private _renderTargetsRenderTime;
  51851. private _captureFrameTime;
  51852. private _frameTime;
  51853. private _captureRenderTime;
  51854. private _renderTime;
  51855. private _captureInterFrameTime;
  51856. private _interFrameTime;
  51857. private _captureParticlesRenderTime;
  51858. private _particlesRenderTime;
  51859. private _captureSpritesRenderTime;
  51860. private _spritesRenderTime;
  51861. private _capturePhysicsTime;
  51862. private _physicsTime;
  51863. private _captureAnimationsTime;
  51864. private _animationsTime;
  51865. private _captureCameraRenderTime;
  51866. private _cameraRenderTime;
  51867. private _onBeforeActiveMeshesEvaluationObserver;
  51868. private _onAfterActiveMeshesEvaluationObserver;
  51869. private _onBeforeRenderTargetsRenderObserver;
  51870. private _onAfterRenderTargetsRenderObserver;
  51871. private _onAfterRenderObserver;
  51872. private _onBeforeDrawPhaseObserver;
  51873. private _onAfterDrawPhaseObserver;
  51874. private _onBeforeAnimationsObserver;
  51875. private _onBeforeParticlesRenderingObserver;
  51876. private _onAfterParticlesRenderingObserver;
  51877. private _onBeforeSpritesRenderingObserver;
  51878. private _onAfterSpritesRenderingObserver;
  51879. private _onBeforePhysicsObserver;
  51880. private _onAfterPhysicsObserver;
  51881. private _onAfterAnimationsObserver;
  51882. private _onBeforeCameraRenderObserver;
  51883. private _onAfterCameraRenderObserver;
  51884. /**
  51885. * Gets the perf counter used for active meshes evaluation time
  51886. */
  51887. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51888. /**
  51889. * Gets the active meshes evaluation time capture status
  51890. */
  51891. /**
  51892. * Enable or disable the active meshes evaluation time capture
  51893. */
  51894. captureActiveMeshesEvaluationTime: boolean;
  51895. /**
  51896. * Gets the perf counter used for render targets render time
  51897. */
  51898. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51899. /**
  51900. * Gets the render targets render time capture status
  51901. */
  51902. /**
  51903. * Enable or disable the render targets render time capture
  51904. */
  51905. captureRenderTargetsRenderTime: boolean;
  51906. /**
  51907. * Gets the perf counter used for particles render time
  51908. */
  51909. readonly particlesRenderTimeCounter: PerfCounter;
  51910. /**
  51911. * Gets the particles render time capture status
  51912. */
  51913. /**
  51914. * Enable or disable the particles render time capture
  51915. */
  51916. captureParticlesRenderTime: boolean;
  51917. /**
  51918. * Gets the perf counter used for sprites render time
  51919. */
  51920. readonly spritesRenderTimeCounter: PerfCounter;
  51921. /**
  51922. * Gets the sprites render time capture status
  51923. */
  51924. /**
  51925. * Enable or disable the sprites render time capture
  51926. */
  51927. captureSpritesRenderTime: boolean;
  51928. /**
  51929. * Gets the perf counter used for physics time
  51930. */
  51931. readonly physicsTimeCounter: PerfCounter;
  51932. /**
  51933. * Gets the physics time capture status
  51934. */
  51935. /**
  51936. * Enable or disable the physics time capture
  51937. */
  51938. capturePhysicsTime: boolean;
  51939. /**
  51940. * Gets the perf counter used for animations time
  51941. */
  51942. readonly animationsTimeCounter: PerfCounter;
  51943. /**
  51944. * Gets the animations time capture status
  51945. */
  51946. /**
  51947. * Enable or disable the animations time capture
  51948. */
  51949. captureAnimationsTime: boolean;
  51950. /**
  51951. * Gets the perf counter used for frame time capture
  51952. */
  51953. readonly frameTimeCounter: PerfCounter;
  51954. /**
  51955. * Gets the frame time capture status
  51956. */
  51957. /**
  51958. * Enable or disable the frame time capture
  51959. */
  51960. captureFrameTime: boolean;
  51961. /**
  51962. * Gets the perf counter used for inter-frames time capture
  51963. */
  51964. readonly interFrameTimeCounter: PerfCounter;
  51965. /**
  51966. * Gets the inter-frames time capture status
  51967. */
  51968. /**
  51969. * Enable or disable the inter-frames time capture
  51970. */
  51971. captureInterFrameTime: boolean;
  51972. /**
  51973. * Gets the perf counter used for render time capture
  51974. */
  51975. readonly renderTimeCounter: PerfCounter;
  51976. /**
  51977. * Gets the render time capture status
  51978. */
  51979. /**
  51980. * Enable or disable the render time capture
  51981. */
  51982. captureRenderTime: boolean;
  51983. /**
  51984. * Gets the perf counter used for camera render time capture
  51985. */
  51986. readonly cameraRenderTimeCounter: PerfCounter;
  51987. /**
  51988. * Gets the camera render time capture status
  51989. */
  51990. /**
  51991. * Enable or disable the camera render time capture
  51992. */
  51993. captureCameraRenderTime: boolean;
  51994. /**
  51995. * Gets the perf counter used for draw calls
  51996. */
  51997. readonly drawCallsCounter: PerfCounter;
  51998. /**
  51999. * Instantiates a new scene instrumentation.
  52000. * This class can be used to get instrumentation data from a Babylon engine
  52001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52002. * @param scene Defines the scene to instrument
  52003. */
  52004. constructor(
  52005. /**
  52006. * Defines the scene to instrument
  52007. */
  52008. scene: Scene);
  52009. /**
  52010. * Dispose and release associated resources.
  52011. */
  52012. dispose(): void;
  52013. }
  52014. }
  52015. declare module "babylonjs/Instrumentation/index" {
  52016. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52017. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52018. export * from "babylonjs/Instrumentation/timeToken";
  52019. }
  52020. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52021. /** @hidden */
  52022. export var glowMapGenerationPixelShader: {
  52023. name: string;
  52024. shader: string;
  52025. };
  52026. }
  52027. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52028. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52029. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52030. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52031. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52032. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52033. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52034. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52035. /** @hidden */
  52036. export var glowMapGenerationVertexShader: {
  52037. name: string;
  52038. shader: string;
  52039. };
  52040. }
  52041. declare module "babylonjs/Layers/effectLayer" {
  52042. import { Observable } from "babylonjs/Misc/observable";
  52043. import { Nullable } from "babylonjs/types";
  52044. import { Camera } from "babylonjs/Cameras/camera";
  52045. import { Scene } from "babylonjs/scene";
  52046. import { ISize } from "babylonjs/Maths/math.size";
  52047. import { Color4 } from "babylonjs/Maths/math.color";
  52048. import { Engine } from "babylonjs/Engines/engine";
  52049. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52051. import { Mesh } from "babylonjs/Meshes/mesh";
  52052. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52055. import { Effect } from "babylonjs/Materials/effect";
  52056. import { Material } from "babylonjs/Materials/material";
  52057. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52058. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52059. /**
  52060. * Effect layer options. This helps customizing the behaviour
  52061. * of the effect layer.
  52062. */
  52063. export interface IEffectLayerOptions {
  52064. /**
  52065. * Multiplication factor apply to the canvas size to compute the render target size
  52066. * used to generated the objects (the smaller the faster).
  52067. */
  52068. mainTextureRatio: number;
  52069. /**
  52070. * Enforces a fixed size texture to ensure effect stability across devices.
  52071. */
  52072. mainTextureFixedSize?: number;
  52073. /**
  52074. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52075. */
  52076. alphaBlendingMode: number;
  52077. /**
  52078. * The camera attached to the layer.
  52079. */
  52080. camera: Nullable<Camera>;
  52081. /**
  52082. * The rendering group to draw the layer in.
  52083. */
  52084. renderingGroupId: number;
  52085. }
  52086. /**
  52087. * The effect layer Helps adding post process effect blended with the main pass.
  52088. *
  52089. * This can be for instance use to generate glow or higlight effects on the scene.
  52090. *
  52091. * The effect layer class can not be used directly and is intented to inherited from to be
  52092. * customized per effects.
  52093. */
  52094. export abstract class EffectLayer {
  52095. private _vertexBuffers;
  52096. private _indexBuffer;
  52097. private _cachedDefines;
  52098. private _effectLayerMapGenerationEffect;
  52099. private _effectLayerOptions;
  52100. private _mergeEffect;
  52101. protected _scene: Scene;
  52102. protected _engine: Engine;
  52103. protected _maxSize: number;
  52104. protected _mainTextureDesiredSize: ISize;
  52105. protected _mainTexture: RenderTargetTexture;
  52106. protected _shouldRender: boolean;
  52107. protected _postProcesses: PostProcess[];
  52108. protected _textures: BaseTexture[];
  52109. protected _emissiveTextureAndColor: {
  52110. texture: Nullable<BaseTexture>;
  52111. color: Color4;
  52112. };
  52113. /**
  52114. * The name of the layer
  52115. */
  52116. name: string;
  52117. /**
  52118. * The clear color of the texture used to generate the glow map.
  52119. */
  52120. neutralColor: Color4;
  52121. /**
  52122. * Specifies wether the highlight layer is enabled or not.
  52123. */
  52124. isEnabled: boolean;
  52125. /**
  52126. * Gets the camera attached to the layer.
  52127. */
  52128. readonly camera: Nullable<Camera>;
  52129. /**
  52130. * Gets the rendering group id the layer should render in.
  52131. */
  52132. renderingGroupId: number;
  52133. /**
  52134. * An event triggered when the effect layer has been disposed.
  52135. */
  52136. onDisposeObservable: Observable<EffectLayer>;
  52137. /**
  52138. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52139. */
  52140. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52141. /**
  52142. * An event triggered when the generated texture is being merged in the scene.
  52143. */
  52144. onBeforeComposeObservable: Observable<EffectLayer>;
  52145. /**
  52146. * An event triggered when the mesh is rendered into the effect render target.
  52147. */
  52148. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52149. /**
  52150. * An event triggered after the mesh has been rendered into the effect render target.
  52151. */
  52152. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52153. /**
  52154. * An event triggered when the generated texture has been merged in the scene.
  52155. */
  52156. onAfterComposeObservable: Observable<EffectLayer>;
  52157. /**
  52158. * An event triggered when the efffect layer changes its size.
  52159. */
  52160. onSizeChangedObservable: Observable<EffectLayer>;
  52161. /** @hidden */
  52162. static _SceneComponentInitialization: (scene: Scene) => void;
  52163. /**
  52164. * Instantiates a new effect Layer and references it in the scene.
  52165. * @param name The name of the layer
  52166. * @param scene The scene to use the layer in
  52167. */
  52168. constructor(
  52169. /** The Friendly of the effect in the scene */
  52170. name: string, scene: Scene);
  52171. /**
  52172. * Get the effect name of the layer.
  52173. * @return The effect name
  52174. */
  52175. abstract getEffectName(): string;
  52176. /**
  52177. * Checks for the readiness of the element composing the layer.
  52178. * @param subMesh the mesh to check for
  52179. * @param useInstances specify wether or not to use instances to render the mesh
  52180. * @return true if ready otherwise, false
  52181. */
  52182. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52183. /**
  52184. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52185. * @returns true if the effect requires stencil during the main canvas render pass.
  52186. */
  52187. abstract needStencil(): boolean;
  52188. /**
  52189. * Create the merge effect. This is the shader use to blit the information back
  52190. * to the main canvas at the end of the scene rendering.
  52191. * @returns The effect containing the shader used to merge the effect on the main canvas
  52192. */
  52193. protected abstract _createMergeEffect(): Effect;
  52194. /**
  52195. * Creates the render target textures and post processes used in the effect layer.
  52196. */
  52197. protected abstract _createTextureAndPostProcesses(): void;
  52198. /**
  52199. * Implementation specific of rendering the generating effect on the main canvas.
  52200. * @param effect The effect used to render through
  52201. */
  52202. protected abstract _internalRender(effect: Effect): void;
  52203. /**
  52204. * Sets the required values for both the emissive texture and and the main color.
  52205. */
  52206. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52207. /**
  52208. * Free any resources and references associated to a mesh.
  52209. * Internal use
  52210. * @param mesh The mesh to free.
  52211. */
  52212. abstract _disposeMesh(mesh: Mesh): void;
  52213. /**
  52214. * Serializes this layer (Glow or Highlight for example)
  52215. * @returns a serialized layer object
  52216. */
  52217. abstract serialize?(): any;
  52218. /**
  52219. * Initializes the effect layer with the required options.
  52220. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52221. */
  52222. protected _init(options: Partial<IEffectLayerOptions>): void;
  52223. /**
  52224. * Generates the index buffer of the full screen quad blending to the main canvas.
  52225. */
  52226. private _generateIndexBuffer;
  52227. /**
  52228. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52229. */
  52230. private _generateVertexBuffer;
  52231. /**
  52232. * Sets the main texture desired size which is the closest power of two
  52233. * of the engine canvas size.
  52234. */
  52235. private _setMainTextureSize;
  52236. /**
  52237. * Creates the main texture for the effect layer.
  52238. */
  52239. protected _createMainTexture(): void;
  52240. /**
  52241. * Adds specific effects defines.
  52242. * @param defines The defines to add specifics to.
  52243. */
  52244. protected _addCustomEffectDefines(defines: string[]): void;
  52245. /**
  52246. * Checks for the readiness of the element composing the layer.
  52247. * @param subMesh the mesh to check for
  52248. * @param useInstances specify wether or not to use instances to render the mesh
  52249. * @param emissiveTexture the associated emissive texture used to generate the glow
  52250. * @return true if ready otherwise, false
  52251. */
  52252. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52253. /**
  52254. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52255. */
  52256. render(): void;
  52257. /**
  52258. * Determine if a given mesh will be used in the current effect.
  52259. * @param mesh mesh to test
  52260. * @returns true if the mesh will be used
  52261. */
  52262. hasMesh(mesh: AbstractMesh): boolean;
  52263. /**
  52264. * Returns true if the layer contains information to display, otherwise false.
  52265. * @returns true if the glow layer should be rendered
  52266. */
  52267. shouldRender(): boolean;
  52268. /**
  52269. * Returns true if the mesh should render, otherwise false.
  52270. * @param mesh The mesh to render
  52271. * @returns true if it should render otherwise false
  52272. */
  52273. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52274. /**
  52275. * Returns true if the mesh can be rendered, otherwise false.
  52276. * @param mesh The mesh to render
  52277. * @param material The material used on the mesh
  52278. * @returns true if it can be rendered otherwise false
  52279. */
  52280. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52281. /**
  52282. * Returns true if the mesh should render, otherwise false.
  52283. * @param mesh The mesh to render
  52284. * @returns true if it should render otherwise false
  52285. */
  52286. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52287. /**
  52288. * Renders the submesh passed in parameter to the generation map.
  52289. */
  52290. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52291. /**
  52292. * Defines wether the current material of the mesh should be use to render the effect.
  52293. * @param mesh defines the current mesh to render
  52294. */
  52295. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52296. /**
  52297. * Rebuild the required buffers.
  52298. * @hidden Internal use only.
  52299. */
  52300. _rebuild(): void;
  52301. /**
  52302. * Dispose only the render target textures and post process.
  52303. */
  52304. private _disposeTextureAndPostProcesses;
  52305. /**
  52306. * Dispose the highlight layer and free resources.
  52307. */
  52308. dispose(): void;
  52309. /**
  52310. * Gets the class name of the effect layer
  52311. * @returns the string with the class name of the effect layer
  52312. */
  52313. getClassName(): string;
  52314. /**
  52315. * Creates an effect layer from parsed effect layer data
  52316. * @param parsedEffectLayer defines effect layer data
  52317. * @param scene defines the current scene
  52318. * @param rootUrl defines the root URL containing the effect layer information
  52319. * @returns a parsed effect Layer
  52320. */
  52321. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52322. }
  52323. }
  52324. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52325. import { Scene } from "babylonjs/scene";
  52326. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52327. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52328. import { AbstractScene } from "babylonjs/abstractScene";
  52329. module "babylonjs/abstractScene" {
  52330. interface AbstractScene {
  52331. /**
  52332. * The list of effect layers (highlights/glow) added to the scene
  52333. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52334. * @see http://doc.babylonjs.com/how_to/glow_layer
  52335. */
  52336. effectLayers: Array<EffectLayer>;
  52337. /**
  52338. * Removes the given effect layer from this scene.
  52339. * @param toRemove defines the effect layer to remove
  52340. * @returns the index of the removed effect layer
  52341. */
  52342. removeEffectLayer(toRemove: EffectLayer): number;
  52343. /**
  52344. * Adds the given effect layer to this scene
  52345. * @param newEffectLayer defines the effect layer to add
  52346. */
  52347. addEffectLayer(newEffectLayer: EffectLayer): void;
  52348. }
  52349. }
  52350. /**
  52351. * Defines the layer scene component responsible to manage any effect layers
  52352. * in a given scene.
  52353. */
  52354. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52355. /**
  52356. * The component name helpfull to identify the component in the list of scene components.
  52357. */
  52358. readonly name: string;
  52359. /**
  52360. * The scene the component belongs to.
  52361. */
  52362. scene: Scene;
  52363. private _engine;
  52364. private _renderEffects;
  52365. private _needStencil;
  52366. private _previousStencilState;
  52367. /**
  52368. * Creates a new instance of the component for the given scene
  52369. * @param scene Defines the scene to register the component in
  52370. */
  52371. constructor(scene: Scene);
  52372. /**
  52373. * Registers the component in a given scene
  52374. */
  52375. register(): void;
  52376. /**
  52377. * Rebuilds the elements related to this component in case of
  52378. * context lost for instance.
  52379. */
  52380. rebuild(): void;
  52381. /**
  52382. * Serializes the component data to the specified json object
  52383. * @param serializationObject The object to serialize to
  52384. */
  52385. serialize(serializationObject: any): void;
  52386. /**
  52387. * Adds all the elements from the container to the scene
  52388. * @param container the container holding the elements
  52389. */
  52390. addFromContainer(container: AbstractScene): void;
  52391. /**
  52392. * Removes all the elements in the container from the scene
  52393. * @param container contains the elements to remove
  52394. * @param dispose if the removed element should be disposed (default: false)
  52395. */
  52396. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52397. /**
  52398. * Disposes the component and the associated ressources.
  52399. */
  52400. dispose(): void;
  52401. private _isReadyForMesh;
  52402. private _renderMainTexture;
  52403. private _setStencil;
  52404. private _setStencilBack;
  52405. private _draw;
  52406. private _drawCamera;
  52407. private _drawRenderingGroup;
  52408. }
  52409. }
  52410. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52411. /** @hidden */
  52412. export var glowMapMergePixelShader: {
  52413. name: string;
  52414. shader: string;
  52415. };
  52416. }
  52417. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52418. /** @hidden */
  52419. export var glowMapMergeVertexShader: {
  52420. name: string;
  52421. shader: string;
  52422. };
  52423. }
  52424. declare module "babylonjs/Layers/glowLayer" {
  52425. import { Nullable } from "babylonjs/types";
  52426. import { Camera } from "babylonjs/Cameras/camera";
  52427. import { Scene } from "babylonjs/scene";
  52428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52430. import { Mesh } from "babylonjs/Meshes/mesh";
  52431. import { Texture } from "babylonjs/Materials/Textures/texture";
  52432. import { Effect } from "babylonjs/Materials/effect";
  52433. import { Material } from "babylonjs/Materials/material";
  52434. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52435. import { Color4 } from "babylonjs/Maths/math.color";
  52436. import "babylonjs/Shaders/glowMapMerge.fragment";
  52437. import "babylonjs/Shaders/glowMapMerge.vertex";
  52438. import "babylonjs/Layers/effectLayerSceneComponent";
  52439. module "babylonjs/abstractScene" {
  52440. interface AbstractScene {
  52441. /**
  52442. * Return a the first highlight layer of the scene with a given name.
  52443. * @param name The name of the highlight layer to look for.
  52444. * @return The highlight layer if found otherwise null.
  52445. */
  52446. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52447. }
  52448. }
  52449. /**
  52450. * Glow layer options. This helps customizing the behaviour
  52451. * of the glow layer.
  52452. */
  52453. export interface IGlowLayerOptions {
  52454. /**
  52455. * Multiplication factor apply to the canvas size to compute the render target size
  52456. * used to generated the glowing objects (the smaller the faster).
  52457. */
  52458. mainTextureRatio: number;
  52459. /**
  52460. * Enforces a fixed size texture to ensure resize independant blur.
  52461. */
  52462. mainTextureFixedSize?: number;
  52463. /**
  52464. * How big is the kernel of the blur texture.
  52465. */
  52466. blurKernelSize: number;
  52467. /**
  52468. * The camera attached to the layer.
  52469. */
  52470. camera: Nullable<Camera>;
  52471. /**
  52472. * Enable MSAA by chosing the number of samples.
  52473. */
  52474. mainTextureSamples?: number;
  52475. /**
  52476. * The rendering group to draw the layer in.
  52477. */
  52478. renderingGroupId: number;
  52479. }
  52480. /**
  52481. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52482. *
  52483. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52484. *
  52485. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52486. */
  52487. export class GlowLayer extends EffectLayer {
  52488. /**
  52489. * Effect Name of the layer.
  52490. */
  52491. static readonly EffectName: string;
  52492. /**
  52493. * The default blur kernel size used for the glow.
  52494. */
  52495. static DefaultBlurKernelSize: number;
  52496. /**
  52497. * The default texture size ratio used for the glow.
  52498. */
  52499. static DefaultTextureRatio: number;
  52500. /**
  52501. * Sets the kernel size of the blur.
  52502. */
  52503. /**
  52504. * Gets the kernel size of the blur.
  52505. */
  52506. blurKernelSize: number;
  52507. /**
  52508. * Sets the glow intensity.
  52509. */
  52510. /**
  52511. * Gets the glow intensity.
  52512. */
  52513. intensity: number;
  52514. private _options;
  52515. private _intensity;
  52516. private _horizontalBlurPostprocess1;
  52517. private _verticalBlurPostprocess1;
  52518. private _horizontalBlurPostprocess2;
  52519. private _verticalBlurPostprocess2;
  52520. private _blurTexture1;
  52521. private _blurTexture2;
  52522. private _postProcesses1;
  52523. private _postProcesses2;
  52524. private _includedOnlyMeshes;
  52525. private _excludedMeshes;
  52526. private _meshesUsingTheirOwnMaterials;
  52527. /**
  52528. * Callback used to let the user override the color selection on a per mesh basis
  52529. */
  52530. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52531. /**
  52532. * Callback used to let the user override the texture selection on a per mesh basis
  52533. */
  52534. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52535. /**
  52536. * Instantiates a new glow Layer and references it to the scene.
  52537. * @param name The name of the layer
  52538. * @param scene The scene to use the layer in
  52539. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52540. */
  52541. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52542. /**
  52543. * Get the effect name of the layer.
  52544. * @return The effect name
  52545. */
  52546. getEffectName(): string;
  52547. /**
  52548. * Create the merge effect. This is the shader use to blit the information back
  52549. * to the main canvas at the end of the scene rendering.
  52550. */
  52551. protected _createMergeEffect(): Effect;
  52552. /**
  52553. * Creates the render target textures and post processes used in the glow layer.
  52554. */
  52555. protected _createTextureAndPostProcesses(): void;
  52556. /**
  52557. * Checks for the readiness of the element composing the layer.
  52558. * @param subMesh the mesh to check for
  52559. * @param useInstances specify wether or not to use instances to render the mesh
  52560. * @param emissiveTexture the associated emissive texture used to generate the glow
  52561. * @return true if ready otherwise, false
  52562. */
  52563. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52564. /**
  52565. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52566. */
  52567. needStencil(): boolean;
  52568. /**
  52569. * Returns true if the mesh can be rendered, otherwise false.
  52570. * @param mesh The mesh to render
  52571. * @param material The material used on the mesh
  52572. * @returns true if it can be rendered otherwise false
  52573. */
  52574. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52575. /**
  52576. * Implementation specific of rendering the generating effect on the main canvas.
  52577. * @param effect The effect used to render through
  52578. */
  52579. protected _internalRender(effect: Effect): void;
  52580. /**
  52581. * Sets the required values for both the emissive texture and and the main color.
  52582. */
  52583. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52584. /**
  52585. * Returns true if the mesh should render, otherwise false.
  52586. * @param mesh The mesh to render
  52587. * @returns true if it should render otherwise false
  52588. */
  52589. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52590. /**
  52591. * Adds specific effects defines.
  52592. * @param defines The defines to add specifics to.
  52593. */
  52594. protected _addCustomEffectDefines(defines: string[]): void;
  52595. /**
  52596. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52597. * @param mesh The mesh to exclude from the glow layer
  52598. */
  52599. addExcludedMesh(mesh: Mesh): void;
  52600. /**
  52601. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52602. * @param mesh The mesh to remove
  52603. */
  52604. removeExcludedMesh(mesh: Mesh): void;
  52605. /**
  52606. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52607. * @param mesh The mesh to include in the glow layer
  52608. */
  52609. addIncludedOnlyMesh(mesh: Mesh): void;
  52610. /**
  52611. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52612. * @param mesh The mesh to remove
  52613. */
  52614. removeIncludedOnlyMesh(mesh: Mesh): void;
  52615. /**
  52616. * Determine if a given mesh will be used in the glow layer
  52617. * @param mesh The mesh to test
  52618. * @returns true if the mesh will be highlighted by the current glow layer
  52619. */
  52620. hasMesh(mesh: AbstractMesh): boolean;
  52621. /**
  52622. * Defines wether the current material of the mesh should be use to render the effect.
  52623. * @param mesh defines the current mesh to render
  52624. */
  52625. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52626. /**
  52627. * Add a mesh to be rendered through its own material and not with emissive only.
  52628. * @param mesh The mesh for which we need to use its material
  52629. */
  52630. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52631. /**
  52632. * Remove a mesh from being rendered through its own material and not with emissive only.
  52633. * @param mesh The mesh for which we need to not use its material
  52634. */
  52635. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52636. /**
  52637. * Free any resources and references associated to a mesh.
  52638. * Internal use
  52639. * @param mesh The mesh to free.
  52640. * @hidden
  52641. */
  52642. _disposeMesh(mesh: Mesh): void;
  52643. /**
  52644. * Gets the class name of the effect layer
  52645. * @returns the string with the class name of the effect layer
  52646. */
  52647. getClassName(): string;
  52648. /**
  52649. * Serializes this glow layer
  52650. * @returns a serialized glow layer object
  52651. */
  52652. serialize(): any;
  52653. /**
  52654. * Creates a Glow Layer from parsed glow layer data
  52655. * @param parsedGlowLayer defines glow layer data
  52656. * @param scene defines the current scene
  52657. * @param rootUrl defines the root URL containing the glow layer information
  52658. * @returns a parsed Glow Layer
  52659. */
  52660. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52661. }
  52662. }
  52663. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52664. /** @hidden */
  52665. export var glowBlurPostProcessPixelShader: {
  52666. name: string;
  52667. shader: string;
  52668. };
  52669. }
  52670. declare module "babylonjs/Layers/highlightLayer" {
  52671. import { Observable } from "babylonjs/Misc/observable";
  52672. import { Nullable } from "babylonjs/types";
  52673. import { Camera } from "babylonjs/Cameras/camera";
  52674. import { Scene } from "babylonjs/scene";
  52675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52677. import { Mesh } from "babylonjs/Meshes/mesh";
  52678. import { Effect } from "babylonjs/Materials/effect";
  52679. import { Material } from "babylonjs/Materials/material";
  52680. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52681. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52682. import "babylonjs/Shaders/glowMapMerge.fragment";
  52683. import "babylonjs/Shaders/glowMapMerge.vertex";
  52684. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52685. module "babylonjs/abstractScene" {
  52686. interface AbstractScene {
  52687. /**
  52688. * Return a the first highlight layer of the scene with a given name.
  52689. * @param name The name of the highlight layer to look for.
  52690. * @return The highlight layer if found otherwise null.
  52691. */
  52692. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52693. }
  52694. }
  52695. /**
  52696. * Highlight layer options. This helps customizing the behaviour
  52697. * of the highlight layer.
  52698. */
  52699. export interface IHighlightLayerOptions {
  52700. /**
  52701. * Multiplication factor apply to the canvas size to compute the render target size
  52702. * used to generated the glowing objects (the smaller the faster).
  52703. */
  52704. mainTextureRatio: number;
  52705. /**
  52706. * Enforces a fixed size texture to ensure resize independant blur.
  52707. */
  52708. mainTextureFixedSize?: number;
  52709. /**
  52710. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52711. * of the picture to blur (the smaller the faster).
  52712. */
  52713. blurTextureSizeRatio: number;
  52714. /**
  52715. * How big in texel of the blur texture is the vertical blur.
  52716. */
  52717. blurVerticalSize: number;
  52718. /**
  52719. * How big in texel of the blur texture is the horizontal blur.
  52720. */
  52721. blurHorizontalSize: number;
  52722. /**
  52723. * Alpha blending mode used to apply the blur. Default is combine.
  52724. */
  52725. alphaBlendingMode: number;
  52726. /**
  52727. * The camera attached to the layer.
  52728. */
  52729. camera: Nullable<Camera>;
  52730. /**
  52731. * Should we display highlight as a solid stroke?
  52732. */
  52733. isStroke?: boolean;
  52734. /**
  52735. * The rendering group to draw the layer in.
  52736. */
  52737. renderingGroupId: number;
  52738. }
  52739. /**
  52740. * The highlight layer Helps adding a glow effect around a mesh.
  52741. *
  52742. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52743. * glowy meshes to your scene.
  52744. *
  52745. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52746. */
  52747. export class HighlightLayer extends EffectLayer {
  52748. name: string;
  52749. /**
  52750. * Effect Name of the highlight layer.
  52751. */
  52752. static readonly EffectName: string;
  52753. /**
  52754. * The neutral color used during the preparation of the glow effect.
  52755. * This is black by default as the blend operation is a blend operation.
  52756. */
  52757. static NeutralColor: Color4;
  52758. /**
  52759. * Stencil value used for glowing meshes.
  52760. */
  52761. static GlowingMeshStencilReference: number;
  52762. /**
  52763. * Stencil value used for the other meshes in the scene.
  52764. */
  52765. static NormalMeshStencilReference: number;
  52766. /**
  52767. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52768. */
  52769. innerGlow: boolean;
  52770. /**
  52771. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52772. */
  52773. outerGlow: boolean;
  52774. /**
  52775. * Specifies the horizontal size of the blur.
  52776. */
  52777. /**
  52778. * Gets the horizontal size of the blur.
  52779. */
  52780. blurHorizontalSize: number;
  52781. /**
  52782. * Specifies the vertical size of the blur.
  52783. */
  52784. /**
  52785. * Gets the vertical size of the blur.
  52786. */
  52787. blurVerticalSize: number;
  52788. /**
  52789. * An event triggered when the highlight layer is being blurred.
  52790. */
  52791. onBeforeBlurObservable: Observable<HighlightLayer>;
  52792. /**
  52793. * An event triggered when the highlight layer has been blurred.
  52794. */
  52795. onAfterBlurObservable: Observable<HighlightLayer>;
  52796. private _instanceGlowingMeshStencilReference;
  52797. private _options;
  52798. private _downSamplePostprocess;
  52799. private _horizontalBlurPostprocess;
  52800. private _verticalBlurPostprocess;
  52801. private _blurTexture;
  52802. private _meshes;
  52803. private _excludedMeshes;
  52804. /**
  52805. * Instantiates a new highlight Layer and references it to the scene..
  52806. * @param name The name of the layer
  52807. * @param scene The scene to use the layer in
  52808. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52809. */
  52810. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52811. /**
  52812. * Get the effect name of the layer.
  52813. * @return The effect name
  52814. */
  52815. getEffectName(): string;
  52816. /**
  52817. * Create the merge effect. This is the shader use to blit the information back
  52818. * to the main canvas at the end of the scene rendering.
  52819. */
  52820. protected _createMergeEffect(): Effect;
  52821. /**
  52822. * Creates the render target textures and post processes used in the highlight layer.
  52823. */
  52824. protected _createTextureAndPostProcesses(): void;
  52825. /**
  52826. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52827. */
  52828. needStencil(): boolean;
  52829. /**
  52830. * Checks for the readiness of the element composing the layer.
  52831. * @param subMesh the mesh to check for
  52832. * @param useInstances specify wether or not to use instances to render the mesh
  52833. * @param emissiveTexture the associated emissive texture used to generate the glow
  52834. * @return true if ready otherwise, false
  52835. */
  52836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52837. /**
  52838. * Implementation specific of rendering the generating effect on the main canvas.
  52839. * @param effect The effect used to render through
  52840. */
  52841. protected _internalRender(effect: Effect): void;
  52842. /**
  52843. * Returns true if the layer contains information to display, otherwise false.
  52844. */
  52845. shouldRender(): boolean;
  52846. /**
  52847. * Returns true if the mesh should render, otherwise false.
  52848. * @param mesh The mesh to render
  52849. * @returns true if it should render otherwise false
  52850. */
  52851. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52852. /**
  52853. * Sets the required values for both the emissive texture and and the main color.
  52854. */
  52855. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52856. /**
  52857. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52858. * @param mesh The mesh to exclude from the highlight layer
  52859. */
  52860. addExcludedMesh(mesh: Mesh): void;
  52861. /**
  52862. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52863. * @param mesh The mesh to highlight
  52864. */
  52865. removeExcludedMesh(mesh: Mesh): void;
  52866. /**
  52867. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52868. * @param mesh mesh to test
  52869. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52870. */
  52871. hasMesh(mesh: AbstractMesh): boolean;
  52872. /**
  52873. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52874. * @param mesh The mesh to highlight
  52875. * @param color The color of the highlight
  52876. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52877. */
  52878. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52879. /**
  52880. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52881. * @param mesh The mesh to highlight
  52882. */
  52883. removeMesh(mesh: Mesh): void;
  52884. /**
  52885. * Force the stencil to the normal expected value for none glowing parts
  52886. */
  52887. private _defaultStencilReference;
  52888. /**
  52889. * Free any resources and references associated to a mesh.
  52890. * Internal use
  52891. * @param mesh The mesh to free.
  52892. * @hidden
  52893. */
  52894. _disposeMesh(mesh: Mesh): void;
  52895. /**
  52896. * Dispose the highlight layer and free resources.
  52897. */
  52898. dispose(): void;
  52899. /**
  52900. * Gets the class name of the effect layer
  52901. * @returns the string with the class name of the effect layer
  52902. */
  52903. getClassName(): string;
  52904. /**
  52905. * Serializes this Highlight layer
  52906. * @returns a serialized Highlight layer object
  52907. */
  52908. serialize(): any;
  52909. /**
  52910. * Creates a Highlight layer from parsed Highlight layer data
  52911. * @param parsedHightlightLayer defines the Highlight layer data
  52912. * @param scene defines the current scene
  52913. * @param rootUrl defines the root URL containing the Highlight layer information
  52914. * @returns a parsed Highlight layer
  52915. */
  52916. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52917. }
  52918. }
  52919. declare module "babylonjs/Layers/layerSceneComponent" {
  52920. import { Scene } from "babylonjs/scene";
  52921. import { ISceneComponent } from "babylonjs/sceneComponent";
  52922. import { Layer } from "babylonjs/Layers/layer";
  52923. import { AbstractScene } from "babylonjs/abstractScene";
  52924. module "babylonjs/abstractScene" {
  52925. interface AbstractScene {
  52926. /**
  52927. * The list of layers (background and foreground) of the scene
  52928. */
  52929. layers: Array<Layer>;
  52930. }
  52931. }
  52932. /**
  52933. * Defines the layer scene component responsible to manage any layers
  52934. * in a given scene.
  52935. */
  52936. export class LayerSceneComponent implements ISceneComponent {
  52937. /**
  52938. * The component name helpfull to identify the component in the list of scene components.
  52939. */
  52940. readonly name: string;
  52941. /**
  52942. * The scene the component belongs to.
  52943. */
  52944. scene: Scene;
  52945. private _engine;
  52946. /**
  52947. * Creates a new instance of the component for the given scene
  52948. * @param scene Defines the scene to register the component in
  52949. */
  52950. constructor(scene: Scene);
  52951. /**
  52952. * Registers the component in a given scene
  52953. */
  52954. register(): void;
  52955. /**
  52956. * Rebuilds the elements related to this component in case of
  52957. * context lost for instance.
  52958. */
  52959. rebuild(): void;
  52960. /**
  52961. * Disposes the component and the associated ressources.
  52962. */
  52963. dispose(): void;
  52964. private _draw;
  52965. private _drawCameraPredicate;
  52966. private _drawCameraBackground;
  52967. private _drawCameraForeground;
  52968. private _drawRenderTargetPredicate;
  52969. private _drawRenderTargetBackground;
  52970. private _drawRenderTargetForeground;
  52971. /**
  52972. * Adds all the elements from the container to the scene
  52973. * @param container the container holding the elements
  52974. */
  52975. addFromContainer(container: AbstractScene): void;
  52976. /**
  52977. * Removes all the elements in the container from the scene
  52978. * @param container contains the elements to remove
  52979. * @param dispose if the removed element should be disposed (default: false)
  52980. */
  52981. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52982. }
  52983. }
  52984. declare module "babylonjs/Shaders/layer.fragment" {
  52985. /** @hidden */
  52986. export var layerPixelShader: {
  52987. name: string;
  52988. shader: string;
  52989. };
  52990. }
  52991. declare module "babylonjs/Shaders/layer.vertex" {
  52992. /** @hidden */
  52993. export var layerVertexShader: {
  52994. name: string;
  52995. shader: string;
  52996. };
  52997. }
  52998. declare module "babylonjs/Layers/layer" {
  52999. import { Observable } from "babylonjs/Misc/observable";
  53000. import { Nullable } from "babylonjs/types";
  53001. import { Scene } from "babylonjs/scene";
  53002. import { Vector2 } from "babylonjs/Maths/math.vector";
  53003. import { Color4 } from "babylonjs/Maths/math.color";
  53004. import { Texture } from "babylonjs/Materials/Textures/texture";
  53005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53006. import "babylonjs/Shaders/layer.fragment";
  53007. import "babylonjs/Shaders/layer.vertex";
  53008. /**
  53009. * This represents a full screen 2d layer.
  53010. * This can be useful to display a picture in the background of your scene for instance.
  53011. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53012. */
  53013. export class Layer {
  53014. /**
  53015. * Define the name of the layer.
  53016. */
  53017. name: string;
  53018. /**
  53019. * Define the texture the layer should display.
  53020. */
  53021. texture: Nullable<Texture>;
  53022. /**
  53023. * Is the layer in background or foreground.
  53024. */
  53025. isBackground: boolean;
  53026. /**
  53027. * Define the color of the layer (instead of texture).
  53028. */
  53029. color: Color4;
  53030. /**
  53031. * Define the scale of the layer in order to zoom in out of the texture.
  53032. */
  53033. scale: Vector2;
  53034. /**
  53035. * Define an offset for the layer in order to shift the texture.
  53036. */
  53037. offset: Vector2;
  53038. /**
  53039. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53040. */
  53041. alphaBlendingMode: number;
  53042. /**
  53043. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53044. * Alpha test will not mix with the background color in case of transparency.
  53045. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53046. */
  53047. alphaTest: boolean;
  53048. /**
  53049. * Define a mask to restrict the layer to only some of the scene cameras.
  53050. */
  53051. layerMask: number;
  53052. /**
  53053. * Define the list of render target the layer is visible into.
  53054. */
  53055. renderTargetTextures: RenderTargetTexture[];
  53056. /**
  53057. * Define if the layer is only used in renderTarget or if it also
  53058. * renders in the main frame buffer of the canvas.
  53059. */
  53060. renderOnlyInRenderTargetTextures: boolean;
  53061. private _scene;
  53062. private _vertexBuffers;
  53063. private _indexBuffer;
  53064. private _effect;
  53065. private _alphaTestEffect;
  53066. /**
  53067. * An event triggered when the layer is disposed.
  53068. */
  53069. onDisposeObservable: Observable<Layer>;
  53070. private _onDisposeObserver;
  53071. /**
  53072. * Back compatibility with callback before the onDisposeObservable existed.
  53073. * The set callback will be triggered when the layer has been disposed.
  53074. */
  53075. onDispose: () => void;
  53076. /**
  53077. * An event triggered before rendering the scene
  53078. */
  53079. onBeforeRenderObservable: Observable<Layer>;
  53080. private _onBeforeRenderObserver;
  53081. /**
  53082. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53083. * The set callback will be triggered just before rendering the layer.
  53084. */
  53085. onBeforeRender: () => void;
  53086. /**
  53087. * An event triggered after rendering the scene
  53088. */
  53089. onAfterRenderObservable: Observable<Layer>;
  53090. private _onAfterRenderObserver;
  53091. /**
  53092. * Back compatibility with callback before the onAfterRenderObservable existed.
  53093. * The set callback will be triggered just after rendering the layer.
  53094. */
  53095. onAfterRender: () => void;
  53096. /**
  53097. * Instantiates a new layer.
  53098. * This represents a full screen 2d layer.
  53099. * This can be useful to display a picture in the background of your scene for instance.
  53100. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53101. * @param name Define the name of the layer in the scene
  53102. * @param imgUrl Define the url of the texture to display in the layer
  53103. * @param scene Define the scene the layer belongs to
  53104. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53105. * @param color Defines a color for the layer
  53106. */
  53107. constructor(
  53108. /**
  53109. * Define the name of the layer.
  53110. */
  53111. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53112. private _createIndexBuffer;
  53113. /** @hidden */
  53114. _rebuild(): void;
  53115. /**
  53116. * Renders the layer in the scene.
  53117. */
  53118. render(): void;
  53119. /**
  53120. * Disposes and releases the associated ressources.
  53121. */
  53122. dispose(): void;
  53123. }
  53124. }
  53125. declare module "babylonjs/Layers/index" {
  53126. export * from "babylonjs/Layers/effectLayer";
  53127. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53128. export * from "babylonjs/Layers/glowLayer";
  53129. export * from "babylonjs/Layers/highlightLayer";
  53130. export * from "babylonjs/Layers/layer";
  53131. export * from "babylonjs/Layers/layerSceneComponent";
  53132. }
  53133. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53134. /** @hidden */
  53135. export var lensFlarePixelShader: {
  53136. name: string;
  53137. shader: string;
  53138. };
  53139. }
  53140. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53141. /** @hidden */
  53142. export var lensFlareVertexShader: {
  53143. name: string;
  53144. shader: string;
  53145. };
  53146. }
  53147. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53148. import { Scene } from "babylonjs/scene";
  53149. import { Vector3 } from "babylonjs/Maths/math.vector";
  53150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53151. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53152. import "babylonjs/Shaders/lensFlare.fragment";
  53153. import "babylonjs/Shaders/lensFlare.vertex";
  53154. import { Viewport } from "babylonjs/Maths/math.viewport";
  53155. /**
  53156. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53157. * It is usually composed of several `lensFlare`.
  53158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53159. */
  53160. export class LensFlareSystem {
  53161. /**
  53162. * Define the name of the lens flare system
  53163. */
  53164. name: string;
  53165. /**
  53166. * List of lens flares used in this system.
  53167. */
  53168. lensFlares: LensFlare[];
  53169. /**
  53170. * Define a limit from the border the lens flare can be visible.
  53171. */
  53172. borderLimit: number;
  53173. /**
  53174. * Define a viewport border we do not want to see the lens flare in.
  53175. */
  53176. viewportBorder: number;
  53177. /**
  53178. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53179. */
  53180. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53181. /**
  53182. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53183. */
  53184. layerMask: number;
  53185. /**
  53186. * Define the id of the lens flare system in the scene.
  53187. * (equal to name by default)
  53188. */
  53189. id: string;
  53190. private _scene;
  53191. private _emitter;
  53192. private _vertexBuffers;
  53193. private _indexBuffer;
  53194. private _effect;
  53195. private _positionX;
  53196. private _positionY;
  53197. private _isEnabled;
  53198. /** @hidden */
  53199. static _SceneComponentInitialization: (scene: Scene) => void;
  53200. /**
  53201. * Instantiates a lens flare system.
  53202. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53203. * It is usually composed of several `lensFlare`.
  53204. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53205. * @param name Define the name of the lens flare system in the scene
  53206. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53207. * @param scene Define the scene the lens flare system belongs to
  53208. */
  53209. constructor(
  53210. /**
  53211. * Define the name of the lens flare system
  53212. */
  53213. name: string, emitter: any, scene: Scene);
  53214. /**
  53215. * Define if the lens flare system is enabled.
  53216. */
  53217. isEnabled: boolean;
  53218. /**
  53219. * Get the scene the effects belongs to.
  53220. * @returns the scene holding the lens flare system
  53221. */
  53222. getScene(): Scene;
  53223. /**
  53224. * Get the emitter of the lens flare system.
  53225. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53226. * @returns the emitter of the lens flare system
  53227. */
  53228. getEmitter(): any;
  53229. /**
  53230. * Set the emitter of the lens flare system.
  53231. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53232. * @param newEmitter Define the new emitter of the system
  53233. */
  53234. setEmitter(newEmitter: any): void;
  53235. /**
  53236. * Get the lens flare system emitter position.
  53237. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53238. * @returns the position
  53239. */
  53240. getEmitterPosition(): Vector3;
  53241. /**
  53242. * @hidden
  53243. */
  53244. computeEffectivePosition(globalViewport: Viewport): boolean;
  53245. /** @hidden */
  53246. _isVisible(): boolean;
  53247. /**
  53248. * @hidden
  53249. */
  53250. render(): boolean;
  53251. /**
  53252. * Dispose and release the lens flare with its associated resources.
  53253. */
  53254. dispose(): void;
  53255. /**
  53256. * Parse a lens flare system from a JSON repressentation
  53257. * @param parsedLensFlareSystem Define the JSON to parse
  53258. * @param scene Define the scene the parsed system should be instantiated in
  53259. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53260. * @returns the parsed system
  53261. */
  53262. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53263. /**
  53264. * Serialize the current Lens Flare System into a JSON representation.
  53265. * @returns the serialized JSON
  53266. */
  53267. serialize(): any;
  53268. }
  53269. }
  53270. declare module "babylonjs/LensFlares/lensFlare" {
  53271. import { Nullable } from "babylonjs/types";
  53272. import { Color3 } from "babylonjs/Maths/math.color";
  53273. import { Texture } from "babylonjs/Materials/Textures/texture";
  53274. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53275. /**
  53276. * This represents one of the lens effect in a `lensFlareSystem`.
  53277. * It controls one of the indiviual texture used in the effect.
  53278. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53279. */
  53280. export class LensFlare {
  53281. /**
  53282. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53283. */
  53284. size: number;
  53285. /**
  53286. * 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.
  53287. */
  53288. position: number;
  53289. /**
  53290. * Define the lens color.
  53291. */
  53292. color: Color3;
  53293. /**
  53294. * Define the lens texture.
  53295. */
  53296. texture: Nullable<Texture>;
  53297. /**
  53298. * Define the alpha mode to render this particular lens.
  53299. */
  53300. alphaMode: number;
  53301. private _system;
  53302. /**
  53303. * Creates a new Lens Flare.
  53304. * This represents one of the lens effect in a `lensFlareSystem`.
  53305. * It controls one of the indiviual texture used in the effect.
  53306. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53307. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53308. * @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.
  53309. * @param color Define the lens color
  53310. * @param imgUrl Define the lens texture url
  53311. * @param system Define the `lensFlareSystem` this flare is part of
  53312. * @returns The newly created Lens Flare
  53313. */
  53314. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53315. /**
  53316. * Instantiates a new Lens Flare.
  53317. * This represents one of the lens effect in a `lensFlareSystem`.
  53318. * It controls one of the indiviual texture used in the effect.
  53319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53320. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53321. * @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.
  53322. * @param color Define the lens color
  53323. * @param imgUrl Define the lens texture url
  53324. * @param system Define the `lensFlareSystem` this flare is part of
  53325. */
  53326. constructor(
  53327. /**
  53328. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53329. */
  53330. size: number,
  53331. /**
  53332. * 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.
  53333. */
  53334. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53335. /**
  53336. * Dispose and release the lens flare with its associated resources.
  53337. */
  53338. dispose(): void;
  53339. }
  53340. }
  53341. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53342. import { Nullable } from "babylonjs/types";
  53343. import { Scene } from "babylonjs/scene";
  53344. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53345. import { AbstractScene } from "babylonjs/abstractScene";
  53346. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53347. module "babylonjs/abstractScene" {
  53348. interface AbstractScene {
  53349. /**
  53350. * The list of lens flare system added to the scene
  53351. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53352. */
  53353. lensFlareSystems: Array<LensFlareSystem>;
  53354. /**
  53355. * Removes the given lens flare system from this scene.
  53356. * @param toRemove The lens flare system to remove
  53357. * @returns The index of the removed lens flare system
  53358. */
  53359. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53360. /**
  53361. * Adds the given lens flare system to this scene
  53362. * @param newLensFlareSystem The lens flare system to add
  53363. */
  53364. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53365. /**
  53366. * Gets a lens flare system using its name
  53367. * @param name defines the name to look for
  53368. * @returns the lens flare system or null if not found
  53369. */
  53370. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53371. /**
  53372. * Gets a lens flare system using its id
  53373. * @param id defines the id to look for
  53374. * @returns the lens flare system or null if not found
  53375. */
  53376. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53377. }
  53378. }
  53379. /**
  53380. * Defines the lens flare scene component responsible to manage any lens flares
  53381. * in a given scene.
  53382. */
  53383. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53384. /**
  53385. * The component name helpfull to identify the component in the list of scene components.
  53386. */
  53387. readonly name: string;
  53388. /**
  53389. * The scene the component belongs to.
  53390. */
  53391. scene: Scene;
  53392. /**
  53393. * Creates a new instance of the component for the given scene
  53394. * @param scene Defines the scene to register the component in
  53395. */
  53396. constructor(scene: Scene);
  53397. /**
  53398. * Registers the component in a given scene
  53399. */
  53400. register(): void;
  53401. /**
  53402. * Rebuilds the elements related to this component in case of
  53403. * context lost for instance.
  53404. */
  53405. rebuild(): void;
  53406. /**
  53407. * Adds all the elements from the container to the scene
  53408. * @param container the container holding the elements
  53409. */
  53410. addFromContainer(container: AbstractScene): void;
  53411. /**
  53412. * Removes all the elements in the container from the scene
  53413. * @param container contains the elements to remove
  53414. * @param dispose if the removed element should be disposed (default: false)
  53415. */
  53416. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53417. /**
  53418. * Serializes the component data to the specified json object
  53419. * @param serializationObject The object to serialize to
  53420. */
  53421. serialize(serializationObject: any): void;
  53422. /**
  53423. * Disposes the component and the associated ressources.
  53424. */
  53425. dispose(): void;
  53426. private _draw;
  53427. }
  53428. }
  53429. declare module "babylonjs/LensFlares/index" {
  53430. export * from "babylonjs/LensFlares/lensFlare";
  53431. export * from "babylonjs/LensFlares/lensFlareSystem";
  53432. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53433. }
  53434. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53435. import { Scene } from "babylonjs/scene";
  53436. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53437. import { AbstractScene } from "babylonjs/abstractScene";
  53438. /**
  53439. * Defines the shadow generator component responsible to manage any shadow generators
  53440. * in a given scene.
  53441. */
  53442. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53443. /**
  53444. * The component name helpfull to identify the component in the list of scene components.
  53445. */
  53446. readonly name: string;
  53447. /**
  53448. * The scene the component belongs to.
  53449. */
  53450. scene: Scene;
  53451. /**
  53452. * Creates a new instance of the component for the given scene
  53453. * @param scene Defines the scene to register the component in
  53454. */
  53455. constructor(scene: Scene);
  53456. /**
  53457. * Registers the component in a given scene
  53458. */
  53459. register(): void;
  53460. /**
  53461. * Rebuilds the elements related to this component in case of
  53462. * context lost for instance.
  53463. */
  53464. rebuild(): void;
  53465. /**
  53466. * Serializes the component data to the specified json object
  53467. * @param serializationObject The object to serialize to
  53468. */
  53469. serialize(serializationObject: any): void;
  53470. /**
  53471. * Adds all the elements from the container to the scene
  53472. * @param container the container holding the elements
  53473. */
  53474. addFromContainer(container: AbstractScene): void;
  53475. /**
  53476. * Removes all the elements in the container from the scene
  53477. * @param container contains the elements to remove
  53478. * @param dispose if the removed element should be disposed (default: false)
  53479. */
  53480. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53481. /**
  53482. * Rebuilds the elements related to this component in case of
  53483. * context lost for instance.
  53484. */
  53485. dispose(): void;
  53486. private _gatherRenderTargets;
  53487. }
  53488. }
  53489. declare module "babylonjs/Lights/Shadows/index" {
  53490. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53491. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53492. }
  53493. declare module "babylonjs/Lights/pointLight" {
  53494. import { Scene } from "babylonjs/scene";
  53495. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53497. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53498. import { Effect } from "babylonjs/Materials/effect";
  53499. /**
  53500. * A point light is a light defined by an unique point in world space.
  53501. * The light is emitted in every direction from this point.
  53502. * A good example of a point light is a standard light bulb.
  53503. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53504. */
  53505. export class PointLight extends ShadowLight {
  53506. private _shadowAngle;
  53507. /**
  53508. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53509. * This specifies what angle the shadow will use to be created.
  53510. *
  53511. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53512. */
  53513. /**
  53514. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53515. * This specifies what angle the shadow will use to be created.
  53516. *
  53517. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53518. */
  53519. shadowAngle: number;
  53520. /**
  53521. * Gets the direction if it has been set.
  53522. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53523. */
  53524. /**
  53525. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53526. */
  53527. direction: Vector3;
  53528. /**
  53529. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53530. * A PointLight emits the light in every direction.
  53531. * It can cast shadows.
  53532. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53533. * ```javascript
  53534. * var pointLight = new PointLight("pl", camera.position, scene);
  53535. * ```
  53536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53537. * @param name The light friendly name
  53538. * @param position The position of the point light in the scene
  53539. * @param scene The scene the lights belongs to
  53540. */
  53541. constructor(name: string, position: Vector3, scene: Scene);
  53542. /**
  53543. * Returns the string "PointLight"
  53544. * @returns the class name
  53545. */
  53546. getClassName(): string;
  53547. /**
  53548. * Returns the integer 0.
  53549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53550. */
  53551. getTypeID(): number;
  53552. /**
  53553. * Specifies wether or not the shadowmap should be a cube texture.
  53554. * @returns true if the shadowmap needs to be a cube texture.
  53555. */
  53556. needCube(): boolean;
  53557. /**
  53558. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53559. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53560. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53561. */
  53562. getShadowDirection(faceIndex?: number): Vector3;
  53563. /**
  53564. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53565. * - fov = PI / 2
  53566. * - aspect ratio : 1.0
  53567. * - z-near and far equal to the active camera minZ and maxZ.
  53568. * Returns the PointLight.
  53569. */
  53570. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53571. protected _buildUniformLayout(): void;
  53572. /**
  53573. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53574. * @param effect The effect to update
  53575. * @param lightIndex The index of the light in the effect to update
  53576. * @returns The point light
  53577. */
  53578. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53580. /**
  53581. * Prepares the list of defines specific to the light type.
  53582. * @param defines the list of defines
  53583. * @param lightIndex defines the index of the light for the effect
  53584. */
  53585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53586. }
  53587. }
  53588. declare module "babylonjs/Lights/index" {
  53589. export * from "babylonjs/Lights/light";
  53590. export * from "babylonjs/Lights/shadowLight";
  53591. export * from "babylonjs/Lights/Shadows/index";
  53592. export * from "babylonjs/Lights/directionalLight";
  53593. export * from "babylonjs/Lights/hemisphericLight";
  53594. export * from "babylonjs/Lights/pointLight";
  53595. export * from "babylonjs/Lights/spotLight";
  53596. }
  53597. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53598. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53599. /**
  53600. * Header information of HDR texture files.
  53601. */
  53602. export interface HDRInfo {
  53603. /**
  53604. * The height of the texture in pixels.
  53605. */
  53606. height: number;
  53607. /**
  53608. * The width of the texture in pixels.
  53609. */
  53610. width: number;
  53611. /**
  53612. * The index of the beginning of the data in the binary file.
  53613. */
  53614. dataPosition: number;
  53615. }
  53616. /**
  53617. * This groups tools to convert HDR texture to native colors array.
  53618. */
  53619. export class HDRTools {
  53620. private static Ldexp;
  53621. private static Rgbe2float;
  53622. private static readStringLine;
  53623. /**
  53624. * Reads header information from an RGBE texture stored in a native array.
  53625. * More information on this format are available here:
  53626. * https://en.wikipedia.org/wiki/RGBE_image_format
  53627. *
  53628. * @param uint8array The binary file stored in native array.
  53629. * @return The header information.
  53630. */
  53631. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53632. /**
  53633. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53634. * This RGBE texture needs to store the information as a panorama.
  53635. *
  53636. * More information on this format are available here:
  53637. * https://en.wikipedia.org/wiki/RGBE_image_format
  53638. *
  53639. * @param buffer The binary file stored in an array buffer.
  53640. * @param size The expected size of the extracted cubemap.
  53641. * @return The Cube Map information.
  53642. */
  53643. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53644. /**
  53645. * Returns the pixels data extracted from an RGBE texture.
  53646. * This pixels will be stored left to right up to down in the R G B order in one array.
  53647. *
  53648. * More information on this format are available here:
  53649. * https://en.wikipedia.org/wiki/RGBE_image_format
  53650. *
  53651. * @param uint8array The binary file stored in an array buffer.
  53652. * @param hdrInfo The header information of the file.
  53653. * @return The pixels data in RGB right to left up to down order.
  53654. */
  53655. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53656. private static RGBE_ReadPixels_RLE;
  53657. }
  53658. }
  53659. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53660. import { Nullable } from "babylonjs/types";
  53661. import { Scene } from "babylonjs/scene";
  53662. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53664. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53665. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53666. /**
  53667. * This represents a texture coming from an HDR input.
  53668. *
  53669. * The only supported format is currently panorama picture stored in RGBE format.
  53670. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53671. */
  53672. export class HDRCubeTexture extends BaseTexture {
  53673. private static _facesMapping;
  53674. private _generateHarmonics;
  53675. private _noMipmap;
  53676. private _textureMatrix;
  53677. private _size;
  53678. private _onLoad;
  53679. private _onError;
  53680. /**
  53681. * The texture URL.
  53682. */
  53683. url: string;
  53684. /**
  53685. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53686. */
  53687. coordinatesMode: number;
  53688. protected _isBlocking: boolean;
  53689. /**
  53690. * Sets wether or not the texture is blocking during loading.
  53691. */
  53692. /**
  53693. * Gets wether or not the texture is blocking during loading.
  53694. */
  53695. isBlocking: boolean;
  53696. protected _rotationY: number;
  53697. /**
  53698. * Sets texture matrix rotation angle around Y axis in radians.
  53699. */
  53700. /**
  53701. * Gets texture matrix rotation angle around Y axis radians.
  53702. */
  53703. rotationY: number;
  53704. /**
  53705. * Gets or sets the center of the bounding box associated with the cube texture
  53706. * It must define where the camera used to render the texture was set
  53707. */
  53708. boundingBoxPosition: Vector3;
  53709. private _boundingBoxSize;
  53710. /**
  53711. * Gets or sets the size of the bounding box associated with the cube texture
  53712. * When defined, the cubemap will switch to local mode
  53713. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53714. * @example https://www.babylonjs-playground.com/#RNASML
  53715. */
  53716. boundingBoxSize: Vector3;
  53717. /**
  53718. * Instantiates an HDRTexture from the following parameters.
  53719. *
  53720. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53721. * @param scene The scene the texture will be used in
  53722. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53723. * @param noMipmap Forces to not generate the mipmap if true
  53724. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53725. * @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)
  53726. * @param reserved Reserved flag for internal use.
  53727. */
  53728. 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>);
  53729. /**
  53730. * Get the current class name of the texture useful for serialization or dynamic coding.
  53731. * @returns "HDRCubeTexture"
  53732. */
  53733. getClassName(): string;
  53734. /**
  53735. * Occurs when the file is raw .hdr file.
  53736. */
  53737. private loadTexture;
  53738. clone(): HDRCubeTexture;
  53739. delayLoad(): void;
  53740. /**
  53741. * Get the texture reflection matrix used to rotate/transform the reflection.
  53742. * @returns the reflection matrix
  53743. */
  53744. getReflectionTextureMatrix(): Matrix;
  53745. /**
  53746. * Set the texture reflection matrix used to rotate/transform the reflection.
  53747. * @param value Define the reflection matrix to set
  53748. */
  53749. setReflectionTextureMatrix(value: Matrix): void;
  53750. /**
  53751. * Parses a JSON representation of an HDR Texture in order to create the texture
  53752. * @param parsedTexture Define the JSON representation
  53753. * @param scene Define the scene the texture should be created in
  53754. * @param rootUrl Define the root url in case we need to load relative dependencies
  53755. * @returns the newly created texture after parsing
  53756. */
  53757. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53758. serialize(): any;
  53759. }
  53760. }
  53761. declare module "babylonjs/Physics/physicsEngine" {
  53762. import { Nullable } from "babylonjs/types";
  53763. import { Vector3 } from "babylonjs/Maths/math.vector";
  53764. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53765. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53766. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53767. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53768. /**
  53769. * Class used to control physics engine
  53770. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53771. */
  53772. export class PhysicsEngine implements IPhysicsEngine {
  53773. private _physicsPlugin;
  53774. /**
  53775. * Global value used to control the smallest number supported by the simulation
  53776. */
  53777. static Epsilon: number;
  53778. private _impostors;
  53779. private _joints;
  53780. /**
  53781. * Gets the gravity vector used by the simulation
  53782. */
  53783. gravity: Vector3;
  53784. /**
  53785. * Factory used to create the default physics plugin.
  53786. * @returns The default physics plugin
  53787. */
  53788. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53789. /**
  53790. * Creates a new Physics Engine
  53791. * @param gravity defines the gravity vector used by the simulation
  53792. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53793. */
  53794. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53795. /**
  53796. * Sets the gravity vector used by the simulation
  53797. * @param gravity defines the gravity vector to use
  53798. */
  53799. setGravity(gravity: Vector3): void;
  53800. /**
  53801. * Set the time step of the physics engine.
  53802. * Default is 1/60.
  53803. * To slow it down, enter 1/600 for example.
  53804. * To speed it up, 1/30
  53805. * @param newTimeStep defines the new timestep to apply to this world.
  53806. */
  53807. setTimeStep(newTimeStep?: number): void;
  53808. /**
  53809. * Get the time step of the physics engine.
  53810. * @returns the current time step
  53811. */
  53812. getTimeStep(): number;
  53813. /**
  53814. * Release all resources
  53815. */
  53816. dispose(): void;
  53817. /**
  53818. * Gets the name of the current physics plugin
  53819. * @returns the name of the plugin
  53820. */
  53821. getPhysicsPluginName(): string;
  53822. /**
  53823. * Adding a new impostor for the impostor tracking.
  53824. * This will be done by the impostor itself.
  53825. * @param impostor the impostor to add
  53826. */
  53827. addImpostor(impostor: PhysicsImpostor): void;
  53828. /**
  53829. * Remove an impostor from the engine.
  53830. * This impostor and its mesh will not longer be updated by the physics engine.
  53831. * @param impostor the impostor to remove
  53832. */
  53833. removeImpostor(impostor: PhysicsImpostor): void;
  53834. /**
  53835. * Add a joint to the physics engine
  53836. * @param mainImpostor defines the main impostor to which the joint is added.
  53837. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53838. * @param joint defines the joint that will connect both impostors.
  53839. */
  53840. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53841. /**
  53842. * Removes a joint from the simulation
  53843. * @param mainImpostor defines the impostor used with the joint
  53844. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53845. * @param joint defines the joint to remove
  53846. */
  53847. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53848. /**
  53849. * Called by the scene. No need to call it.
  53850. * @param delta defines the timespam between frames
  53851. */
  53852. _step(delta: number): void;
  53853. /**
  53854. * Gets the current plugin used to run the simulation
  53855. * @returns current plugin
  53856. */
  53857. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53858. /**
  53859. * Gets the list of physic impostors
  53860. * @returns an array of PhysicsImpostor
  53861. */
  53862. getImpostors(): Array<PhysicsImpostor>;
  53863. /**
  53864. * Gets the impostor for a physics enabled object
  53865. * @param object defines the object impersonated by the impostor
  53866. * @returns the PhysicsImpostor or null if not found
  53867. */
  53868. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53869. /**
  53870. * Gets the impostor for a physics body object
  53871. * @param body defines physics body used by the impostor
  53872. * @returns the PhysicsImpostor or null if not found
  53873. */
  53874. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53875. /**
  53876. * Does a raycast in the physics world
  53877. * @param from when should the ray start?
  53878. * @param to when should the ray end?
  53879. * @returns PhysicsRaycastResult
  53880. */
  53881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53882. }
  53883. }
  53884. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53885. import { Nullable } from "babylonjs/types";
  53886. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53888. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53889. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53890. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53891. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53892. /** @hidden */
  53893. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53894. private _useDeltaForWorldStep;
  53895. world: any;
  53896. name: string;
  53897. private _physicsMaterials;
  53898. private _fixedTimeStep;
  53899. private _cannonRaycastResult;
  53900. private _raycastResult;
  53901. private _physicsBodysToRemoveAfterStep;
  53902. BJSCANNON: any;
  53903. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53904. setGravity(gravity: Vector3): void;
  53905. setTimeStep(timeStep: number): void;
  53906. getTimeStep(): number;
  53907. executeStep(delta: number): void;
  53908. private _removeMarkedPhysicsBodiesFromWorld;
  53909. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53910. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53911. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53912. private _processChildMeshes;
  53913. removePhysicsBody(impostor: PhysicsImpostor): void;
  53914. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53915. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53916. private _addMaterial;
  53917. private _checkWithEpsilon;
  53918. private _createShape;
  53919. private _createHeightmap;
  53920. private _minus90X;
  53921. private _plus90X;
  53922. private _tmpPosition;
  53923. private _tmpDeltaPosition;
  53924. private _tmpUnityRotation;
  53925. private _updatePhysicsBodyTransformation;
  53926. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53927. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53928. isSupported(): boolean;
  53929. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53930. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53931. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53932. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53933. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53934. getBodyMass(impostor: PhysicsImpostor): number;
  53935. getBodyFriction(impostor: PhysicsImpostor): number;
  53936. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53937. getBodyRestitution(impostor: PhysicsImpostor): number;
  53938. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53939. sleepBody(impostor: PhysicsImpostor): void;
  53940. wakeUpBody(impostor: PhysicsImpostor): void;
  53941. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53942. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53943. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53945. getRadius(impostor: PhysicsImpostor): number;
  53946. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53947. dispose(): void;
  53948. private _extendNamespace;
  53949. /**
  53950. * Does a raycast in the physics world
  53951. * @param from when should the ray start?
  53952. * @param to when should the ray end?
  53953. * @returns PhysicsRaycastResult
  53954. */
  53955. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53956. }
  53957. }
  53958. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53959. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53960. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53961. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53963. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53964. import { Nullable } from "babylonjs/types";
  53965. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53966. /** @hidden */
  53967. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53968. world: any;
  53969. name: string;
  53970. BJSOIMO: any;
  53971. private _raycastResult;
  53972. constructor(iterations?: number, oimoInjection?: any);
  53973. setGravity(gravity: Vector3): void;
  53974. setTimeStep(timeStep: number): void;
  53975. getTimeStep(): number;
  53976. private _tmpImpostorsArray;
  53977. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53978. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53979. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53980. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53981. private _tmpPositionVector;
  53982. removePhysicsBody(impostor: PhysicsImpostor): void;
  53983. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53984. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53985. isSupported(): boolean;
  53986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53993. getBodyMass(impostor: PhysicsImpostor): number;
  53994. getBodyFriction(impostor: PhysicsImpostor): number;
  53995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53996. getBodyRestitution(impostor: PhysicsImpostor): number;
  53997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53998. sleepBody(impostor: PhysicsImpostor): void;
  53999. wakeUpBody(impostor: PhysicsImpostor): void;
  54000. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54001. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54002. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54004. getRadius(impostor: PhysicsImpostor): number;
  54005. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54006. dispose(): void;
  54007. /**
  54008. * Does a raycast in the physics world
  54009. * @param from when should the ray start?
  54010. * @param to when should the ray end?
  54011. * @returns PhysicsRaycastResult
  54012. */
  54013. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54014. }
  54015. }
  54016. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54017. import { Nullable } from "babylonjs/types";
  54018. import { Scene } from "babylonjs/scene";
  54019. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54020. import { Color4 } from "babylonjs/Maths/math.color";
  54021. import { Mesh } from "babylonjs/Meshes/mesh";
  54022. /**
  54023. * Class containing static functions to help procedurally build meshes
  54024. */
  54025. export class RibbonBuilder {
  54026. /**
  54027. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54028. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54029. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54030. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54031. * * 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
  54032. * * 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
  54033. * * 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
  54034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54037. * * 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
  54038. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54039. * * 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
  54040. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54042. * @param name defines the name of the mesh
  54043. * @param options defines the options used to create the mesh
  54044. * @param scene defines the hosting scene
  54045. * @returns the ribbon mesh
  54046. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54048. */
  54049. static CreateRibbon(name: string, options: {
  54050. pathArray: Vector3[][];
  54051. closeArray?: boolean;
  54052. closePath?: boolean;
  54053. offset?: number;
  54054. updatable?: boolean;
  54055. sideOrientation?: number;
  54056. frontUVs?: Vector4;
  54057. backUVs?: Vector4;
  54058. instance?: Mesh;
  54059. invertUV?: boolean;
  54060. uvs?: Vector2[];
  54061. colors?: Color4[];
  54062. }, scene?: Nullable<Scene>): Mesh;
  54063. }
  54064. }
  54065. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54066. import { Nullable } from "babylonjs/types";
  54067. import { Scene } from "babylonjs/scene";
  54068. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54069. import { Mesh } from "babylonjs/Meshes/mesh";
  54070. /**
  54071. * Class containing static functions to help procedurally build meshes
  54072. */
  54073. export class ShapeBuilder {
  54074. /**
  54075. * 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.
  54076. * * 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.
  54077. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54078. * * 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.
  54079. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54080. * * 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
  54081. * * 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
  54082. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54087. * @param name defines the name of the mesh
  54088. * @param options defines the options used to create the mesh
  54089. * @param scene defines the hosting scene
  54090. * @returns the extruded shape mesh
  54091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54093. */
  54094. static ExtrudeShape(name: string, options: {
  54095. shape: Vector3[];
  54096. path: Vector3[];
  54097. scale?: number;
  54098. rotation?: number;
  54099. cap?: number;
  54100. updatable?: boolean;
  54101. sideOrientation?: number;
  54102. frontUVs?: Vector4;
  54103. backUVs?: Vector4;
  54104. instance?: Mesh;
  54105. invertUV?: boolean;
  54106. }, scene?: Nullable<Scene>): Mesh;
  54107. /**
  54108. * Creates an custom extruded shape mesh.
  54109. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54110. * * 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.
  54111. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54112. * * 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
  54113. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54114. * * 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
  54115. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54116. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54117. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54118. * * 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
  54119. * * 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
  54120. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54123. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54125. * @param name defines the name of the mesh
  54126. * @param options defines the options used to create the mesh
  54127. * @param scene defines the hosting scene
  54128. * @returns the custom extruded shape mesh
  54129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54132. */
  54133. static ExtrudeShapeCustom(name: string, options: {
  54134. shape: Vector3[];
  54135. path: Vector3[];
  54136. scaleFunction?: any;
  54137. rotationFunction?: any;
  54138. ribbonCloseArray?: boolean;
  54139. ribbonClosePath?: boolean;
  54140. cap?: number;
  54141. updatable?: boolean;
  54142. sideOrientation?: number;
  54143. frontUVs?: Vector4;
  54144. backUVs?: Vector4;
  54145. instance?: Mesh;
  54146. invertUV?: boolean;
  54147. }, scene?: Nullable<Scene>): Mesh;
  54148. private static _ExtrudeShapeGeneric;
  54149. }
  54150. }
  54151. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54152. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54153. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54154. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54155. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54156. import { Nullable } from "babylonjs/types";
  54157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54158. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54159. /**
  54160. * AmmoJS Physics plugin
  54161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54162. * @see https://github.com/kripken/ammo.js/
  54163. */
  54164. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54165. private _useDeltaForWorldStep;
  54166. /**
  54167. * Reference to the Ammo library
  54168. */
  54169. bjsAMMO: any;
  54170. /**
  54171. * Created ammoJS world which physics bodies are added to
  54172. */
  54173. world: any;
  54174. /**
  54175. * Name of the plugin
  54176. */
  54177. name: string;
  54178. private _timeStep;
  54179. private _fixedTimeStep;
  54180. private _maxSteps;
  54181. private _tmpQuaternion;
  54182. private _tmpAmmoTransform;
  54183. private _tmpAmmoQuaternion;
  54184. private _tmpAmmoConcreteContactResultCallback;
  54185. private _collisionConfiguration;
  54186. private _dispatcher;
  54187. private _overlappingPairCache;
  54188. private _solver;
  54189. private _softBodySolver;
  54190. private _tmpAmmoVectorA;
  54191. private _tmpAmmoVectorB;
  54192. private _tmpAmmoVectorC;
  54193. private _tmpAmmoVectorD;
  54194. private _tmpContactCallbackResult;
  54195. private _tmpAmmoVectorRCA;
  54196. private _tmpAmmoVectorRCB;
  54197. private _raycastResult;
  54198. private static readonly DISABLE_COLLISION_FLAG;
  54199. private static readonly KINEMATIC_FLAG;
  54200. private static readonly DISABLE_DEACTIVATION_FLAG;
  54201. /**
  54202. * Initializes the ammoJS plugin
  54203. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54204. * @param ammoInjection can be used to inject your own ammo reference
  54205. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54206. */
  54207. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54208. /**
  54209. * Sets the gravity of the physics world (m/(s^2))
  54210. * @param gravity Gravity to set
  54211. */
  54212. setGravity(gravity: Vector3): void;
  54213. /**
  54214. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54215. * @param timeStep timestep to use in seconds
  54216. */
  54217. setTimeStep(timeStep: number): void;
  54218. /**
  54219. * 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)
  54220. * @param fixedTimeStep fixedTimeStep to use in seconds
  54221. */
  54222. setFixedTimeStep(fixedTimeStep: number): void;
  54223. /**
  54224. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54225. * @param maxSteps the maximum number of steps by the physics engine per frame
  54226. */
  54227. setMaxSteps(maxSteps: number): void;
  54228. /**
  54229. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54230. * @returns the current timestep in seconds
  54231. */
  54232. getTimeStep(): number;
  54233. private _isImpostorInContact;
  54234. private _isImpostorPairInContact;
  54235. private _stepSimulation;
  54236. /**
  54237. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54238. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54239. * After the step the babylon meshes are set to the position of the physics imposters
  54240. * @param delta amount of time to step forward
  54241. * @param impostors array of imposters to update before/after the step
  54242. */
  54243. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54244. /**
  54245. * Update babylon mesh to match physics world object
  54246. * @param impostor imposter to match
  54247. */
  54248. private _afterSoftStep;
  54249. /**
  54250. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54251. * @param impostor imposter to match
  54252. */
  54253. private _ropeStep;
  54254. /**
  54255. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54256. * @param impostor imposter to match
  54257. */
  54258. private _softbodyOrClothStep;
  54259. private _tmpVector;
  54260. private _tmpMatrix;
  54261. /**
  54262. * Applies an impulse on the imposter
  54263. * @param impostor imposter to apply impulse to
  54264. * @param force amount of force to be applied to the imposter
  54265. * @param contactPoint the location to apply the impulse on the imposter
  54266. */
  54267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54268. /**
  54269. * Applies a force on the imposter
  54270. * @param impostor imposter to apply force
  54271. * @param force amount of force to be applied to the imposter
  54272. * @param contactPoint the location to apply the force on the imposter
  54273. */
  54274. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54275. /**
  54276. * Creates a physics body using the plugin
  54277. * @param impostor the imposter to create the physics body on
  54278. */
  54279. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54280. /**
  54281. * Removes the physics body from the imposter and disposes of the body's memory
  54282. * @param impostor imposter to remove the physics body from
  54283. */
  54284. removePhysicsBody(impostor: PhysicsImpostor): void;
  54285. /**
  54286. * Generates a joint
  54287. * @param impostorJoint the imposter joint to create the joint with
  54288. */
  54289. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54290. /**
  54291. * Removes a joint
  54292. * @param impostorJoint the imposter joint to remove the joint from
  54293. */
  54294. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54295. private _addMeshVerts;
  54296. /**
  54297. * Initialise the soft body vertices to match its object's (mesh) vertices
  54298. * Softbody vertices (nodes) are in world space and to match this
  54299. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54300. * @param impostor to create the softbody for
  54301. */
  54302. private _softVertexData;
  54303. /**
  54304. * Create an impostor's soft body
  54305. * @param impostor to create the softbody for
  54306. */
  54307. private _createSoftbody;
  54308. /**
  54309. * Create cloth for an impostor
  54310. * @param impostor to create the softbody for
  54311. */
  54312. private _createCloth;
  54313. /**
  54314. * Create rope for an impostor
  54315. * @param impostor to create the softbody for
  54316. */
  54317. private _createRope;
  54318. private _addHullVerts;
  54319. private _createShape;
  54320. /**
  54321. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54322. * @param impostor imposter containing the physics body and babylon object
  54323. */
  54324. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54325. /**
  54326. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54327. * @param impostor imposter containing the physics body and babylon object
  54328. * @param newPosition new position
  54329. * @param newRotation new rotation
  54330. */
  54331. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54332. /**
  54333. * If this plugin is supported
  54334. * @returns true if its supported
  54335. */
  54336. isSupported(): boolean;
  54337. /**
  54338. * Sets the linear velocity of the physics body
  54339. * @param impostor imposter to set the velocity on
  54340. * @param velocity velocity to set
  54341. */
  54342. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54343. /**
  54344. * Sets the angular velocity of the physics body
  54345. * @param impostor imposter to set the velocity on
  54346. * @param velocity velocity to set
  54347. */
  54348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54349. /**
  54350. * gets the linear velocity
  54351. * @param impostor imposter to get linear velocity from
  54352. * @returns linear velocity
  54353. */
  54354. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54355. /**
  54356. * gets the angular velocity
  54357. * @param impostor imposter to get angular velocity from
  54358. * @returns angular velocity
  54359. */
  54360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54361. /**
  54362. * Sets the mass of physics body
  54363. * @param impostor imposter to set the mass on
  54364. * @param mass mass to set
  54365. */
  54366. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54367. /**
  54368. * Gets the mass of the physics body
  54369. * @param impostor imposter to get the mass from
  54370. * @returns mass
  54371. */
  54372. getBodyMass(impostor: PhysicsImpostor): number;
  54373. /**
  54374. * Gets friction of the impostor
  54375. * @param impostor impostor to get friction from
  54376. * @returns friction value
  54377. */
  54378. getBodyFriction(impostor: PhysicsImpostor): number;
  54379. /**
  54380. * Sets friction of the impostor
  54381. * @param impostor impostor to set friction on
  54382. * @param friction friction value
  54383. */
  54384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54385. /**
  54386. * Gets restitution of the impostor
  54387. * @param impostor impostor to get restitution from
  54388. * @returns restitution value
  54389. */
  54390. getBodyRestitution(impostor: PhysicsImpostor): number;
  54391. /**
  54392. * Sets resitution of the impostor
  54393. * @param impostor impostor to set resitution on
  54394. * @param restitution resitution value
  54395. */
  54396. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54397. /**
  54398. * Gets pressure inside the impostor
  54399. * @param impostor impostor to get pressure from
  54400. * @returns pressure value
  54401. */
  54402. getBodyPressure(impostor: PhysicsImpostor): number;
  54403. /**
  54404. * Sets pressure inside a soft body impostor
  54405. * Cloth and rope must remain 0 pressure
  54406. * @param impostor impostor to set pressure on
  54407. * @param pressure pressure value
  54408. */
  54409. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54410. /**
  54411. * Gets stiffness of the impostor
  54412. * @param impostor impostor to get stiffness from
  54413. * @returns pressure value
  54414. */
  54415. getBodyStiffness(impostor: PhysicsImpostor): number;
  54416. /**
  54417. * Sets stiffness of the impostor
  54418. * @param impostor impostor to set stiffness on
  54419. * @param stiffness stiffness value from 0 to 1
  54420. */
  54421. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54422. /**
  54423. * Gets velocityIterations of the impostor
  54424. * @param impostor impostor to get velocity iterations from
  54425. * @returns velocityIterations value
  54426. */
  54427. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54428. /**
  54429. * Sets velocityIterations of the impostor
  54430. * @param impostor impostor to set velocity iterations on
  54431. * @param velocityIterations velocityIterations value
  54432. */
  54433. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54434. /**
  54435. * Gets positionIterations of the impostor
  54436. * @param impostor impostor to get position iterations from
  54437. * @returns positionIterations value
  54438. */
  54439. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54440. /**
  54441. * Sets positionIterations of the impostor
  54442. * @param impostor impostor to set position on
  54443. * @param positionIterations positionIterations value
  54444. */
  54445. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54446. /**
  54447. * Append an anchor to a cloth object
  54448. * @param impostor is the cloth impostor to add anchor to
  54449. * @param otherImpostor is the rigid impostor to anchor to
  54450. * @param width ratio across width from 0 to 1
  54451. * @param height ratio up height from 0 to 1
  54452. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54453. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54454. */
  54455. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54456. /**
  54457. * Append an hook to a rope object
  54458. * @param impostor is the rope impostor to add hook to
  54459. * @param otherImpostor is the rigid impostor to hook to
  54460. * @param length ratio along the rope from 0 to 1
  54461. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54462. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54463. */
  54464. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54465. /**
  54466. * Sleeps the physics body and stops it from being active
  54467. * @param impostor impostor to sleep
  54468. */
  54469. sleepBody(impostor: PhysicsImpostor): void;
  54470. /**
  54471. * Activates the physics body
  54472. * @param impostor impostor to activate
  54473. */
  54474. wakeUpBody(impostor: PhysicsImpostor): void;
  54475. /**
  54476. * Updates the distance parameters of the joint
  54477. * @param joint joint to update
  54478. * @param maxDistance maximum distance of the joint
  54479. * @param minDistance minimum distance of the joint
  54480. */
  54481. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54482. /**
  54483. * Sets a motor on the joint
  54484. * @param joint joint to set motor on
  54485. * @param speed speed of the motor
  54486. * @param maxForce maximum force of the motor
  54487. * @param motorIndex index of the motor
  54488. */
  54489. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54490. /**
  54491. * Sets the motors limit
  54492. * @param joint joint to set limit on
  54493. * @param upperLimit upper limit
  54494. * @param lowerLimit lower limit
  54495. */
  54496. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54497. /**
  54498. * Syncs the position and rotation of a mesh with the impostor
  54499. * @param mesh mesh to sync
  54500. * @param impostor impostor to update the mesh with
  54501. */
  54502. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54503. /**
  54504. * Gets the radius of the impostor
  54505. * @param impostor impostor to get radius from
  54506. * @returns the radius
  54507. */
  54508. getRadius(impostor: PhysicsImpostor): number;
  54509. /**
  54510. * Gets the box size of the impostor
  54511. * @param impostor impostor to get box size from
  54512. * @param result the resulting box size
  54513. */
  54514. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54515. /**
  54516. * Disposes of the impostor
  54517. */
  54518. dispose(): void;
  54519. /**
  54520. * Does a raycast in the physics world
  54521. * @param from when should the ray start?
  54522. * @param to when should the ray end?
  54523. * @returns PhysicsRaycastResult
  54524. */
  54525. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54526. }
  54527. }
  54528. declare module "babylonjs/Probes/reflectionProbe" {
  54529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54530. import { Vector3 } from "babylonjs/Maths/math.vector";
  54531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54532. import { Nullable } from "babylonjs/types";
  54533. import { Scene } from "babylonjs/scene";
  54534. module "babylonjs/abstractScene" {
  54535. interface AbstractScene {
  54536. /**
  54537. * The list of reflection probes added to the scene
  54538. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54539. */
  54540. reflectionProbes: Array<ReflectionProbe>;
  54541. /**
  54542. * Removes the given reflection probe from this scene.
  54543. * @param toRemove The reflection probe to remove
  54544. * @returns The index of the removed reflection probe
  54545. */
  54546. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54547. /**
  54548. * Adds the given reflection probe to this scene.
  54549. * @param newReflectionProbe The reflection probe to add
  54550. */
  54551. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54552. }
  54553. }
  54554. /**
  54555. * Class used to generate realtime reflection / refraction cube textures
  54556. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54557. */
  54558. export class ReflectionProbe {
  54559. /** defines the name of the probe */
  54560. name: string;
  54561. private _scene;
  54562. private _renderTargetTexture;
  54563. private _projectionMatrix;
  54564. private _viewMatrix;
  54565. private _target;
  54566. private _add;
  54567. private _attachedMesh;
  54568. private _invertYAxis;
  54569. /** Gets or sets probe position (center of the cube map) */
  54570. position: Vector3;
  54571. /**
  54572. * Creates a new reflection probe
  54573. * @param name defines the name of the probe
  54574. * @param size defines the texture resolution (for each face)
  54575. * @param scene defines the hosting scene
  54576. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54577. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54578. */
  54579. constructor(
  54580. /** defines the name of the probe */
  54581. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54582. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54583. samples: number;
  54584. /** Gets or sets the refresh rate to use (on every frame by default) */
  54585. refreshRate: number;
  54586. /**
  54587. * Gets the hosting scene
  54588. * @returns a Scene
  54589. */
  54590. getScene(): Scene;
  54591. /** Gets the internal CubeTexture used to render to */
  54592. readonly cubeTexture: RenderTargetTexture;
  54593. /** Gets the list of meshes to render */
  54594. readonly renderList: Nullable<AbstractMesh[]>;
  54595. /**
  54596. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54597. * @param mesh defines the mesh to attach to
  54598. */
  54599. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54600. /**
  54601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54602. * @param renderingGroupId The rendering group id corresponding to its index
  54603. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54604. */
  54605. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54606. /**
  54607. * Clean all associated resources
  54608. */
  54609. dispose(): void;
  54610. /**
  54611. * Converts the reflection probe information to a readable string for debug purpose.
  54612. * @param fullDetails Supports for multiple levels of logging within scene loading
  54613. * @returns the human readable reflection probe info
  54614. */
  54615. toString(fullDetails?: boolean): string;
  54616. /**
  54617. * Get the class name of the relfection probe.
  54618. * @returns "ReflectionProbe"
  54619. */
  54620. getClassName(): string;
  54621. /**
  54622. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54623. * @returns The JSON representation of the texture
  54624. */
  54625. serialize(): any;
  54626. /**
  54627. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54628. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54629. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54630. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54631. * @returns The parsed reflection probe if successful
  54632. */
  54633. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54634. }
  54635. }
  54636. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54637. /** @hidden */
  54638. export var _BabylonLoaderRegistered: boolean;
  54639. /**
  54640. * Helps setting up some configuration for the babylon file loader.
  54641. */
  54642. export class BabylonFileLoaderConfiguration {
  54643. /**
  54644. * The loader does not allow injecting custom physix engine into the plugins.
  54645. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54646. * So you could set this variable to your engine import to make it work.
  54647. */
  54648. static LoaderInjectedPhysicsEngine: any;
  54649. }
  54650. }
  54651. declare module "babylonjs/Loading/Plugins/index" {
  54652. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54653. }
  54654. declare module "babylonjs/Loading/index" {
  54655. export * from "babylonjs/Loading/loadingScreen";
  54656. export * from "babylonjs/Loading/Plugins/index";
  54657. export * from "babylonjs/Loading/sceneLoader";
  54658. export * from "babylonjs/Loading/sceneLoaderFlags";
  54659. }
  54660. declare module "babylonjs/Materials/Background/index" {
  54661. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54662. }
  54663. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54664. import { Scene } from "babylonjs/scene";
  54665. import { Color3 } from "babylonjs/Maths/math.color";
  54666. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54668. /**
  54669. * The Physically based simple base material of BJS.
  54670. *
  54671. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54672. * It is used as the base class for both the specGloss and metalRough conventions.
  54673. */
  54674. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54675. /**
  54676. * Number of Simultaneous lights allowed on the material.
  54677. */
  54678. maxSimultaneousLights: number;
  54679. /**
  54680. * If sets to true, disables all the lights affecting the material.
  54681. */
  54682. disableLighting: boolean;
  54683. /**
  54684. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54685. */
  54686. environmentTexture: BaseTexture;
  54687. /**
  54688. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54689. */
  54690. invertNormalMapX: boolean;
  54691. /**
  54692. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54693. */
  54694. invertNormalMapY: boolean;
  54695. /**
  54696. * Normal map used in the model.
  54697. */
  54698. normalTexture: BaseTexture;
  54699. /**
  54700. * Emissivie color used to self-illuminate the model.
  54701. */
  54702. emissiveColor: Color3;
  54703. /**
  54704. * Emissivie texture used to self-illuminate the model.
  54705. */
  54706. emissiveTexture: BaseTexture;
  54707. /**
  54708. * Occlusion Channel Strenght.
  54709. */
  54710. occlusionStrength: number;
  54711. /**
  54712. * Occlusion Texture of the material (adding extra occlusion effects).
  54713. */
  54714. occlusionTexture: BaseTexture;
  54715. /**
  54716. * Defines the alpha limits in alpha test mode.
  54717. */
  54718. alphaCutOff: number;
  54719. /**
  54720. * Gets the current double sided mode.
  54721. */
  54722. /**
  54723. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54724. */
  54725. doubleSided: boolean;
  54726. /**
  54727. * Stores the pre-calculated light information of a mesh in a texture.
  54728. */
  54729. lightmapTexture: BaseTexture;
  54730. /**
  54731. * If true, the light map contains occlusion information instead of lighting info.
  54732. */
  54733. useLightmapAsShadowmap: boolean;
  54734. /**
  54735. * Instantiates a new PBRMaterial instance.
  54736. *
  54737. * @param name The material name
  54738. * @param scene The scene the material will be use in.
  54739. */
  54740. constructor(name: string, scene: Scene);
  54741. getClassName(): string;
  54742. }
  54743. }
  54744. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54745. import { Scene } from "babylonjs/scene";
  54746. import { Color3 } from "babylonjs/Maths/math.color";
  54747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54748. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54749. /**
  54750. * The PBR material of BJS following the metal roughness convention.
  54751. *
  54752. * This fits to the PBR convention in the GLTF definition:
  54753. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54754. */
  54755. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54756. /**
  54757. * The base color has two different interpretations depending on the value of metalness.
  54758. * When the material is a metal, the base color is the specific measured reflectance value
  54759. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54760. * of the material.
  54761. */
  54762. baseColor: Color3;
  54763. /**
  54764. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54765. * well as opacity information in the alpha channel.
  54766. */
  54767. baseTexture: BaseTexture;
  54768. /**
  54769. * Specifies the metallic scalar value of the material.
  54770. * Can also be used to scale the metalness values of the metallic texture.
  54771. */
  54772. metallic: number;
  54773. /**
  54774. * Specifies the roughness scalar value of the material.
  54775. * Can also be used to scale the roughness values of the metallic texture.
  54776. */
  54777. roughness: number;
  54778. /**
  54779. * Texture containing both the metallic value in the B channel and the
  54780. * roughness value in the G channel to keep better precision.
  54781. */
  54782. metallicRoughnessTexture: BaseTexture;
  54783. /**
  54784. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54785. *
  54786. * @param name The material name
  54787. * @param scene The scene the material will be use in.
  54788. */
  54789. constructor(name: string, scene: Scene);
  54790. /**
  54791. * Return the currrent class name of the material.
  54792. */
  54793. getClassName(): string;
  54794. /**
  54795. * Makes a duplicate of the current material.
  54796. * @param name - name to use for the new material.
  54797. */
  54798. clone(name: string): PBRMetallicRoughnessMaterial;
  54799. /**
  54800. * Serialize the material to a parsable JSON object.
  54801. */
  54802. serialize(): any;
  54803. /**
  54804. * Parses a JSON object correponding to the serialize function.
  54805. */
  54806. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54807. }
  54808. }
  54809. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54810. import { Scene } from "babylonjs/scene";
  54811. import { Color3 } from "babylonjs/Maths/math.color";
  54812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54813. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54814. /**
  54815. * The PBR material of BJS following the specular glossiness convention.
  54816. *
  54817. * This fits to the PBR convention in the GLTF definition:
  54818. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54819. */
  54820. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54821. /**
  54822. * Specifies the diffuse color of the material.
  54823. */
  54824. diffuseColor: Color3;
  54825. /**
  54826. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54827. * channel.
  54828. */
  54829. diffuseTexture: BaseTexture;
  54830. /**
  54831. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54832. */
  54833. specularColor: Color3;
  54834. /**
  54835. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54836. */
  54837. glossiness: number;
  54838. /**
  54839. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54840. */
  54841. specularGlossinessTexture: BaseTexture;
  54842. /**
  54843. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54844. *
  54845. * @param name The material name
  54846. * @param scene The scene the material will be use in.
  54847. */
  54848. constructor(name: string, scene: Scene);
  54849. /**
  54850. * Return the currrent class name of the material.
  54851. */
  54852. getClassName(): string;
  54853. /**
  54854. * Makes a duplicate of the current material.
  54855. * @param name - name to use for the new material.
  54856. */
  54857. clone(name: string): PBRSpecularGlossinessMaterial;
  54858. /**
  54859. * Serialize the material to a parsable JSON object.
  54860. */
  54861. serialize(): any;
  54862. /**
  54863. * Parses a JSON object correponding to the serialize function.
  54864. */
  54865. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54866. }
  54867. }
  54868. declare module "babylonjs/Materials/PBR/index" {
  54869. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54870. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54871. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54872. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54873. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54874. }
  54875. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54876. import { Nullable } from "babylonjs/types";
  54877. import { Scene } from "babylonjs/scene";
  54878. import { Matrix } from "babylonjs/Maths/math.vector";
  54879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54880. /**
  54881. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54882. * It can help converting any input color in a desired output one. This can then be used to create effects
  54883. * from sepia, black and white to sixties or futuristic rendering...
  54884. *
  54885. * The only supported format is currently 3dl.
  54886. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54887. */
  54888. export class ColorGradingTexture extends BaseTexture {
  54889. /**
  54890. * The current texture matrix. (will always be identity in color grading texture)
  54891. */
  54892. private _textureMatrix;
  54893. /**
  54894. * The texture URL.
  54895. */
  54896. url: string;
  54897. /**
  54898. * Empty line regex stored for GC.
  54899. */
  54900. private static _noneEmptyLineRegex;
  54901. private _engine;
  54902. /**
  54903. * Instantiates a ColorGradingTexture from the following parameters.
  54904. *
  54905. * @param url The location of the color gradind data (currently only supporting 3dl)
  54906. * @param scene The scene the texture will be used in
  54907. */
  54908. constructor(url: string, scene: Scene);
  54909. /**
  54910. * Returns the texture matrix used in most of the material.
  54911. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54912. */
  54913. getTextureMatrix(): Matrix;
  54914. /**
  54915. * Occurs when the file being loaded is a .3dl LUT file.
  54916. */
  54917. private load3dlTexture;
  54918. /**
  54919. * Starts the loading process of the texture.
  54920. */
  54921. private loadTexture;
  54922. /**
  54923. * Clones the color gradind texture.
  54924. */
  54925. clone(): ColorGradingTexture;
  54926. /**
  54927. * Called during delayed load for textures.
  54928. */
  54929. delayLoad(): void;
  54930. /**
  54931. * Parses a color grading texture serialized by Babylon.
  54932. * @param parsedTexture The texture information being parsedTexture
  54933. * @param scene The scene to load the texture in
  54934. * @param rootUrl The root url of the data assets to load
  54935. * @return A color gradind texture
  54936. */
  54937. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54938. /**
  54939. * Serializes the LUT texture to json format.
  54940. */
  54941. serialize(): any;
  54942. }
  54943. }
  54944. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54946. import { Scene } from "babylonjs/scene";
  54947. import { Nullable } from "babylonjs/types";
  54948. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54949. /**
  54950. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54951. */
  54952. export class EquiRectangularCubeTexture extends BaseTexture {
  54953. /** The six faces of the cube. */
  54954. private static _FacesMapping;
  54955. private _noMipmap;
  54956. private _onLoad;
  54957. private _onError;
  54958. /** The size of the cubemap. */
  54959. private _size;
  54960. /** The buffer of the image. */
  54961. private _buffer;
  54962. /** The width of the input image. */
  54963. private _width;
  54964. /** The height of the input image. */
  54965. private _height;
  54966. /** The URL to the image. */
  54967. url: string;
  54968. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54969. coordinatesMode: number;
  54970. /**
  54971. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54972. * @param url The location of the image
  54973. * @param scene The scene the texture will be used in
  54974. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54975. * @param noMipmap Forces to not generate the mipmap if true
  54976. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54977. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54978. * @param onLoad — defines a callback called when texture is loaded
  54979. * @param onError — defines a callback called if there is an error
  54980. */
  54981. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54982. /**
  54983. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54984. */
  54985. private loadImage;
  54986. /**
  54987. * Convert the image buffer into a cubemap and create a CubeTexture.
  54988. */
  54989. private loadTexture;
  54990. /**
  54991. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54992. * @param buffer The ArrayBuffer that should be converted.
  54993. * @returns The buffer as Float32Array.
  54994. */
  54995. private getFloat32ArrayFromArrayBuffer;
  54996. /**
  54997. * Get the current class name of the texture useful for serialization or dynamic coding.
  54998. * @returns "EquiRectangularCubeTexture"
  54999. */
  55000. getClassName(): string;
  55001. /**
  55002. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55003. * @returns A clone of the current EquiRectangularCubeTexture.
  55004. */
  55005. clone(): EquiRectangularCubeTexture;
  55006. }
  55007. }
  55008. declare module "babylonjs/Misc/tga" {
  55009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55010. /**
  55011. * Based on jsTGALoader - Javascript loader for TGA file
  55012. * By Vincent Thibault
  55013. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55014. */
  55015. export class TGATools {
  55016. private static _TYPE_INDEXED;
  55017. private static _TYPE_RGB;
  55018. private static _TYPE_GREY;
  55019. private static _TYPE_RLE_INDEXED;
  55020. private static _TYPE_RLE_RGB;
  55021. private static _TYPE_RLE_GREY;
  55022. private static _ORIGIN_MASK;
  55023. private static _ORIGIN_SHIFT;
  55024. private static _ORIGIN_BL;
  55025. private static _ORIGIN_BR;
  55026. private static _ORIGIN_UL;
  55027. private static _ORIGIN_UR;
  55028. /**
  55029. * Gets the header of a TGA file
  55030. * @param data defines the TGA data
  55031. * @returns the header
  55032. */
  55033. static GetTGAHeader(data: Uint8Array): any;
  55034. /**
  55035. * Uploads TGA content to a Babylon Texture
  55036. * @hidden
  55037. */
  55038. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55039. /** @hidden */
  55040. 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;
  55041. /** @hidden */
  55042. 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;
  55043. /** @hidden */
  55044. 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;
  55045. /** @hidden */
  55046. 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;
  55047. /** @hidden */
  55048. 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;
  55049. /** @hidden */
  55050. 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;
  55051. }
  55052. }
  55053. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55054. import { Nullable } from "babylonjs/types";
  55055. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55056. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55057. /**
  55058. * Implementation of the TGA Texture Loader.
  55059. * @hidden
  55060. */
  55061. export class _TGATextureLoader implements IInternalTextureLoader {
  55062. /**
  55063. * Defines wether the loader supports cascade loading the different faces.
  55064. */
  55065. readonly supportCascades: boolean;
  55066. /**
  55067. * This returns if the loader support the current file information.
  55068. * @param extension defines the file extension of the file being loaded
  55069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55070. * @param fallback defines the fallback internal texture if any
  55071. * @param isBase64 defines whether the texture is encoded as a base64
  55072. * @param isBuffer defines whether the texture data are stored as a buffer
  55073. * @returns true if the loader can load the specified file
  55074. */
  55075. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55076. /**
  55077. * Transform the url before loading if required.
  55078. * @param rootUrl the url of the texture
  55079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55080. * @returns the transformed texture
  55081. */
  55082. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55083. /**
  55084. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55085. * @param rootUrl the url of the texture
  55086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55087. * @returns the fallback texture
  55088. */
  55089. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55090. /**
  55091. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55092. * @param data contains the texture data
  55093. * @param texture defines the BabylonJS internal texture
  55094. * @param createPolynomials will be true if polynomials have been requested
  55095. * @param onLoad defines the callback to trigger once the texture is ready
  55096. * @param onError defines the callback to trigger in case of error
  55097. */
  55098. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55099. /**
  55100. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55101. * @param data contains the texture data
  55102. * @param texture defines the BabylonJS internal texture
  55103. * @param callback defines the method to call once ready to upload
  55104. */
  55105. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55106. }
  55107. }
  55108. declare module "babylonjs/Misc/basis" {
  55109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55110. /**
  55111. * Info about the .basis files
  55112. */
  55113. class BasisFileInfo {
  55114. /**
  55115. * If the file has alpha
  55116. */
  55117. hasAlpha: boolean;
  55118. /**
  55119. * Info about each image of the basis file
  55120. */
  55121. images: Array<{
  55122. levels: Array<{
  55123. width: number;
  55124. height: number;
  55125. transcodedPixels: ArrayBufferView;
  55126. }>;
  55127. }>;
  55128. }
  55129. /**
  55130. * Result of transcoding a basis file
  55131. */
  55132. class TranscodeResult {
  55133. /**
  55134. * Info about the .basis file
  55135. */
  55136. fileInfo: BasisFileInfo;
  55137. /**
  55138. * Format to use when loading the file
  55139. */
  55140. format: number;
  55141. }
  55142. /**
  55143. * Configuration options for the Basis transcoder
  55144. */
  55145. export class BasisTranscodeConfiguration {
  55146. /**
  55147. * Supported compression formats used to determine the supported output format of the transcoder
  55148. */
  55149. supportedCompressionFormats?: {
  55150. /**
  55151. * etc1 compression format
  55152. */
  55153. etc1?: boolean;
  55154. /**
  55155. * s3tc compression format
  55156. */
  55157. s3tc?: boolean;
  55158. /**
  55159. * pvrtc compression format
  55160. */
  55161. pvrtc?: boolean;
  55162. /**
  55163. * etc2 compression format
  55164. */
  55165. etc2?: boolean;
  55166. };
  55167. /**
  55168. * If mipmap levels should be loaded for transcoded images (Default: true)
  55169. */
  55170. loadMipmapLevels?: boolean;
  55171. /**
  55172. * Index of a single image to load (Default: all images)
  55173. */
  55174. loadSingleImage?: number;
  55175. }
  55176. /**
  55177. * Used to load .Basis files
  55178. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55179. */
  55180. export class BasisTools {
  55181. private static _IgnoreSupportedFormats;
  55182. /**
  55183. * URL to use when loading the basis transcoder
  55184. */
  55185. static JSModuleURL: string;
  55186. /**
  55187. * URL to use when loading the wasm module for the transcoder
  55188. */
  55189. static WasmModuleURL: string;
  55190. /**
  55191. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55192. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55193. * @returns internal format corresponding to the Basis format
  55194. */
  55195. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55196. private static _WorkerPromise;
  55197. private static _Worker;
  55198. private static _actionId;
  55199. private static _CreateWorkerAsync;
  55200. /**
  55201. * Transcodes a loaded image file to compressed pixel data
  55202. * @param imageData image data to transcode
  55203. * @param config configuration options for the transcoding
  55204. * @returns a promise resulting in the transcoded image
  55205. */
  55206. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55207. /**
  55208. * Loads a texture from the transcode result
  55209. * @param texture texture load to
  55210. * @param transcodeResult the result of transcoding the basis file to load from
  55211. */
  55212. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55213. }
  55214. }
  55215. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55216. import { Nullable } from "babylonjs/types";
  55217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55218. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55219. /**
  55220. * Loader for .basis file format
  55221. */
  55222. export class _BasisTextureLoader implements IInternalTextureLoader {
  55223. /**
  55224. * Defines whether the loader supports cascade loading the different faces.
  55225. */
  55226. readonly supportCascades: boolean;
  55227. /**
  55228. * This returns if the loader support the current file information.
  55229. * @param extension defines the file extension of the file being loaded
  55230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55231. * @param fallback defines the fallback internal texture if any
  55232. * @param isBase64 defines whether the texture is encoded as a base64
  55233. * @param isBuffer defines whether the texture data are stored as a buffer
  55234. * @returns true if the loader can load the specified file
  55235. */
  55236. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55237. /**
  55238. * Transform the url before loading if required.
  55239. * @param rootUrl the url of the texture
  55240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55241. * @returns the transformed texture
  55242. */
  55243. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55244. /**
  55245. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55246. * @param rootUrl the url of the texture
  55247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55248. * @returns the fallback texture
  55249. */
  55250. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55251. /**
  55252. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55253. * @param data contains the texture data
  55254. * @param texture defines the BabylonJS internal texture
  55255. * @param createPolynomials will be true if polynomials have been requested
  55256. * @param onLoad defines the callback to trigger once the texture is ready
  55257. * @param onError defines the callback to trigger in case of error
  55258. */
  55259. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55260. /**
  55261. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55262. * @param data contains the texture data
  55263. * @param texture defines the BabylonJS internal texture
  55264. * @param callback defines the method to call once ready to upload
  55265. */
  55266. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55267. }
  55268. }
  55269. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55270. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55271. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55272. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55273. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55274. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55275. }
  55276. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55277. import { Scene } from "babylonjs/scene";
  55278. import { Texture } from "babylonjs/Materials/Textures/texture";
  55279. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55280. /**
  55281. * 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.
  55282. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55283. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55284. */
  55285. export class CustomProceduralTexture extends ProceduralTexture {
  55286. private _animate;
  55287. private _time;
  55288. private _config;
  55289. private _texturePath;
  55290. /**
  55291. * Instantiates a new Custom Procedural Texture.
  55292. * 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.
  55293. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55294. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55295. * @param name Define the name of the texture
  55296. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55297. * @param size Define the size of the texture to create
  55298. * @param scene Define the scene the texture belongs to
  55299. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55300. * @param generateMipMaps Define if the texture should creates mip maps or not
  55301. */
  55302. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55303. private _loadJson;
  55304. /**
  55305. * Is the texture ready to be used ? (rendered at least once)
  55306. * @returns true if ready, otherwise, false.
  55307. */
  55308. isReady(): boolean;
  55309. /**
  55310. * Render the texture to its associated render target.
  55311. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55312. */
  55313. render(useCameraPostProcess?: boolean): void;
  55314. /**
  55315. * Update the list of dependant textures samplers in the shader.
  55316. */
  55317. updateTextures(): void;
  55318. /**
  55319. * Update the uniform values of the procedural texture in the shader.
  55320. */
  55321. updateShaderUniforms(): void;
  55322. /**
  55323. * Define if the texture animates or not.
  55324. */
  55325. animate: boolean;
  55326. }
  55327. }
  55328. declare module "babylonjs/Shaders/noise.fragment" {
  55329. /** @hidden */
  55330. export var noisePixelShader: {
  55331. name: string;
  55332. shader: string;
  55333. };
  55334. }
  55335. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55336. import { Nullable } from "babylonjs/types";
  55337. import { Scene } from "babylonjs/scene";
  55338. import { Texture } from "babylonjs/Materials/Textures/texture";
  55339. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55340. import "babylonjs/Shaders/noise.fragment";
  55341. /**
  55342. * Class used to generate noise procedural textures
  55343. */
  55344. export class NoiseProceduralTexture extends ProceduralTexture {
  55345. private _time;
  55346. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55347. brightness: number;
  55348. /** Defines the number of octaves to process */
  55349. octaves: number;
  55350. /** Defines the level of persistence (0.8 by default) */
  55351. persistence: number;
  55352. /** Gets or sets animation speed factor (default is 1) */
  55353. animationSpeedFactor: number;
  55354. /**
  55355. * Creates a new NoiseProceduralTexture
  55356. * @param name defines the name fo the texture
  55357. * @param size defines the size of the texture (default is 256)
  55358. * @param scene defines the hosting scene
  55359. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55360. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55361. */
  55362. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55363. private _updateShaderUniforms;
  55364. protected _getDefines(): string;
  55365. /** Generate the current state of the procedural texture */
  55366. render(useCameraPostProcess?: boolean): void;
  55367. /**
  55368. * Serializes this noise procedural texture
  55369. * @returns a serialized noise procedural texture object
  55370. */
  55371. serialize(): any;
  55372. /**
  55373. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55374. * @param parsedTexture defines parsed texture data
  55375. * @param scene defines the current scene
  55376. * @param rootUrl defines the root URL containing noise procedural texture information
  55377. * @returns a parsed NoiseProceduralTexture
  55378. */
  55379. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55380. }
  55381. }
  55382. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55383. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55384. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55385. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55386. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55387. }
  55388. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55389. import { Nullable } from "babylonjs/types";
  55390. import { Scene } from "babylonjs/scene";
  55391. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55393. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55394. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55395. /**
  55396. * Raw cube texture where the raw buffers are passed in
  55397. */
  55398. export class RawCubeTexture extends CubeTexture {
  55399. /**
  55400. * Creates a cube texture where the raw buffers are passed in.
  55401. * @param scene defines the scene the texture is attached to
  55402. * @param data defines the array of data to use to create each face
  55403. * @param size defines the size of the textures
  55404. * @param format defines the format of the data
  55405. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55406. * @param generateMipMaps defines if the engine should generate the mip levels
  55407. * @param invertY defines if data must be stored with Y axis inverted
  55408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55409. * @param compression defines the compression used (null by default)
  55410. */
  55411. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55412. /**
  55413. * Updates the raw cube texture.
  55414. * @param data defines the data to store
  55415. * @param format defines the data format
  55416. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55417. * @param invertY defines if data must be stored with Y axis inverted
  55418. * @param compression defines the compression used (null by default)
  55419. * @param level defines which level of the texture to update
  55420. */
  55421. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55422. /**
  55423. * Updates a raw cube texture with RGBD encoded data.
  55424. * @param data defines the array of data [mipmap][face] to use to create each face
  55425. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55426. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55427. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55428. * @returns a promsie that resolves when the operation is complete
  55429. */
  55430. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55431. /**
  55432. * Clones the raw cube texture.
  55433. * @return a new cube texture
  55434. */
  55435. clone(): CubeTexture;
  55436. /** @hidden */
  55437. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55438. }
  55439. }
  55440. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55441. import { Scene } from "babylonjs/scene";
  55442. import { Texture } from "babylonjs/Materials/Textures/texture";
  55443. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55444. /**
  55445. * Class used to store 3D textures containing user data
  55446. */
  55447. export class RawTexture3D extends Texture {
  55448. /** Gets or sets the texture format to use */
  55449. format: number;
  55450. private _engine;
  55451. /**
  55452. * Create a new RawTexture3D
  55453. * @param data defines the data of the texture
  55454. * @param width defines the width of the texture
  55455. * @param height defines the height of the texture
  55456. * @param depth defines the depth of the texture
  55457. * @param format defines the texture format to use
  55458. * @param scene defines the hosting scene
  55459. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55460. * @param invertY defines if texture must be stored with Y axis inverted
  55461. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55463. */
  55464. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55465. /** Gets or sets the texture format to use */
  55466. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55467. /**
  55468. * Update the texture with new data
  55469. * @param data defines the data to store in the texture
  55470. */
  55471. update(data: ArrayBufferView): void;
  55472. }
  55473. }
  55474. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55475. import { Scene } from "babylonjs/scene";
  55476. import { Texture } from "babylonjs/Materials/Textures/texture";
  55477. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55478. /**
  55479. * Class used to store 2D array textures containing user data
  55480. */
  55481. export class RawTexture2DArray extends Texture {
  55482. /** Gets or sets the texture format to use */
  55483. format: number;
  55484. private _engine;
  55485. /**
  55486. * Create a new RawTexture2DArray
  55487. * @param data defines the data of the texture
  55488. * @param width defines the width of the texture
  55489. * @param height defines the height of the texture
  55490. * @param depth defines the number of layers of the texture
  55491. * @param format defines the texture format to use
  55492. * @param scene defines the hosting scene
  55493. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55494. * @param invertY defines if texture must be stored with Y axis inverted
  55495. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55496. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55497. */
  55498. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55499. /** Gets or sets the texture format to use */
  55500. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55501. /**
  55502. * Update the texture with new data
  55503. * @param data defines the data to store in the texture
  55504. */
  55505. update(data: ArrayBufferView): void;
  55506. }
  55507. }
  55508. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55509. import { Scene } from "babylonjs/scene";
  55510. import { Plane } from "babylonjs/Maths/math.plane";
  55511. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55512. /**
  55513. * Creates a refraction texture used by refraction channel of the standard material.
  55514. * It is like a mirror but to see through a material.
  55515. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55516. */
  55517. export class RefractionTexture extends RenderTargetTexture {
  55518. /**
  55519. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55520. * 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.
  55521. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55522. */
  55523. refractionPlane: Plane;
  55524. /**
  55525. * Define how deep under the surface we should see.
  55526. */
  55527. depth: number;
  55528. /**
  55529. * Creates a refraction texture used by refraction channel of the standard material.
  55530. * It is like a mirror but to see through a material.
  55531. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55532. * @param name Define the texture name
  55533. * @param size Define the size of the underlying texture
  55534. * @param scene Define the scene the refraction belongs to
  55535. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55536. */
  55537. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55538. /**
  55539. * Clone the refraction texture.
  55540. * @returns the cloned texture
  55541. */
  55542. clone(): RefractionTexture;
  55543. /**
  55544. * Serialize the texture to a JSON representation you could use in Parse later on
  55545. * @returns the serialized JSON representation
  55546. */
  55547. serialize(): any;
  55548. }
  55549. }
  55550. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55551. import { Nullable } from "babylonjs/types";
  55552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55553. import { Matrix } from "babylonjs/Maths/math.vector";
  55554. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55555. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55556. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55557. import { Scene } from "babylonjs/scene";
  55558. /**
  55559. * Defines the options related to the creation of an HtmlElementTexture
  55560. */
  55561. export interface IHtmlElementTextureOptions {
  55562. /**
  55563. * Defines wether mip maps should be created or not.
  55564. */
  55565. generateMipMaps?: boolean;
  55566. /**
  55567. * Defines the sampling mode of the texture.
  55568. */
  55569. samplingMode?: number;
  55570. /**
  55571. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55572. */
  55573. engine: Nullable<ThinEngine>;
  55574. /**
  55575. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55576. */
  55577. scene: Nullable<Scene>;
  55578. }
  55579. /**
  55580. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55581. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55582. * is automatically managed.
  55583. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55584. * in your application.
  55585. *
  55586. * As the update is not automatic, you need to call them manually.
  55587. */
  55588. export class HtmlElementTexture extends BaseTexture {
  55589. /**
  55590. * The texture URL.
  55591. */
  55592. element: HTMLVideoElement | HTMLCanvasElement;
  55593. private static readonly DefaultOptions;
  55594. private _textureMatrix;
  55595. private _engine;
  55596. private _isVideo;
  55597. private _generateMipMaps;
  55598. private _samplingMode;
  55599. /**
  55600. * Instantiates a HtmlElementTexture from the following parameters.
  55601. *
  55602. * @param name Defines the name of the texture
  55603. * @param element Defines the video or canvas the texture is filled with
  55604. * @param options Defines the other none mandatory texture creation options
  55605. */
  55606. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55607. private _createInternalTexture;
  55608. /**
  55609. * Returns the texture matrix used in most of the material.
  55610. */
  55611. getTextureMatrix(): Matrix;
  55612. /**
  55613. * Updates the content of the texture.
  55614. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55615. */
  55616. update(invertY?: Nullable<boolean>): void;
  55617. }
  55618. }
  55619. declare module "babylonjs/Materials/Textures/index" {
  55620. export * from "babylonjs/Materials/Textures/baseTexture";
  55621. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55622. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55623. export * from "babylonjs/Materials/Textures/cubeTexture";
  55624. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55625. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55626. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55627. export * from "babylonjs/Materials/Textures/internalTexture";
  55628. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55629. export * from "babylonjs/Materials/Textures/Loaders/index";
  55630. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55631. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55632. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55633. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55634. export * from "babylonjs/Materials/Textures/rawTexture";
  55635. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55636. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55637. export * from "babylonjs/Materials/Textures/refractionTexture";
  55638. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55639. export * from "babylonjs/Materials/Textures/texture";
  55640. export * from "babylonjs/Materials/Textures/videoTexture";
  55641. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55642. }
  55643. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55644. /**
  55645. * Enum used to define the target of a block
  55646. */
  55647. export enum NodeMaterialBlockTargets {
  55648. /** Vertex shader */
  55649. Vertex = 1,
  55650. /** Fragment shader */
  55651. Fragment = 2,
  55652. /** Neutral */
  55653. Neutral = 4,
  55654. /** Vertex and Fragment */
  55655. VertexAndFragment = 3
  55656. }
  55657. }
  55658. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55659. /**
  55660. * Defines the kind of connection point for node based material
  55661. */
  55662. export enum NodeMaterialBlockConnectionPointTypes {
  55663. /** Float */
  55664. Float = 1,
  55665. /** Int */
  55666. Int = 2,
  55667. /** Vector2 */
  55668. Vector2 = 4,
  55669. /** Vector3 */
  55670. Vector3 = 8,
  55671. /** Vector4 */
  55672. Vector4 = 16,
  55673. /** Color3 */
  55674. Color3 = 32,
  55675. /** Color4 */
  55676. Color4 = 64,
  55677. /** Matrix */
  55678. Matrix = 128,
  55679. /** Detect type based on connection */
  55680. AutoDetect = 1024,
  55681. /** Output type that will be defined by input type */
  55682. BasedOnInput = 2048
  55683. }
  55684. }
  55685. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55686. /**
  55687. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55688. */
  55689. export enum NodeMaterialBlockConnectionPointMode {
  55690. /** Value is an uniform */
  55691. Uniform = 0,
  55692. /** Value is a mesh attribute */
  55693. Attribute = 1,
  55694. /** Value is a varying between vertex and fragment shaders */
  55695. Varying = 2,
  55696. /** Mode is undefined */
  55697. Undefined = 3
  55698. }
  55699. }
  55700. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55701. /**
  55702. * Enum used to define system values e.g. values automatically provided by the system
  55703. */
  55704. export enum NodeMaterialSystemValues {
  55705. /** World */
  55706. World = 1,
  55707. /** View */
  55708. View = 2,
  55709. /** Projection */
  55710. Projection = 3,
  55711. /** ViewProjection */
  55712. ViewProjection = 4,
  55713. /** WorldView */
  55714. WorldView = 5,
  55715. /** WorldViewProjection */
  55716. WorldViewProjection = 6,
  55717. /** CameraPosition */
  55718. CameraPosition = 7,
  55719. /** Fog Color */
  55720. FogColor = 8,
  55721. /** Delta time */
  55722. DeltaTime = 9
  55723. }
  55724. }
  55725. declare module "babylonjs/Materials/Node/Enums/index" {
  55726. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55727. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55728. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55729. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55730. }
  55731. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55733. /**
  55734. * Root class for all node material optimizers
  55735. */
  55736. export class NodeMaterialOptimizer {
  55737. /**
  55738. * Function used to optimize a NodeMaterial graph
  55739. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55740. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55741. */
  55742. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55743. }
  55744. }
  55745. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55749. import { Scene } from "babylonjs/scene";
  55750. /**
  55751. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55752. */
  55753. export class TransformBlock extends NodeMaterialBlock {
  55754. /**
  55755. * Defines the value to use to complement W value to transform it to a Vector4
  55756. */
  55757. complementW: number;
  55758. /**
  55759. * Defines the value to use to complement z value to transform it to a Vector4
  55760. */
  55761. complementZ: number;
  55762. /**
  55763. * Creates a new TransformBlock
  55764. * @param name defines the block name
  55765. */
  55766. constructor(name: string);
  55767. /**
  55768. * Gets the current class name
  55769. * @returns the class name
  55770. */
  55771. getClassName(): string;
  55772. /**
  55773. * Gets the vector input
  55774. */
  55775. readonly vector: NodeMaterialConnectionPoint;
  55776. /**
  55777. * Gets the output component
  55778. */
  55779. readonly output: NodeMaterialConnectionPoint;
  55780. /**
  55781. * Gets the matrix transform input
  55782. */
  55783. readonly transform: NodeMaterialConnectionPoint;
  55784. protected _buildBlock(state: NodeMaterialBuildState): this;
  55785. serialize(): any;
  55786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55787. protected _dumpPropertiesCode(): string;
  55788. }
  55789. }
  55790. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55794. /**
  55795. * Block used to output the vertex position
  55796. */
  55797. export class VertexOutputBlock extends NodeMaterialBlock {
  55798. /**
  55799. * Creates a new VertexOutputBlock
  55800. * @param name defines the block name
  55801. */
  55802. constructor(name: string);
  55803. /**
  55804. * Gets the current class name
  55805. * @returns the class name
  55806. */
  55807. getClassName(): string;
  55808. /**
  55809. * Gets the vector input component
  55810. */
  55811. readonly vector: NodeMaterialConnectionPoint;
  55812. protected _buildBlock(state: NodeMaterialBuildState): this;
  55813. }
  55814. }
  55815. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55819. /**
  55820. * Block used to output the final color
  55821. */
  55822. export class FragmentOutputBlock extends NodeMaterialBlock {
  55823. /**
  55824. * Create a new FragmentOutputBlock
  55825. * @param name defines the block name
  55826. */
  55827. constructor(name: string);
  55828. /**
  55829. * Gets the current class name
  55830. * @returns the class name
  55831. */
  55832. getClassName(): string;
  55833. /**
  55834. * Gets the rgba input component
  55835. */
  55836. readonly rgba: NodeMaterialConnectionPoint;
  55837. /**
  55838. * Gets the rgb input component
  55839. */
  55840. readonly rgb: NodeMaterialConnectionPoint;
  55841. /**
  55842. * Gets the a input component
  55843. */
  55844. readonly a: NodeMaterialConnectionPoint;
  55845. protected _buildBlock(state: NodeMaterialBuildState): this;
  55846. }
  55847. }
  55848. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55854. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55855. import { Effect } from "babylonjs/Materials/effect";
  55856. import { Mesh } from "babylonjs/Meshes/mesh";
  55857. import { Nullable } from "babylonjs/types";
  55858. import { Scene } from "babylonjs/scene";
  55859. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55860. /**
  55861. * Block used to read a reflection texture from a sampler
  55862. */
  55863. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55864. private _define3DName;
  55865. private _defineCubicName;
  55866. private _defineExplicitName;
  55867. private _defineProjectionName;
  55868. private _defineLocalCubicName;
  55869. private _defineSphericalName;
  55870. private _definePlanarName;
  55871. private _defineEquirectangularName;
  55872. private _defineMirroredEquirectangularFixedName;
  55873. private _defineEquirectangularFixedName;
  55874. private _defineSkyboxName;
  55875. private _cubeSamplerName;
  55876. private _2DSamplerName;
  55877. private _positionUVWName;
  55878. private _directionWName;
  55879. private _reflectionCoordsName;
  55880. private _reflection2DCoordsName;
  55881. private _reflectionColorName;
  55882. private _reflectionMatrixName;
  55883. /**
  55884. * Gets or sets the texture associated with the node
  55885. */
  55886. texture: Nullable<BaseTexture>;
  55887. /**
  55888. * Create a new TextureBlock
  55889. * @param name defines the block name
  55890. */
  55891. constructor(name: string);
  55892. /**
  55893. * Gets the current class name
  55894. * @returns the class name
  55895. */
  55896. getClassName(): string;
  55897. /**
  55898. * Gets the world position input component
  55899. */
  55900. readonly position: NodeMaterialConnectionPoint;
  55901. /**
  55902. * Gets the world position input component
  55903. */
  55904. readonly worldPosition: NodeMaterialConnectionPoint;
  55905. /**
  55906. * Gets the world normal input component
  55907. */
  55908. readonly worldNormal: NodeMaterialConnectionPoint;
  55909. /**
  55910. * Gets the world input component
  55911. */
  55912. readonly world: NodeMaterialConnectionPoint;
  55913. /**
  55914. * Gets the camera (or eye) position component
  55915. */
  55916. readonly cameraPosition: NodeMaterialConnectionPoint;
  55917. /**
  55918. * Gets the view input component
  55919. */
  55920. readonly view: NodeMaterialConnectionPoint;
  55921. /**
  55922. * Gets the rgb output component
  55923. */
  55924. readonly rgb: NodeMaterialConnectionPoint;
  55925. /**
  55926. * Gets the r output component
  55927. */
  55928. readonly r: NodeMaterialConnectionPoint;
  55929. /**
  55930. * Gets the g output component
  55931. */
  55932. readonly g: NodeMaterialConnectionPoint;
  55933. /**
  55934. * Gets the b output component
  55935. */
  55936. readonly b: NodeMaterialConnectionPoint;
  55937. autoConfigure(material: NodeMaterial): void;
  55938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55939. isReady(): boolean;
  55940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55941. private _injectVertexCode;
  55942. private _writeOutput;
  55943. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55944. protected _dumpPropertiesCode(): string;
  55945. serialize(): any;
  55946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55947. }
  55948. }
  55949. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55951. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55952. import { Scene } from "babylonjs/scene";
  55953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55954. import { Matrix } from "babylonjs/Maths/math.vector";
  55955. import { Mesh } from "babylonjs/Meshes/mesh";
  55956. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55957. import { Observable } from "babylonjs/Misc/observable";
  55958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55959. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55960. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55961. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55962. import { Nullable } from "babylonjs/types";
  55963. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55964. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55965. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55966. /**
  55967. * Interface used to configure the node material editor
  55968. */
  55969. export interface INodeMaterialEditorOptions {
  55970. /** Define the URl to load node editor script */
  55971. editorURL?: string;
  55972. }
  55973. /** @hidden */
  55974. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55975. /** BONES */
  55976. NUM_BONE_INFLUENCERS: number;
  55977. BonesPerMesh: number;
  55978. BONETEXTURE: boolean;
  55979. /** MORPH TARGETS */
  55980. MORPHTARGETS: boolean;
  55981. MORPHTARGETS_NORMAL: boolean;
  55982. MORPHTARGETS_TANGENT: boolean;
  55983. MORPHTARGETS_UV: boolean;
  55984. NUM_MORPH_INFLUENCERS: number;
  55985. /** IMAGE PROCESSING */
  55986. IMAGEPROCESSING: boolean;
  55987. VIGNETTE: boolean;
  55988. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55989. VIGNETTEBLENDMODEOPAQUE: boolean;
  55990. TONEMAPPING: boolean;
  55991. TONEMAPPING_ACES: boolean;
  55992. CONTRAST: boolean;
  55993. EXPOSURE: boolean;
  55994. COLORCURVES: boolean;
  55995. COLORGRADING: boolean;
  55996. COLORGRADING3D: boolean;
  55997. SAMPLER3DGREENDEPTH: boolean;
  55998. SAMPLER3DBGRMAP: boolean;
  55999. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56000. /** MISC. */
  56001. BUMPDIRECTUV: number;
  56002. constructor();
  56003. setValue(name: string, value: boolean): void;
  56004. }
  56005. /**
  56006. * Class used to configure NodeMaterial
  56007. */
  56008. export interface INodeMaterialOptions {
  56009. /**
  56010. * Defines if blocks should emit comments
  56011. */
  56012. emitComments: boolean;
  56013. }
  56014. /**
  56015. * Class used to create a node based material built by assembling shader blocks
  56016. */
  56017. export class NodeMaterial extends PushMaterial {
  56018. private static _BuildIdGenerator;
  56019. private _options;
  56020. private _vertexCompilationState;
  56021. private _fragmentCompilationState;
  56022. private _sharedData;
  56023. private _buildId;
  56024. private _buildWasSuccessful;
  56025. private _cachedWorldViewMatrix;
  56026. private _cachedWorldViewProjectionMatrix;
  56027. private _optimizers;
  56028. private _animationFrame;
  56029. /** Define the URl to load node editor script */
  56030. static EditorURL: string;
  56031. private BJSNODEMATERIALEDITOR;
  56032. /** Get the inspector from bundle or global */
  56033. private _getGlobalNodeMaterialEditor;
  56034. /**
  56035. * 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)
  56036. */
  56037. ignoreAlpha: boolean;
  56038. /**
  56039. * Defines the maximum number of lights that can be used in the material
  56040. */
  56041. maxSimultaneousLights: number;
  56042. /**
  56043. * Observable raised when the material is built
  56044. */
  56045. onBuildObservable: Observable<NodeMaterial>;
  56046. /**
  56047. * Gets or sets the root nodes of the material vertex shader
  56048. */
  56049. _vertexOutputNodes: NodeMaterialBlock[];
  56050. /**
  56051. * Gets or sets the root nodes of the material fragment (pixel) shader
  56052. */
  56053. _fragmentOutputNodes: NodeMaterialBlock[];
  56054. /** Gets or sets options to control the node material overall behavior */
  56055. options: INodeMaterialOptions;
  56056. /**
  56057. * Default configuration related to image processing available in the standard Material.
  56058. */
  56059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56060. /**
  56061. * Gets the image processing configuration used either in this material.
  56062. */
  56063. /**
  56064. * Sets the Default image processing configuration used either in the this material.
  56065. *
  56066. * If sets to null, the scene one is in use.
  56067. */
  56068. imageProcessingConfiguration: ImageProcessingConfiguration;
  56069. /**
  56070. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56071. */
  56072. attachedBlocks: NodeMaterialBlock[];
  56073. /**
  56074. * Create a new node based material
  56075. * @param name defines the material name
  56076. * @param scene defines the hosting scene
  56077. * @param options defines creation option
  56078. */
  56079. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56080. /**
  56081. * Gets the current class name of the material e.g. "NodeMaterial"
  56082. * @returns the class name
  56083. */
  56084. getClassName(): string;
  56085. /**
  56086. * Keep track of the image processing observer to allow dispose and replace.
  56087. */
  56088. private _imageProcessingObserver;
  56089. /**
  56090. * Attaches a new image processing configuration to the Standard Material.
  56091. * @param configuration
  56092. */
  56093. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56094. /**
  56095. * Get a block by its name
  56096. * @param name defines the name of the block to retrieve
  56097. * @returns the required block or null if not found
  56098. */
  56099. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56100. /**
  56101. * Get a block by its name
  56102. * @param predicate defines the predicate used to find the good candidate
  56103. * @returns the required block or null if not found
  56104. */
  56105. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56106. /**
  56107. * Get an input block by its name
  56108. * @param predicate defines the predicate used to find the good candidate
  56109. * @returns the required input block or null if not found
  56110. */
  56111. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56112. /**
  56113. * Gets the list of input blocks attached to this material
  56114. * @returns an array of InputBlocks
  56115. */
  56116. getInputBlocks(): InputBlock[];
  56117. /**
  56118. * Adds a new optimizer to the list of optimizers
  56119. * @param optimizer defines the optimizers to add
  56120. * @returns the current material
  56121. */
  56122. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56123. /**
  56124. * Remove an optimizer from the list of optimizers
  56125. * @param optimizer defines the optimizers to remove
  56126. * @returns the current material
  56127. */
  56128. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56129. /**
  56130. * Add a new block to the list of output nodes
  56131. * @param node defines the node to add
  56132. * @returns the current material
  56133. */
  56134. addOutputNode(node: NodeMaterialBlock): this;
  56135. /**
  56136. * Remove a block from the list of root nodes
  56137. * @param node defines the node to remove
  56138. * @returns the current material
  56139. */
  56140. removeOutputNode(node: NodeMaterialBlock): this;
  56141. private _addVertexOutputNode;
  56142. private _removeVertexOutputNode;
  56143. private _addFragmentOutputNode;
  56144. private _removeFragmentOutputNode;
  56145. /**
  56146. * Specifies if the material will require alpha blending
  56147. * @returns a boolean specifying if alpha blending is needed
  56148. */
  56149. needAlphaBlending(): boolean;
  56150. /**
  56151. * Specifies if this material should be rendered in alpha test mode
  56152. * @returns a boolean specifying if an alpha test is needed.
  56153. */
  56154. needAlphaTesting(): boolean;
  56155. private _initializeBlock;
  56156. private _resetDualBlocks;
  56157. /**
  56158. * Build the material and generates the inner effect
  56159. * @param verbose defines if the build should log activity
  56160. */
  56161. build(verbose?: boolean): void;
  56162. /**
  56163. * Runs an otpimization phase to try to improve the shader code
  56164. */
  56165. optimize(): void;
  56166. private _prepareDefinesForAttributes;
  56167. /**
  56168. * Get if the submesh is ready to be used and all its information available.
  56169. * Child classes can use it to update shaders
  56170. * @param mesh defines the mesh to check
  56171. * @param subMesh defines which submesh to check
  56172. * @param useInstances specifies that instances should be used
  56173. * @returns a boolean indicating that the submesh is ready or not
  56174. */
  56175. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56176. /**
  56177. * Get a string representing the shaders built by the current node graph
  56178. */
  56179. readonly compiledShaders: string;
  56180. /**
  56181. * Binds the world matrix to the material
  56182. * @param world defines the world transformation matrix
  56183. */
  56184. bindOnlyWorldMatrix(world: Matrix): void;
  56185. /**
  56186. * Binds the submesh to this material by preparing the effect and shader to draw
  56187. * @param world defines the world transformation matrix
  56188. * @param mesh defines the mesh containing the submesh
  56189. * @param subMesh defines the submesh to bind the material to
  56190. */
  56191. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56192. /**
  56193. * Gets the active textures from the material
  56194. * @returns an array of textures
  56195. */
  56196. getActiveTextures(): BaseTexture[];
  56197. /**
  56198. * Gets the list of texture blocks
  56199. * @returns an array of texture blocks
  56200. */
  56201. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56202. /**
  56203. * Specifies if the material uses a texture
  56204. * @param texture defines the texture to check against the material
  56205. * @returns a boolean specifying if the material uses the texture
  56206. */
  56207. hasTexture(texture: BaseTexture): boolean;
  56208. /**
  56209. * Disposes the material
  56210. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56211. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56212. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56213. */
  56214. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56215. /** Creates the node editor window. */
  56216. private _createNodeEditor;
  56217. /**
  56218. * Launch the node material editor
  56219. * @param config Define the configuration of the editor
  56220. * @return a promise fulfilled when the node editor is visible
  56221. */
  56222. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56223. /**
  56224. * Clear the current material
  56225. */
  56226. clear(): void;
  56227. /**
  56228. * Clear the current material and set it to a default state
  56229. */
  56230. setToDefault(): void;
  56231. /**
  56232. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56233. * @param url defines the url to load from
  56234. * @returns a promise that will fullfil when the material is fully loaded
  56235. */
  56236. loadAsync(url: string): Promise<void>;
  56237. private _gatherBlocks;
  56238. /**
  56239. * Generate a string containing the code declaration required to create an equivalent of this material
  56240. * @returns a string
  56241. */
  56242. generateCode(): string;
  56243. /**
  56244. * Serializes this material in a JSON representation
  56245. * @returns the serialized material object
  56246. */
  56247. serialize(): any;
  56248. private _restoreConnections;
  56249. /**
  56250. * Clear the current graph and load a new one from a serialization object
  56251. * @param source defines the JSON representation of the material
  56252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56253. */
  56254. loadFromSerialization(source: any, rootUrl?: string): void;
  56255. /**
  56256. * Creates a node material from parsed material data
  56257. * @param source defines the JSON representation of the material
  56258. * @param scene defines the hosting scene
  56259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56260. * @returns a new node material
  56261. */
  56262. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56263. /**
  56264. * Creates a new node material set to default basic configuration
  56265. * @param name defines the name of the material
  56266. * @param scene defines the hosting scene
  56267. * @returns a new NodeMaterial
  56268. */
  56269. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56270. }
  56271. }
  56272. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56273. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56274. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56275. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56278. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56279. import { Effect } from "babylonjs/Materials/effect";
  56280. import { Mesh } from "babylonjs/Meshes/mesh";
  56281. import { Nullable } from "babylonjs/types";
  56282. import { Texture } from "babylonjs/Materials/Textures/texture";
  56283. import { Scene } from "babylonjs/scene";
  56284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56285. /**
  56286. * Block used to read a texture from a sampler
  56287. */
  56288. export class TextureBlock extends NodeMaterialBlock {
  56289. private _defineName;
  56290. private _linearDefineName;
  56291. private _samplerName;
  56292. private _transformedUVName;
  56293. private _textureTransformName;
  56294. private _textureInfoName;
  56295. private _mainUVName;
  56296. private _mainUVDefineName;
  56297. /**
  56298. * Gets or sets the texture associated with the node
  56299. */
  56300. texture: Nullable<Texture>;
  56301. /**
  56302. * Create a new TextureBlock
  56303. * @param name defines the block name
  56304. */
  56305. constructor(name: string);
  56306. /**
  56307. * Gets the current class name
  56308. * @returns the class name
  56309. */
  56310. getClassName(): string;
  56311. /**
  56312. * Gets the uv input component
  56313. */
  56314. readonly uv: NodeMaterialConnectionPoint;
  56315. /**
  56316. * Gets the rgba output component
  56317. */
  56318. readonly rgba: NodeMaterialConnectionPoint;
  56319. /**
  56320. * Gets the rgb output component
  56321. */
  56322. readonly rgb: NodeMaterialConnectionPoint;
  56323. /**
  56324. * Gets the r output component
  56325. */
  56326. readonly r: NodeMaterialConnectionPoint;
  56327. /**
  56328. * Gets the g output component
  56329. */
  56330. readonly g: NodeMaterialConnectionPoint;
  56331. /**
  56332. * Gets the b output component
  56333. */
  56334. readonly b: NodeMaterialConnectionPoint;
  56335. /**
  56336. * Gets the a output component
  56337. */
  56338. readonly a: NodeMaterialConnectionPoint;
  56339. readonly target: NodeMaterialBlockTargets;
  56340. autoConfigure(material: NodeMaterial): void;
  56341. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56343. isReady(): boolean;
  56344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56345. private readonly _isMixed;
  56346. private _injectVertexCode;
  56347. private _writeOutput;
  56348. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56349. protected _dumpPropertiesCode(): string;
  56350. serialize(): any;
  56351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56352. }
  56353. }
  56354. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56357. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56358. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56359. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56360. import { Scene } from "babylonjs/scene";
  56361. /**
  56362. * Class used to store shared data between 2 NodeMaterialBuildState
  56363. */
  56364. export class NodeMaterialBuildStateSharedData {
  56365. /**
  56366. * Gets the list of emitted varyings
  56367. */
  56368. temps: string[];
  56369. /**
  56370. * Gets the list of emitted varyings
  56371. */
  56372. varyings: string[];
  56373. /**
  56374. * Gets the varying declaration string
  56375. */
  56376. varyingDeclaration: string;
  56377. /**
  56378. * Input blocks
  56379. */
  56380. inputBlocks: InputBlock[];
  56381. /**
  56382. * Input blocks
  56383. */
  56384. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56385. /**
  56386. * Bindable blocks (Blocks that need to set data to the effect)
  56387. */
  56388. bindableBlocks: NodeMaterialBlock[];
  56389. /**
  56390. * List of blocks that can provide a compilation fallback
  56391. */
  56392. blocksWithFallbacks: NodeMaterialBlock[];
  56393. /**
  56394. * List of blocks that can provide a define update
  56395. */
  56396. blocksWithDefines: NodeMaterialBlock[];
  56397. /**
  56398. * List of blocks that can provide a repeatable content
  56399. */
  56400. repeatableContentBlocks: NodeMaterialBlock[];
  56401. /**
  56402. * List of blocks that can provide a dynamic list of uniforms
  56403. */
  56404. dynamicUniformBlocks: NodeMaterialBlock[];
  56405. /**
  56406. * List of blocks that can block the isReady function for the material
  56407. */
  56408. blockingBlocks: NodeMaterialBlock[];
  56409. /**
  56410. * Gets the list of animated inputs
  56411. */
  56412. animatedInputs: InputBlock[];
  56413. /**
  56414. * Build Id used to avoid multiple recompilations
  56415. */
  56416. buildId: number;
  56417. /** List of emitted variables */
  56418. variableNames: {
  56419. [key: string]: number;
  56420. };
  56421. /** List of emitted defines */
  56422. defineNames: {
  56423. [key: string]: number;
  56424. };
  56425. /** Should emit comments? */
  56426. emitComments: boolean;
  56427. /** Emit build activity */
  56428. verbose: boolean;
  56429. /** Gets or sets the hosting scene */
  56430. scene: Scene;
  56431. /**
  56432. * Gets the compilation hints emitted at compilation time
  56433. */
  56434. hints: {
  56435. needWorldViewMatrix: boolean;
  56436. needWorldViewProjectionMatrix: boolean;
  56437. needAlphaBlending: boolean;
  56438. needAlphaTesting: boolean;
  56439. };
  56440. /**
  56441. * List of compilation checks
  56442. */
  56443. checks: {
  56444. emitVertex: boolean;
  56445. emitFragment: boolean;
  56446. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56447. };
  56448. /** Creates a new shared data */
  56449. constructor();
  56450. /**
  56451. * Emits console errors and exceptions if there is a failing check
  56452. */
  56453. emitErrors(): void;
  56454. }
  56455. }
  56456. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56457. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56458. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56459. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56460. /**
  56461. * Class used to store node based material build state
  56462. */
  56463. export class NodeMaterialBuildState {
  56464. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56465. supportUniformBuffers: boolean;
  56466. /**
  56467. * Gets the list of emitted attributes
  56468. */
  56469. attributes: string[];
  56470. /**
  56471. * Gets the list of emitted uniforms
  56472. */
  56473. uniforms: string[];
  56474. /**
  56475. * Gets the list of emitted constants
  56476. */
  56477. constants: string[];
  56478. /**
  56479. * Gets the list of emitted samplers
  56480. */
  56481. samplers: string[];
  56482. /**
  56483. * Gets the list of emitted functions
  56484. */
  56485. functions: {
  56486. [key: string]: string;
  56487. };
  56488. /**
  56489. * Gets the list of emitted extensions
  56490. */
  56491. extensions: {
  56492. [key: string]: string;
  56493. };
  56494. /**
  56495. * Gets the target of the compilation state
  56496. */
  56497. target: NodeMaterialBlockTargets;
  56498. /**
  56499. * Gets the list of emitted counters
  56500. */
  56501. counters: {
  56502. [key: string]: number;
  56503. };
  56504. /**
  56505. * Shared data between multiple NodeMaterialBuildState instances
  56506. */
  56507. sharedData: NodeMaterialBuildStateSharedData;
  56508. /** @hidden */
  56509. _vertexState: NodeMaterialBuildState;
  56510. /** @hidden */
  56511. _attributeDeclaration: string;
  56512. /** @hidden */
  56513. _uniformDeclaration: string;
  56514. /** @hidden */
  56515. _constantDeclaration: string;
  56516. /** @hidden */
  56517. _samplerDeclaration: string;
  56518. /** @hidden */
  56519. _varyingTransfer: string;
  56520. private _repeatableContentAnchorIndex;
  56521. /** @hidden */
  56522. _builtCompilationString: string;
  56523. /**
  56524. * Gets the emitted compilation strings
  56525. */
  56526. compilationString: string;
  56527. /**
  56528. * Finalize the compilation strings
  56529. * @param state defines the current compilation state
  56530. */
  56531. finalize(state: NodeMaterialBuildState): void;
  56532. /** @hidden */
  56533. readonly _repeatableContentAnchor: string;
  56534. /** @hidden */
  56535. _getFreeVariableName(prefix: string): string;
  56536. /** @hidden */
  56537. _getFreeDefineName(prefix: string): string;
  56538. /** @hidden */
  56539. _excludeVariableName(name: string): void;
  56540. /** @hidden */
  56541. _emit2DSampler(name: string): void;
  56542. /** @hidden */
  56543. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56544. /** @hidden */
  56545. _emitExtension(name: string, extension: string): void;
  56546. /** @hidden */
  56547. _emitFunction(name: string, code: string, comments: string): void;
  56548. /** @hidden */
  56549. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56550. replaceStrings?: {
  56551. search: RegExp;
  56552. replace: string;
  56553. }[];
  56554. repeatKey?: string;
  56555. }): string;
  56556. /** @hidden */
  56557. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56558. repeatKey?: string;
  56559. removeAttributes?: boolean;
  56560. removeUniforms?: boolean;
  56561. removeVaryings?: boolean;
  56562. removeIfDef?: boolean;
  56563. replaceStrings?: {
  56564. search: RegExp;
  56565. replace: string;
  56566. }[];
  56567. }, storeKey?: string): void;
  56568. /** @hidden */
  56569. _registerTempVariable(name: string): boolean;
  56570. /** @hidden */
  56571. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56572. /** @hidden */
  56573. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56574. /** @hidden */
  56575. _emitFloat(value: number): string;
  56576. }
  56577. }
  56578. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56579. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56581. import { Nullable } from "babylonjs/types";
  56582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56583. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56584. import { Effect } from "babylonjs/Materials/effect";
  56585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56586. import { Mesh } from "babylonjs/Meshes/mesh";
  56587. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56588. import { Scene } from "babylonjs/scene";
  56589. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56590. /**
  56591. * Defines a block that can be used inside a node based material
  56592. */
  56593. export class NodeMaterialBlock {
  56594. private _buildId;
  56595. private _buildTarget;
  56596. private _target;
  56597. private _isFinalMerger;
  56598. private _isInput;
  56599. /** @hidden */
  56600. _codeVariableName: string;
  56601. /** @hidden */
  56602. _inputs: NodeMaterialConnectionPoint[];
  56603. /** @hidden */
  56604. _outputs: NodeMaterialConnectionPoint[];
  56605. /** @hidden */
  56606. _preparationId: number;
  56607. /**
  56608. * Gets or sets the name of the block
  56609. */
  56610. name: string;
  56611. /**
  56612. * Gets or sets the unique id of the node
  56613. */
  56614. uniqueId: number;
  56615. /**
  56616. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56617. */
  56618. readonly isFinalMerger: boolean;
  56619. /**
  56620. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56621. */
  56622. readonly isInput: boolean;
  56623. /**
  56624. * Gets or sets the build Id
  56625. */
  56626. buildId: number;
  56627. /**
  56628. * Gets or sets the target of the block
  56629. */
  56630. target: NodeMaterialBlockTargets;
  56631. /**
  56632. * Gets the list of input points
  56633. */
  56634. readonly inputs: NodeMaterialConnectionPoint[];
  56635. /** Gets the list of output points */
  56636. readonly outputs: NodeMaterialConnectionPoint[];
  56637. /**
  56638. * Find an input by its name
  56639. * @param name defines the name of the input to look for
  56640. * @returns the input or null if not found
  56641. */
  56642. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56643. /**
  56644. * Find an output by its name
  56645. * @param name defines the name of the outputto look for
  56646. * @returns the output or null if not found
  56647. */
  56648. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56649. /**
  56650. * Creates a new NodeMaterialBlock
  56651. * @param name defines the block name
  56652. * @param target defines the target of that block (Vertex by default)
  56653. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56654. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56655. */
  56656. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56657. /**
  56658. * Initialize the block and prepare the context for build
  56659. * @param state defines the state that will be used for the build
  56660. */
  56661. initialize(state: NodeMaterialBuildState): void;
  56662. /**
  56663. * Bind data to effect. Will only be called for blocks with isBindable === true
  56664. * @param effect defines the effect to bind data to
  56665. * @param nodeMaterial defines the hosting NodeMaterial
  56666. * @param mesh defines the mesh that will be rendered
  56667. */
  56668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56669. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56670. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56671. protected _writeFloat(value: number): string;
  56672. /**
  56673. * Gets the current class name e.g. "NodeMaterialBlock"
  56674. * @returns the class name
  56675. */
  56676. getClassName(): string;
  56677. /**
  56678. * Register a new input. Must be called inside a block constructor
  56679. * @param name defines the connection point name
  56680. * @param type defines the connection point type
  56681. * @param isOptional defines a boolean indicating that this input can be omitted
  56682. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56683. * @returns the current block
  56684. */
  56685. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56686. /**
  56687. * Register a new output. Must be called inside a block constructor
  56688. * @param name defines the connection point name
  56689. * @param type defines the connection point type
  56690. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56691. * @returns the current block
  56692. */
  56693. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56694. /**
  56695. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56696. * @param forOutput defines an optional connection point to check compatibility with
  56697. * @returns the first available input or null
  56698. */
  56699. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56700. /**
  56701. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56702. * @param forBlock defines an optional block to check compatibility with
  56703. * @returns the first available input or null
  56704. */
  56705. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56706. /**
  56707. * Gets the sibling of the given output
  56708. * @param current defines the current output
  56709. * @returns the next output in the list or null
  56710. */
  56711. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56712. /**
  56713. * Connect current block with another block
  56714. * @param other defines the block to connect with
  56715. * @param options define the various options to help pick the right connections
  56716. * @returns the current block
  56717. */
  56718. connectTo(other: NodeMaterialBlock, options?: {
  56719. input?: string;
  56720. output?: string;
  56721. outputSwizzle?: string;
  56722. }): this | undefined;
  56723. protected _buildBlock(state: NodeMaterialBuildState): void;
  56724. /**
  56725. * Add uniforms, samplers and uniform buffers at compilation time
  56726. * @param state defines the state to update
  56727. * @param nodeMaterial defines the node material requesting the update
  56728. * @param defines defines the material defines to update
  56729. * @param uniformBuffers defines the list of uniform buffer names
  56730. */
  56731. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56732. /**
  56733. * Add potential fallbacks if shader compilation fails
  56734. * @param mesh defines the mesh to be rendered
  56735. * @param fallbacks defines the current prioritized list of fallbacks
  56736. */
  56737. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56738. /**
  56739. * Initialize defines for shader compilation
  56740. * @param mesh defines the mesh to be rendered
  56741. * @param nodeMaterial defines the node material requesting the update
  56742. * @param defines defines the material defines to update
  56743. * @param useInstances specifies that instances should be used
  56744. */
  56745. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56746. /**
  56747. * Update defines for shader compilation
  56748. * @param mesh defines the mesh to be rendered
  56749. * @param nodeMaterial defines the node material requesting the update
  56750. * @param defines defines the material defines to update
  56751. * @param useInstances specifies that instances should be used
  56752. */
  56753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56754. /**
  56755. * Lets the block try to connect some inputs automatically
  56756. * @param material defines the hosting NodeMaterial
  56757. */
  56758. autoConfigure(material: NodeMaterial): void;
  56759. /**
  56760. * Function called when a block is declared as repeatable content generator
  56761. * @param vertexShaderState defines the current compilation state for the vertex shader
  56762. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56763. * @param mesh defines the mesh to be rendered
  56764. * @param defines defines the material defines to update
  56765. */
  56766. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56767. /**
  56768. * Checks if the block is ready
  56769. * @param mesh defines the mesh to be rendered
  56770. * @param nodeMaterial defines the node material requesting the update
  56771. * @param defines defines the material defines to update
  56772. * @param useInstances specifies that instances should be used
  56773. * @returns true if the block is ready
  56774. */
  56775. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56776. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56777. private _processBuild;
  56778. /**
  56779. * Compile the current node and generate the shader code
  56780. * @param state defines the current compilation state (uniforms, samplers, current string)
  56781. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56782. * @returns true if already built
  56783. */
  56784. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56785. protected _inputRename(name: string): string;
  56786. protected _outputRename(name: string): string;
  56787. protected _dumpPropertiesCode(): string;
  56788. /** @hidden */
  56789. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56790. /** @hidden */
  56791. _dumpCodeForOutputConnections(): string;
  56792. /**
  56793. * Clone the current block to a new identical block
  56794. * @param scene defines the hosting scene
  56795. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56796. * @returns a copy of the current block
  56797. */
  56798. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56799. /**
  56800. * Serializes this block in a JSON representation
  56801. * @returns the serialized block object
  56802. */
  56803. serialize(): any;
  56804. /** @hidden */
  56805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56806. /**
  56807. * Release resources
  56808. */
  56809. dispose(): void;
  56810. }
  56811. }
  56812. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56813. /**
  56814. * Enum defining the type of animations supported by InputBlock
  56815. */
  56816. export enum AnimatedInputBlockTypes {
  56817. /** No animation */
  56818. None = 0,
  56819. /** Time based animation. Will only work for floats */
  56820. Time = 1
  56821. }
  56822. }
  56823. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56825. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56826. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56827. import { Nullable } from "babylonjs/types";
  56828. import { Effect } from "babylonjs/Materials/effect";
  56829. import { Matrix } from "babylonjs/Maths/math.vector";
  56830. import { Scene } from "babylonjs/scene";
  56831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56833. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56834. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56835. /**
  56836. * Block used to expose an input value
  56837. */
  56838. export class InputBlock extends NodeMaterialBlock {
  56839. private _mode;
  56840. private _associatedVariableName;
  56841. private _storedValue;
  56842. private _valueCallback;
  56843. private _type;
  56844. private _animationType;
  56845. /** Gets or set a value used to limit the range of float values */
  56846. min: number;
  56847. /** Gets or set a value used to limit the range of float values */
  56848. max: number;
  56849. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56850. matrixMode: number;
  56851. /** @hidden */
  56852. _systemValue: Nullable<NodeMaterialSystemValues>;
  56853. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56854. visibleInInspector: boolean;
  56855. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56856. isConstant: boolean;
  56857. /**
  56858. * Gets or sets the connection point type (default is float)
  56859. */
  56860. readonly type: NodeMaterialBlockConnectionPointTypes;
  56861. /**
  56862. * Creates a new InputBlock
  56863. * @param name defines the block name
  56864. * @param target defines the target of that block (Vertex by default)
  56865. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56866. */
  56867. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56868. /**
  56869. * Gets the output component
  56870. */
  56871. readonly output: NodeMaterialConnectionPoint;
  56872. /**
  56873. * Set the source of this connection point to a vertex attribute
  56874. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56875. * @returns the current connection point
  56876. */
  56877. setAsAttribute(attributeName?: string): InputBlock;
  56878. /**
  56879. * Set the source of this connection point to a system value
  56880. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56881. * @returns the current connection point
  56882. */
  56883. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56884. /**
  56885. * Gets or sets the value of that point.
  56886. * Please note that this value will be ignored if valueCallback is defined
  56887. */
  56888. value: any;
  56889. /**
  56890. * Gets or sets a callback used to get the value of that point.
  56891. * Please note that setting this value will force the connection point to ignore the value property
  56892. */
  56893. valueCallback: () => any;
  56894. /**
  56895. * Gets or sets the associated variable name in the shader
  56896. */
  56897. associatedVariableName: string;
  56898. /** Gets or sets the type of animation applied to the input */
  56899. animationType: AnimatedInputBlockTypes;
  56900. /**
  56901. * Gets a boolean indicating that this connection point not defined yet
  56902. */
  56903. readonly isUndefined: boolean;
  56904. /**
  56905. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56906. * In this case the connection point name must be the name of the uniform to use.
  56907. * Can only be set on inputs
  56908. */
  56909. isUniform: boolean;
  56910. /**
  56911. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56912. * In this case the connection point name must be the name of the attribute to use
  56913. * Can only be set on inputs
  56914. */
  56915. isAttribute: boolean;
  56916. /**
  56917. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56918. * Can only be set on exit points
  56919. */
  56920. isVarying: boolean;
  56921. /**
  56922. * Gets a boolean indicating that the current connection point is a system value
  56923. */
  56924. readonly isSystemValue: boolean;
  56925. /**
  56926. * Gets or sets the current well known value or null if not defined as a system value
  56927. */
  56928. systemValue: Nullable<NodeMaterialSystemValues>;
  56929. /**
  56930. * Gets the current class name
  56931. * @returns the class name
  56932. */
  56933. getClassName(): string;
  56934. /**
  56935. * Animate the input if animationType !== None
  56936. * @param scene defines the rendering scene
  56937. */
  56938. animate(scene: Scene): void;
  56939. private _emitDefine;
  56940. initialize(state: NodeMaterialBuildState): void;
  56941. /**
  56942. * Set the input block to its default value (based on its type)
  56943. */
  56944. setDefaultValue(): void;
  56945. private _emitConstant;
  56946. private _emit;
  56947. /** @hidden */
  56948. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56949. /** @hidden */
  56950. _transmit(effect: Effect, scene: Scene): void;
  56951. protected _buildBlock(state: NodeMaterialBuildState): void;
  56952. protected _dumpPropertiesCode(): string;
  56953. serialize(): any;
  56954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56955. }
  56956. }
  56957. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56958. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56959. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56960. import { Nullable } from "babylonjs/types";
  56961. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56962. import { Observable } from "babylonjs/Misc/observable";
  56963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56964. /**
  56965. * Defines a connection point for a block
  56966. */
  56967. export class NodeMaterialConnectionPoint {
  56968. /** @hidden */
  56969. _ownerBlock: NodeMaterialBlock;
  56970. /** @hidden */
  56971. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56972. private _endpoints;
  56973. private _associatedVariableName;
  56974. /** @hidden */
  56975. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56976. /** @hidden */
  56977. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56978. private _type;
  56979. /** @hidden */
  56980. _enforceAssociatedVariableName: boolean;
  56981. /**
  56982. * Gets or sets the additional types supported by this connection point
  56983. */
  56984. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56985. /**
  56986. * Gets or sets the additional types excluded by this connection point
  56987. */
  56988. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56989. /**
  56990. * Observable triggered when this point is connected
  56991. */
  56992. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56993. /**
  56994. * Gets or sets the associated variable name in the shader
  56995. */
  56996. associatedVariableName: string;
  56997. /**
  56998. * Gets or sets the connection point type (default is float)
  56999. */
  57000. type: NodeMaterialBlockConnectionPointTypes;
  57001. /**
  57002. * Gets or sets the connection point name
  57003. */
  57004. name: string;
  57005. /**
  57006. * Gets or sets a boolean indicating that this connection point can be omitted
  57007. */
  57008. isOptional: boolean;
  57009. /**
  57010. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57011. */
  57012. define: string;
  57013. /** @hidden */
  57014. _prioritizeVertex: boolean;
  57015. private _target;
  57016. /** Gets or sets the target of that connection point */
  57017. target: NodeMaterialBlockTargets;
  57018. /**
  57019. * Gets a boolean indicating that the current point is connected
  57020. */
  57021. readonly isConnected: boolean;
  57022. /**
  57023. * Gets a boolean indicating that the current point is connected to an input block
  57024. */
  57025. readonly isConnectedToInputBlock: boolean;
  57026. /**
  57027. * Gets a the connected input block (if any)
  57028. */
  57029. readonly connectInputBlock: Nullable<InputBlock>;
  57030. /** Get the other side of the connection (if any) */
  57031. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57032. /** Get the block that owns this connection point */
  57033. readonly ownerBlock: NodeMaterialBlock;
  57034. /** Get the block connected on the other side of this connection (if any) */
  57035. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57036. /** Get the block connected on the endpoints of this connection (if any) */
  57037. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57038. /** Gets the list of connected endpoints */
  57039. readonly endpoints: NodeMaterialConnectionPoint[];
  57040. /** Gets a boolean indicating if that output point is connected to at least one input */
  57041. readonly hasEndpoints: boolean;
  57042. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57043. readonly isConnectedInVertexShader: boolean;
  57044. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57045. readonly isConnectedInFragmentShader: boolean;
  57046. /**
  57047. * Creates a new connection point
  57048. * @param name defines the connection point name
  57049. * @param ownerBlock defines the block hosting this connection point
  57050. */
  57051. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57052. /**
  57053. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57054. * @returns the class name
  57055. */
  57056. getClassName(): string;
  57057. /**
  57058. * Gets an boolean indicating if the current point can be connected to another point
  57059. * @param connectionPoint defines the other connection point
  57060. * @returns true if the connection is possible
  57061. */
  57062. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57063. /**
  57064. * Connect this point to another connection point
  57065. * @param connectionPoint defines the other connection point
  57066. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57067. * @returns the current connection point
  57068. */
  57069. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57070. /**
  57071. * Disconnect this point from one of his endpoint
  57072. * @param endpoint defines the other connection point
  57073. * @returns the current connection point
  57074. */
  57075. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57076. /**
  57077. * Serializes this point in a JSON representation
  57078. * @returns the serialized point object
  57079. */
  57080. serialize(): any;
  57081. /**
  57082. * Release resources
  57083. */
  57084. dispose(): void;
  57085. }
  57086. }
  57087. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57091. import { Mesh } from "babylonjs/Meshes/mesh";
  57092. import { Effect } from "babylonjs/Materials/effect";
  57093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57094. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57095. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57096. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57097. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57098. /**
  57099. * Block used to add support for vertex skinning (bones)
  57100. */
  57101. export class BonesBlock extends NodeMaterialBlock {
  57102. /**
  57103. * Creates a new BonesBlock
  57104. * @param name defines the block name
  57105. */
  57106. constructor(name: string);
  57107. /**
  57108. * Initialize the block and prepare the context for build
  57109. * @param state defines the state that will be used for the build
  57110. */
  57111. initialize(state: NodeMaterialBuildState): void;
  57112. /**
  57113. * Gets the current class name
  57114. * @returns the class name
  57115. */
  57116. getClassName(): string;
  57117. /**
  57118. * Gets the matrix indices input component
  57119. */
  57120. readonly matricesIndices: NodeMaterialConnectionPoint;
  57121. /**
  57122. * Gets the matrix weights input component
  57123. */
  57124. readonly matricesWeights: NodeMaterialConnectionPoint;
  57125. /**
  57126. * Gets the extra matrix indices input component
  57127. */
  57128. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57129. /**
  57130. * Gets the extra matrix weights input component
  57131. */
  57132. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57133. /**
  57134. * Gets the world input component
  57135. */
  57136. readonly world: NodeMaterialConnectionPoint;
  57137. /**
  57138. * Gets the output component
  57139. */
  57140. readonly output: NodeMaterialConnectionPoint;
  57141. autoConfigure(material: NodeMaterial): void;
  57142. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57143. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57145. protected _buildBlock(state: NodeMaterialBuildState): this;
  57146. }
  57147. }
  57148. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57153. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57154. /**
  57155. * Block used to add support for instances
  57156. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57157. */
  57158. export class InstancesBlock extends NodeMaterialBlock {
  57159. /**
  57160. * Creates a new InstancesBlock
  57161. * @param name defines the block name
  57162. */
  57163. constructor(name: string);
  57164. /**
  57165. * Gets the current class name
  57166. * @returns the class name
  57167. */
  57168. getClassName(): string;
  57169. /**
  57170. * Gets the first world row input component
  57171. */
  57172. readonly world0: NodeMaterialConnectionPoint;
  57173. /**
  57174. * Gets the second world row input component
  57175. */
  57176. readonly world1: NodeMaterialConnectionPoint;
  57177. /**
  57178. * Gets the third world row input component
  57179. */
  57180. readonly world2: NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the forth world row input component
  57183. */
  57184. readonly world3: NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the world input component
  57187. */
  57188. readonly world: NodeMaterialConnectionPoint;
  57189. /**
  57190. * Gets the output component
  57191. */
  57192. readonly output: NodeMaterialConnectionPoint;
  57193. autoConfigure(material: NodeMaterial): void;
  57194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57195. protected _buildBlock(state: NodeMaterialBuildState): this;
  57196. }
  57197. }
  57198. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57203. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57204. import { Effect } from "babylonjs/Materials/effect";
  57205. import { Mesh } from "babylonjs/Meshes/mesh";
  57206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57207. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57208. /**
  57209. * Block used to add morph targets support to vertex shader
  57210. */
  57211. export class MorphTargetsBlock extends NodeMaterialBlock {
  57212. private _repeatableContentAnchor;
  57213. private _repeatebleContentGenerated;
  57214. /**
  57215. * Create a new MorphTargetsBlock
  57216. * @param name defines the block name
  57217. */
  57218. constructor(name: string);
  57219. /**
  57220. * Gets the current class name
  57221. * @returns the class name
  57222. */
  57223. getClassName(): string;
  57224. /**
  57225. * Gets the position input component
  57226. */
  57227. readonly position: NodeMaterialConnectionPoint;
  57228. /**
  57229. * Gets the normal input component
  57230. */
  57231. readonly normal: NodeMaterialConnectionPoint;
  57232. /**
  57233. * Gets the tangent input component
  57234. */
  57235. readonly tangent: NodeMaterialConnectionPoint;
  57236. /**
  57237. * Gets the tangent input component
  57238. */
  57239. readonly uv: NodeMaterialConnectionPoint;
  57240. /**
  57241. * Gets the position output component
  57242. */
  57243. readonly positionOutput: NodeMaterialConnectionPoint;
  57244. /**
  57245. * Gets the normal output component
  57246. */
  57247. readonly normalOutput: NodeMaterialConnectionPoint;
  57248. /**
  57249. * Gets the tangent output component
  57250. */
  57251. readonly tangentOutput: NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the tangent output component
  57254. */
  57255. readonly uvOutput: NodeMaterialConnectionPoint;
  57256. initialize(state: NodeMaterialBuildState): void;
  57257. autoConfigure(material: NodeMaterial): void;
  57258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57259. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57260. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57261. protected _buildBlock(state: NodeMaterialBuildState): this;
  57262. }
  57263. }
  57264. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57268. import { Nullable } from "babylonjs/types";
  57269. import { Scene } from "babylonjs/scene";
  57270. import { Effect } from "babylonjs/Materials/effect";
  57271. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57272. import { Mesh } from "babylonjs/Meshes/mesh";
  57273. import { Light } from "babylonjs/Lights/light";
  57274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57275. /**
  57276. * Block used to get data information from a light
  57277. */
  57278. export class LightInformationBlock extends NodeMaterialBlock {
  57279. private _lightDataUniformName;
  57280. private _lightColorUniformName;
  57281. private _lightTypeDefineName;
  57282. /**
  57283. * Gets or sets the light associated with this block
  57284. */
  57285. light: Nullable<Light>;
  57286. /**
  57287. * Creates a new LightInformationBlock
  57288. * @param name defines the block name
  57289. */
  57290. constructor(name: string);
  57291. /**
  57292. * Gets the current class name
  57293. * @returns the class name
  57294. */
  57295. getClassName(): string;
  57296. /**
  57297. * Gets the world position input component
  57298. */
  57299. readonly worldPosition: NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the direction output component
  57302. */
  57303. readonly direction: NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the direction output component
  57306. */
  57307. readonly color: NodeMaterialConnectionPoint;
  57308. /**
  57309. * Gets the direction output component
  57310. */
  57311. readonly intensity: NodeMaterialConnectionPoint;
  57312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57314. protected _buildBlock(state: NodeMaterialBuildState): this;
  57315. serialize(): any;
  57316. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57317. }
  57318. }
  57319. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57320. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57321. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57322. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57323. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57324. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57325. }
  57326. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57332. import { Effect } from "babylonjs/Materials/effect";
  57333. import { Mesh } from "babylonjs/Meshes/mesh";
  57334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57335. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57336. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57337. /**
  57338. * Block used to add image processing support to fragment shader
  57339. */
  57340. export class ImageProcessingBlock extends NodeMaterialBlock {
  57341. /**
  57342. * Create a new ImageProcessingBlock
  57343. * @param name defines the block name
  57344. */
  57345. constructor(name: string);
  57346. /**
  57347. * Gets the current class name
  57348. * @returns the class name
  57349. */
  57350. getClassName(): string;
  57351. /**
  57352. * Gets the color input component
  57353. */
  57354. readonly color: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the output component
  57357. */
  57358. readonly output: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Initialize the block and prepare the context for build
  57361. * @param state defines the state that will be used for the build
  57362. */
  57363. initialize(state: NodeMaterialBuildState): void;
  57364. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57367. protected _buildBlock(state: NodeMaterialBuildState): this;
  57368. }
  57369. }
  57370. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57374. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57376. import { Effect } from "babylonjs/Materials/effect";
  57377. import { Mesh } from "babylonjs/Meshes/mesh";
  57378. import { Scene } from "babylonjs/scene";
  57379. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57380. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57381. /**
  57382. * Block used to pertub normals based on a normal map
  57383. */
  57384. export class PerturbNormalBlock extends NodeMaterialBlock {
  57385. private _tangentSpaceParameterName;
  57386. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57387. invertX: boolean;
  57388. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57389. invertY: boolean;
  57390. /**
  57391. * Create a new PerturbNormalBlock
  57392. * @param name defines the block name
  57393. */
  57394. constructor(name: string);
  57395. /**
  57396. * Gets the current class name
  57397. * @returns the class name
  57398. */
  57399. getClassName(): string;
  57400. /**
  57401. * Gets the world position input component
  57402. */
  57403. readonly worldPosition: NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the world normal input component
  57406. */
  57407. readonly worldNormal: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the uv input component
  57410. */
  57411. readonly uv: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the normal map color input component
  57414. */
  57415. readonly normalMapColor: NodeMaterialConnectionPoint;
  57416. /**
  57417. * Gets the strength input component
  57418. */
  57419. readonly strength: NodeMaterialConnectionPoint;
  57420. /**
  57421. * Gets the output component
  57422. */
  57423. readonly output: NodeMaterialConnectionPoint;
  57424. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57426. autoConfigure(material: NodeMaterial): void;
  57427. protected _buildBlock(state: NodeMaterialBuildState): this;
  57428. protected _dumpPropertiesCode(): string;
  57429. serialize(): any;
  57430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57431. }
  57432. }
  57433. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57437. /**
  57438. * Block used to discard a pixel if a value is smaller than a cutoff
  57439. */
  57440. export class DiscardBlock extends NodeMaterialBlock {
  57441. /**
  57442. * Create a new DiscardBlock
  57443. * @param name defines the block name
  57444. */
  57445. constructor(name: string);
  57446. /**
  57447. * Gets the current class name
  57448. * @returns the class name
  57449. */
  57450. getClassName(): string;
  57451. /**
  57452. * Gets the color input component
  57453. */
  57454. readonly value: NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the cutoff input component
  57457. */
  57458. readonly cutoff: NodeMaterialConnectionPoint;
  57459. protected _buildBlock(state: NodeMaterialBuildState): this;
  57460. }
  57461. }
  57462. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57463. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57464. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57465. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57466. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57467. }
  57468. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57471. import { Mesh } from "babylonjs/Meshes/mesh";
  57472. import { Effect } from "babylonjs/Materials/effect";
  57473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57475. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57476. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57477. /**
  57478. * Block used to add support for scene fog
  57479. */
  57480. export class FogBlock extends NodeMaterialBlock {
  57481. private _fogDistanceName;
  57482. private _fogParameters;
  57483. /**
  57484. * Create a new FogBlock
  57485. * @param name defines the block name
  57486. */
  57487. constructor(name: string);
  57488. /**
  57489. * Gets the current class name
  57490. * @returns the class name
  57491. */
  57492. getClassName(): string;
  57493. /**
  57494. * Gets the world position input component
  57495. */
  57496. readonly worldPosition: NodeMaterialConnectionPoint;
  57497. /**
  57498. * Gets the view input component
  57499. */
  57500. readonly view: NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the color input component
  57503. */
  57504. readonly input: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the fog color input component
  57507. */
  57508. readonly fogColor: NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the output component
  57511. */
  57512. readonly output: NodeMaterialConnectionPoint;
  57513. autoConfigure(material: NodeMaterial): void;
  57514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57516. protected _buildBlock(state: NodeMaterialBuildState): this;
  57517. }
  57518. }
  57519. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57524. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57525. import { Effect } from "babylonjs/Materials/effect";
  57526. import { Mesh } from "babylonjs/Meshes/mesh";
  57527. import { Light } from "babylonjs/Lights/light";
  57528. import { Nullable } from "babylonjs/types";
  57529. import { Scene } from "babylonjs/scene";
  57530. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57531. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57532. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57533. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57534. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57535. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57536. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57537. /**
  57538. * Block used to add light in the fragment shader
  57539. */
  57540. export class LightBlock extends NodeMaterialBlock {
  57541. private _lightId;
  57542. /**
  57543. * Gets or sets the light associated with this block
  57544. */
  57545. light: Nullable<Light>;
  57546. /**
  57547. * Create a new LightBlock
  57548. * @param name defines the block name
  57549. */
  57550. constructor(name: string);
  57551. /**
  57552. * Gets the current class name
  57553. * @returns the class name
  57554. */
  57555. getClassName(): string;
  57556. /**
  57557. * Gets the world position input component
  57558. */
  57559. readonly worldPosition: NodeMaterialConnectionPoint;
  57560. /**
  57561. * Gets the world normal input component
  57562. */
  57563. readonly worldNormal: NodeMaterialConnectionPoint;
  57564. /**
  57565. * Gets the camera (or eye) position component
  57566. */
  57567. readonly cameraPosition: NodeMaterialConnectionPoint;
  57568. /**
  57569. * Gets the glossiness component
  57570. */
  57571. readonly glossiness: NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the glossinness power component
  57574. */
  57575. readonly glossPower: NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the diffuse color component
  57578. */
  57579. readonly diffuseColor: NodeMaterialConnectionPoint;
  57580. /**
  57581. * Gets the specular color component
  57582. */
  57583. readonly specularColor: NodeMaterialConnectionPoint;
  57584. /**
  57585. * Gets the diffuse output component
  57586. */
  57587. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57588. /**
  57589. * Gets the specular output component
  57590. */
  57591. readonly specularOutput: NodeMaterialConnectionPoint;
  57592. autoConfigure(material: NodeMaterial): void;
  57593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57594. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57596. private _injectVertexCode;
  57597. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57598. serialize(): any;
  57599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57600. }
  57601. }
  57602. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57603. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57604. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57605. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57606. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57607. }
  57608. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57609. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57610. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57611. }
  57612. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57616. /**
  57617. * Block used to multiply 2 values
  57618. */
  57619. export class MultiplyBlock extends NodeMaterialBlock {
  57620. /**
  57621. * Creates a new MultiplyBlock
  57622. * @param name defines the block name
  57623. */
  57624. constructor(name: string);
  57625. /**
  57626. * Gets the current class name
  57627. * @returns the class name
  57628. */
  57629. getClassName(): string;
  57630. /**
  57631. * Gets the left operand input component
  57632. */
  57633. readonly left: NodeMaterialConnectionPoint;
  57634. /**
  57635. * Gets the right operand input component
  57636. */
  57637. readonly right: NodeMaterialConnectionPoint;
  57638. /**
  57639. * Gets the output component
  57640. */
  57641. readonly output: NodeMaterialConnectionPoint;
  57642. protected _buildBlock(state: NodeMaterialBuildState): this;
  57643. }
  57644. }
  57645. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57649. /**
  57650. * Block used to add 2 vectors
  57651. */
  57652. export class AddBlock extends NodeMaterialBlock {
  57653. /**
  57654. * Creates a new AddBlock
  57655. * @param name defines the block name
  57656. */
  57657. constructor(name: string);
  57658. /**
  57659. * Gets the current class name
  57660. * @returns the class name
  57661. */
  57662. getClassName(): string;
  57663. /**
  57664. * Gets the left operand input component
  57665. */
  57666. readonly left: NodeMaterialConnectionPoint;
  57667. /**
  57668. * Gets the right operand input component
  57669. */
  57670. readonly right: NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the output component
  57673. */
  57674. readonly output: NodeMaterialConnectionPoint;
  57675. protected _buildBlock(state: NodeMaterialBuildState): this;
  57676. }
  57677. }
  57678. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57682. /**
  57683. * Block used to scale a vector by a float
  57684. */
  57685. export class ScaleBlock extends NodeMaterialBlock {
  57686. /**
  57687. * Creates a new ScaleBlock
  57688. * @param name defines the block name
  57689. */
  57690. constructor(name: string);
  57691. /**
  57692. * Gets the current class name
  57693. * @returns the class name
  57694. */
  57695. getClassName(): string;
  57696. /**
  57697. * Gets the input component
  57698. */
  57699. readonly input: NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the factor input component
  57702. */
  57703. readonly factor: NodeMaterialConnectionPoint;
  57704. /**
  57705. * Gets the output component
  57706. */
  57707. readonly output: NodeMaterialConnectionPoint;
  57708. protected _buildBlock(state: NodeMaterialBuildState): this;
  57709. }
  57710. }
  57711. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57715. import { Scene } from "babylonjs/scene";
  57716. /**
  57717. * Block used to clamp a float
  57718. */
  57719. export class ClampBlock extends NodeMaterialBlock {
  57720. /** Gets or sets the minimum range */
  57721. minimum: number;
  57722. /** Gets or sets the maximum range */
  57723. maximum: number;
  57724. /**
  57725. * Creates a new ClampBlock
  57726. * @param name defines the block name
  57727. */
  57728. constructor(name: string);
  57729. /**
  57730. * Gets the current class name
  57731. * @returns the class name
  57732. */
  57733. getClassName(): string;
  57734. /**
  57735. * Gets the value input component
  57736. */
  57737. readonly value: NodeMaterialConnectionPoint;
  57738. /**
  57739. * Gets the output component
  57740. */
  57741. readonly output: NodeMaterialConnectionPoint;
  57742. protected _buildBlock(state: NodeMaterialBuildState): this;
  57743. protected _dumpPropertiesCode(): string;
  57744. serialize(): any;
  57745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57746. }
  57747. }
  57748. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57752. /**
  57753. * Block used to apply a cross product between 2 vectors
  57754. */
  57755. export class CrossBlock extends NodeMaterialBlock {
  57756. /**
  57757. * Creates a new CrossBlock
  57758. * @param name defines the block name
  57759. */
  57760. constructor(name: string);
  57761. /**
  57762. * Gets the current class name
  57763. * @returns the class name
  57764. */
  57765. getClassName(): string;
  57766. /**
  57767. * Gets the left operand input component
  57768. */
  57769. readonly left: NodeMaterialConnectionPoint;
  57770. /**
  57771. * Gets the right operand input component
  57772. */
  57773. readonly right: NodeMaterialConnectionPoint;
  57774. /**
  57775. * Gets the output component
  57776. */
  57777. readonly output: NodeMaterialConnectionPoint;
  57778. protected _buildBlock(state: NodeMaterialBuildState): this;
  57779. }
  57780. }
  57781. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57785. /**
  57786. * Block used to apply a dot product between 2 vectors
  57787. */
  57788. export class DotBlock extends NodeMaterialBlock {
  57789. /**
  57790. * Creates a new DotBlock
  57791. * @param name defines the block name
  57792. */
  57793. constructor(name: string);
  57794. /**
  57795. * Gets the current class name
  57796. * @returns the class name
  57797. */
  57798. getClassName(): string;
  57799. /**
  57800. * Gets the left operand input component
  57801. */
  57802. readonly left: NodeMaterialConnectionPoint;
  57803. /**
  57804. * Gets the right operand input component
  57805. */
  57806. readonly right: NodeMaterialConnectionPoint;
  57807. /**
  57808. * Gets the output component
  57809. */
  57810. readonly output: NodeMaterialConnectionPoint;
  57811. protected _buildBlock(state: NodeMaterialBuildState): this;
  57812. }
  57813. }
  57814. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57818. import { Vector2 } from "babylonjs/Maths/math.vector";
  57819. import { Scene } from "babylonjs/scene";
  57820. /**
  57821. * Block used to remap a float from a range to a new one
  57822. */
  57823. export class RemapBlock extends NodeMaterialBlock {
  57824. /**
  57825. * Gets or sets the source range
  57826. */
  57827. sourceRange: Vector2;
  57828. /**
  57829. * Gets or sets the target range
  57830. */
  57831. targetRange: Vector2;
  57832. /**
  57833. * Creates a new RemapBlock
  57834. * @param name defines the block name
  57835. */
  57836. constructor(name: string);
  57837. /**
  57838. * Gets the current class name
  57839. * @returns the class name
  57840. */
  57841. getClassName(): string;
  57842. /**
  57843. * Gets the input component
  57844. */
  57845. readonly input: NodeMaterialConnectionPoint;
  57846. /**
  57847. * Gets the source min input component
  57848. */
  57849. readonly sourceMin: NodeMaterialConnectionPoint;
  57850. /**
  57851. * Gets the source max input component
  57852. */
  57853. readonly sourceMax: NodeMaterialConnectionPoint;
  57854. /**
  57855. * Gets the target min input component
  57856. */
  57857. readonly targetMin: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the target max input component
  57860. */
  57861. readonly targetMax: NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the output component
  57864. */
  57865. readonly output: NodeMaterialConnectionPoint;
  57866. protected _buildBlock(state: NodeMaterialBuildState): this;
  57867. protected _dumpPropertiesCode(): string;
  57868. serialize(): any;
  57869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57870. }
  57871. }
  57872. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57876. /**
  57877. * Block used to normalize a vector
  57878. */
  57879. export class NormalizeBlock extends NodeMaterialBlock {
  57880. /**
  57881. * Creates a new NormalizeBlock
  57882. * @param name defines the block name
  57883. */
  57884. constructor(name: string);
  57885. /**
  57886. * Gets the current class name
  57887. * @returns the class name
  57888. */
  57889. getClassName(): string;
  57890. /**
  57891. * Gets the input component
  57892. */
  57893. readonly input: NodeMaterialConnectionPoint;
  57894. /**
  57895. * Gets the output component
  57896. */
  57897. readonly output: NodeMaterialConnectionPoint;
  57898. protected _buildBlock(state: NodeMaterialBuildState): this;
  57899. }
  57900. }
  57901. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57905. import { Scene } from "babylonjs/scene";
  57906. /**
  57907. * Operations supported by the Trigonometry block
  57908. */
  57909. export enum TrigonometryBlockOperations {
  57910. /** Cos */
  57911. Cos = 0,
  57912. /** Sin */
  57913. Sin = 1,
  57914. /** Abs */
  57915. Abs = 2,
  57916. /** Exp */
  57917. Exp = 3,
  57918. /** Exp2 */
  57919. Exp2 = 4,
  57920. /** Round */
  57921. Round = 5,
  57922. /** Floor */
  57923. Floor = 6,
  57924. /** Ceiling */
  57925. Ceiling = 7,
  57926. /** Square root */
  57927. Sqrt = 8,
  57928. /** Log */
  57929. Log = 9,
  57930. /** Tangent */
  57931. Tan = 10,
  57932. /** Arc tangent */
  57933. ArcTan = 11,
  57934. /** Arc cosinus */
  57935. ArcCos = 12,
  57936. /** Arc sinus */
  57937. ArcSin = 13,
  57938. /** Fraction */
  57939. Fract = 14,
  57940. /** Sign */
  57941. Sign = 15,
  57942. /** To radians (from degrees) */
  57943. Radians = 16,
  57944. /** To degrees (from radians) */
  57945. Degrees = 17
  57946. }
  57947. /**
  57948. * Block used to apply trigonometry operation to floats
  57949. */
  57950. export class TrigonometryBlock extends NodeMaterialBlock {
  57951. /**
  57952. * Gets or sets the operation applied by the block
  57953. */
  57954. operation: TrigonometryBlockOperations;
  57955. /**
  57956. * Creates a new TrigonometryBlock
  57957. * @param name defines the block name
  57958. */
  57959. constructor(name: string);
  57960. /**
  57961. * Gets the current class name
  57962. * @returns the class name
  57963. */
  57964. getClassName(): string;
  57965. /**
  57966. * Gets the input component
  57967. */
  57968. readonly input: NodeMaterialConnectionPoint;
  57969. /**
  57970. * Gets the output component
  57971. */
  57972. readonly output: NodeMaterialConnectionPoint;
  57973. protected _buildBlock(state: NodeMaterialBuildState): this;
  57974. serialize(): any;
  57975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57976. }
  57977. }
  57978. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57982. /**
  57983. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57984. */
  57985. export class ColorMergerBlock extends NodeMaterialBlock {
  57986. /**
  57987. * Create a new ColorMergerBlock
  57988. * @param name defines the block name
  57989. */
  57990. constructor(name: string);
  57991. /**
  57992. * Gets the current class name
  57993. * @returns the class name
  57994. */
  57995. getClassName(): string;
  57996. /**
  57997. * Gets the r component (input)
  57998. */
  57999. readonly r: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the g component (input)
  58002. */
  58003. readonly g: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the b component (input)
  58006. */
  58007. readonly b: NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the a component (input)
  58010. */
  58011. readonly a: NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the rgba component (output)
  58014. */
  58015. readonly rgba: NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the rgb component (output)
  58018. */
  58019. readonly rgb: NodeMaterialConnectionPoint;
  58020. protected _buildBlock(state: NodeMaterialBuildState): this;
  58021. }
  58022. }
  58023. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58027. /**
  58028. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58029. */
  58030. export class VectorMergerBlock extends NodeMaterialBlock {
  58031. /**
  58032. * Create a new VectorMergerBlock
  58033. * @param name defines the block name
  58034. */
  58035. constructor(name: string);
  58036. /**
  58037. * Gets the current class name
  58038. * @returns the class name
  58039. */
  58040. getClassName(): string;
  58041. /**
  58042. * Gets the x component (input)
  58043. */
  58044. readonly x: NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the y component (input)
  58047. */
  58048. readonly y: NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the z component (input)
  58051. */
  58052. readonly z: NodeMaterialConnectionPoint;
  58053. /**
  58054. * Gets the w component (input)
  58055. */
  58056. readonly w: NodeMaterialConnectionPoint;
  58057. /**
  58058. * Gets the xyzw component (output)
  58059. */
  58060. readonly xyzw: NodeMaterialConnectionPoint;
  58061. /**
  58062. * Gets the xyz component (output)
  58063. */
  58064. readonly xyz: NodeMaterialConnectionPoint;
  58065. /**
  58066. * Gets the xy component (output)
  58067. */
  58068. readonly xy: NodeMaterialConnectionPoint;
  58069. protected _buildBlock(state: NodeMaterialBuildState): this;
  58070. }
  58071. }
  58072. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58076. /**
  58077. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58078. */
  58079. export class ColorSplitterBlock extends NodeMaterialBlock {
  58080. /**
  58081. * Create a new ColorSplitterBlock
  58082. * @param name defines the block name
  58083. */
  58084. constructor(name: string);
  58085. /**
  58086. * Gets the current class name
  58087. * @returns the class name
  58088. */
  58089. getClassName(): string;
  58090. /**
  58091. * Gets the rgba component (input)
  58092. */
  58093. readonly rgba: NodeMaterialConnectionPoint;
  58094. /**
  58095. * Gets the rgb component (input)
  58096. */
  58097. readonly rgbIn: NodeMaterialConnectionPoint;
  58098. /**
  58099. * Gets the rgb component (output)
  58100. */
  58101. readonly rgbOut: NodeMaterialConnectionPoint;
  58102. /**
  58103. * Gets the r component (output)
  58104. */
  58105. readonly r: NodeMaterialConnectionPoint;
  58106. /**
  58107. * Gets the g component (output)
  58108. */
  58109. readonly g: NodeMaterialConnectionPoint;
  58110. /**
  58111. * Gets the b component (output)
  58112. */
  58113. readonly b: NodeMaterialConnectionPoint;
  58114. /**
  58115. * Gets the a component (output)
  58116. */
  58117. readonly a: NodeMaterialConnectionPoint;
  58118. protected _inputRename(name: string): string;
  58119. protected _outputRename(name: string): string;
  58120. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58121. }
  58122. }
  58123. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58127. /**
  58128. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58129. */
  58130. export class VectorSplitterBlock extends NodeMaterialBlock {
  58131. /**
  58132. * Create a new VectorSplitterBlock
  58133. * @param name defines the block name
  58134. */
  58135. constructor(name: string);
  58136. /**
  58137. * Gets the current class name
  58138. * @returns the class name
  58139. */
  58140. getClassName(): string;
  58141. /**
  58142. * Gets the xyzw component (input)
  58143. */
  58144. readonly xyzw: NodeMaterialConnectionPoint;
  58145. /**
  58146. * Gets the xyz component (input)
  58147. */
  58148. readonly xyzIn: NodeMaterialConnectionPoint;
  58149. /**
  58150. * Gets the xy component (input)
  58151. */
  58152. readonly xyIn: NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the xyz component (output)
  58155. */
  58156. readonly xyzOut: NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the xy component (output)
  58159. */
  58160. readonly xyOut: NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the x component (output)
  58163. */
  58164. readonly x: NodeMaterialConnectionPoint;
  58165. /**
  58166. * Gets the y component (output)
  58167. */
  58168. readonly y: NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the z component (output)
  58171. */
  58172. readonly z: NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the w component (output)
  58175. */
  58176. readonly w: NodeMaterialConnectionPoint;
  58177. protected _inputRename(name: string): string;
  58178. protected _outputRename(name: string): string;
  58179. protected _buildBlock(state: NodeMaterialBuildState): this;
  58180. }
  58181. }
  58182. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58183. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58185. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58186. /**
  58187. * Block used to lerp between 2 values
  58188. */
  58189. export class LerpBlock extends NodeMaterialBlock {
  58190. /**
  58191. * Creates a new LerpBlock
  58192. * @param name defines the block name
  58193. */
  58194. constructor(name: string);
  58195. /**
  58196. * Gets the current class name
  58197. * @returns the class name
  58198. */
  58199. getClassName(): string;
  58200. /**
  58201. * Gets the left operand input component
  58202. */
  58203. readonly left: NodeMaterialConnectionPoint;
  58204. /**
  58205. * Gets the right operand input component
  58206. */
  58207. readonly right: NodeMaterialConnectionPoint;
  58208. /**
  58209. * Gets the gradient operand input component
  58210. */
  58211. readonly gradient: NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the output component
  58214. */
  58215. readonly output: NodeMaterialConnectionPoint;
  58216. protected _buildBlock(state: NodeMaterialBuildState): this;
  58217. }
  58218. }
  58219. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58222. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58223. /**
  58224. * Block used to divide 2 vectors
  58225. */
  58226. export class DivideBlock extends NodeMaterialBlock {
  58227. /**
  58228. * Creates a new DivideBlock
  58229. * @param name defines the block name
  58230. */
  58231. constructor(name: string);
  58232. /**
  58233. * Gets the current class name
  58234. * @returns the class name
  58235. */
  58236. getClassName(): string;
  58237. /**
  58238. * Gets the left operand input component
  58239. */
  58240. readonly left: NodeMaterialConnectionPoint;
  58241. /**
  58242. * Gets the right operand input component
  58243. */
  58244. readonly right: NodeMaterialConnectionPoint;
  58245. /**
  58246. * Gets the output component
  58247. */
  58248. readonly output: NodeMaterialConnectionPoint;
  58249. protected _buildBlock(state: NodeMaterialBuildState): this;
  58250. }
  58251. }
  58252. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58256. /**
  58257. * Block used to subtract 2 vectors
  58258. */
  58259. export class SubtractBlock extends NodeMaterialBlock {
  58260. /**
  58261. * Creates a new SubtractBlock
  58262. * @param name defines the block name
  58263. */
  58264. constructor(name: string);
  58265. /**
  58266. * Gets the current class name
  58267. * @returns the class name
  58268. */
  58269. getClassName(): string;
  58270. /**
  58271. * Gets the left operand input component
  58272. */
  58273. readonly left: NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the right operand input component
  58276. */
  58277. readonly right: NodeMaterialConnectionPoint;
  58278. /**
  58279. * Gets the output component
  58280. */
  58281. readonly output: NodeMaterialConnectionPoint;
  58282. protected _buildBlock(state: NodeMaterialBuildState): this;
  58283. }
  58284. }
  58285. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58288. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58289. /**
  58290. * Block used to step a value
  58291. */
  58292. export class StepBlock extends NodeMaterialBlock {
  58293. /**
  58294. * Creates a new StepBlock
  58295. * @param name defines the block name
  58296. */
  58297. constructor(name: string);
  58298. /**
  58299. * Gets the current class name
  58300. * @returns the class name
  58301. */
  58302. getClassName(): string;
  58303. /**
  58304. * Gets the value operand input component
  58305. */
  58306. readonly value: NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the edge operand input component
  58309. */
  58310. readonly edge: NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the output component
  58313. */
  58314. readonly output: NodeMaterialConnectionPoint;
  58315. protected _buildBlock(state: NodeMaterialBuildState): this;
  58316. }
  58317. }
  58318. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58322. /**
  58323. * Block used to get the opposite (1 - x) of a value
  58324. */
  58325. export class OneMinusBlock extends NodeMaterialBlock {
  58326. /**
  58327. * Creates a new OneMinusBlock
  58328. * @param name defines the block name
  58329. */
  58330. constructor(name: string);
  58331. /**
  58332. * Gets the current class name
  58333. * @returns the class name
  58334. */
  58335. getClassName(): string;
  58336. /**
  58337. * Gets the input component
  58338. */
  58339. readonly input: 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/viewDirectionBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58352. /**
  58353. * Block used to get the view direction
  58354. */
  58355. export class ViewDirectionBlock extends NodeMaterialBlock {
  58356. /**
  58357. * Creates a new ViewDirectionBlock
  58358. * @param name defines the block name
  58359. */
  58360. constructor(name: string);
  58361. /**
  58362. * Gets the current class name
  58363. * @returns the class name
  58364. */
  58365. getClassName(): string;
  58366. /**
  58367. * Gets the world position component
  58368. */
  58369. readonly worldPosition: NodeMaterialConnectionPoint;
  58370. /**
  58371. * Gets the camera position component
  58372. */
  58373. readonly cameraPosition: NodeMaterialConnectionPoint;
  58374. /**
  58375. * Gets the output component
  58376. */
  58377. readonly output: NodeMaterialConnectionPoint;
  58378. autoConfigure(material: NodeMaterial): void;
  58379. protected _buildBlock(state: NodeMaterialBuildState): this;
  58380. }
  58381. }
  58382. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58386. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58387. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58388. /**
  58389. * Block used to compute fresnel value
  58390. */
  58391. export class FresnelBlock extends NodeMaterialBlock {
  58392. /**
  58393. * Create a new FresnelBlock
  58394. * @param name defines the block name
  58395. */
  58396. constructor(name: string);
  58397. /**
  58398. * Gets the current class name
  58399. * @returns the class name
  58400. */
  58401. getClassName(): string;
  58402. /**
  58403. * Gets the world normal input component
  58404. */
  58405. readonly worldNormal: NodeMaterialConnectionPoint;
  58406. /**
  58407. * Gets the view direction input component
  58408. */
  58409. readonly viewDirection: NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the bias input component
  58412. */
  58413. readonly bias: NodeMaterialConnectionPoint;
  58414. /**
  58415. * Gets the camera (or eye) position component
  58416. */
  58417. readonly power: NodeMaterialConnectionPoint;
  58418. /**
  58419. * Gets the fresnel output component
  58420. */
  58421. readonly fresnel: NodeMaterialConnectionPoint;
  58422. autoConfigure(material: NodeMaterial): void;
  58423. protected _buildBlock(state: NodeMaterialBuildState): this;
  58424. }
  58425. }
  58426. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58430. /**
  58431. * Block used to get the max of 2 values
  58432. */
  58433. export class MaxBlock extends NodeMaterialBlock {
  58434. /**
  58435. * Creates a new MaxBlock
  58436. * @param name defines the block name
  58437. */
  58438. constructor(name: string);
  58439. /**
  58440. * Gets the current class name
  58441. * @returns the class name
  58442. */
  58443. getClassName(): string;
  58444. /**
  58445. * Gets the left operand input component
  58446. */
  58447. readonly left: NodeMaterialConnectionPoint;
  58448. /**
  58449. * Gets the right operand input component
  58450. */
  58451. readonly right: NodeMaterialConnectionPoint;
  58452. /**
  58453. * Gets the output component
  58454. */
  58455. readonly output: NodeMaterialConnectionPoint;
  58456. protected _buildBlock(state: NodeMaterialBuildState): this;
  58457. }
  58458. }
  58459. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58463. /**
  58464. * Block used to get the min of 2 values
  58465. */
  58466. export class MinBlock extends NodeMaterialBlock {
  58467. /**
  58468. * Creates a new MinBlock
  58469. * @param name defines the block name
  58470. */
  58471. constructor(name: string);
  58472. /**
  58473. * Gets the current class name
  58474. * @returns the class name
  58475. */
  58476. getClassName(): string;
  58477. /**
  58478. * Gets the left operand input component
  58479. */
  58480. readonly left: NodeMaterialConnectionPoint;
  58481. /**
  58482. * Gets the right operand input component
  58483. */
  58484. readonly right: NodeMaterialConnectionPoint;
  58485. /**
  58486. * Gets the output component
  58487. */
  58488. readonly output: NodeMaterialConnectionPoint;
  58489. protected _buildBlock(state: NodeMaterialBuildState): this;
  58490. }
  58491. }
  58492. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58496. /**
  58497. * Block used to get the distance between 2 values
  58498. */
  58499. export class DistanceBlock extends NodeMaterialBlock {
  58500. /**
  58501. * Creates a new DistanceBlock
  58502. * @param name defines the block name
  58503. */
  58504. constructor(name: string);
  58505. /**
  58506. * Gets the current class name
  58507. * @returns the class name
  58508. */
  58509. getClassName(): string;
  58510. /**
  58511. * Gets the left operand input component
  58512. */
  58513. readonly left: NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the right operand input component
  58516. */
  58517. readonly right: NodeMaterialConnectionPoint;
  58518. /**
  58519. * Gets the output component
  58520. */
  58521. readonly output: NodeMaterialConnectionPoint;
  58522. protected _buildBlock(state: NodeMaterialBuildState): this;
  58523. }
  58524. }
  58525. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58529. /**
  58530. * Block used to get the length of a vector
  58531. */
  58532. export class LengthBlock extends NodeMaterialBlock {
  58533. /**
  58534. * Creates a new LengthBlock
  58535. * @param name defines the block name
  58536. */
  58537. constructor(name: string);
  58538. /**
  58539. * Gets the current class name
  58540. * @returns the class name
  58541. */
  58542. getClassName(): string;
  58543. /**
  58544. * Gets the value input component
  58545. */
  58546. readonly value: 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/negateBlock" {
  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 negative version of a value (i.e. x * -1)
  58560. */
  58561. export class NegateBlock extends NodeMaterialBlock {
  58562. /**
  58563. * Creates a new NegateBlock
  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 value input component
  58574. */
  58575. readonly value: NodeMaterialConnectionPoint;
  58576. /**
  58577. * Gets the output component
  58578. */
  58579. readonly output: NodeMaterialConnectionPoint;
  58580. protected _buildBlock(state: NodeMaterialBuildState): this;
  58581. }
  58582. }
  58583. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58587. /**
  58588. * Block used to get the value of the first parameter raised to the power of the second
  58589. */
  58590. export class PowBlock extends NodeMaterialBlock {
  58591. /**
  58592. * Creates a new PowBlock
  58593. * @param name defines the block name
  58594. */
  58595. constructor(name: string);
  58596. /**
  58597. * Gets the current class name
  58598. * @returns the class name
  58599. */
  58600. getClassName(): string;
  58601. /**
  58602. * Gets the value operand input component
  58603. */
  58604. readonly value: NodeMaterialConnectionPoint;
  58605. /**
  58606. * Gets the power operand input component
  58607. */
  58608. readonly power: 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/randomNumberBlock" {
  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. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58621. /**
  58622. * Block used to get a random number
  58623. */
  58624. export class RandomNumberBlock extends NodeMaterialBlock {
  58625. /**
  58626. * Creates a new RandomNumberBlock
  58627. * @param name defines the block name
  58628. */
  58629. constructor(name: string);
  58630. /**
  58631. * Gets the current class name
  58632. * @returns the class name
  58633. */
  58634. getClassName(): string;
  58635. /**
  58636. * Gets the seed input component
  58637. */
  58638. readonly seed: NodeMaterialConnectionPoint;
  58639. /**
  58640. * Gets the output component
  58641. */
  58642. readonly output: NodeMaterialConnectionPoint;
  58643. protected _buildBlock(state: NodeMaterialBuildState): this;
  58644. }
  58645. }
  58646. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58650. /**
  58651. * Block used to compute arc tangent of 2 values
  58652. */
  58653. export class ArcTan2Block extends NodeMaterialBlock {
  58654. /**
  58655. * Creates a new ArcTan2Block
  58656. * @param name defines the block name
  58657. */
  58658. constructor(name: string);
  58659. /**
  58660. * Gets the current class name
  58661. * @returns the class name
  58662. */
  58663. getClassName(): string;
  58664. /**
  58665. * Gets the x operand input component
  58666. */
  58667. readonly x: NodeMaterialConnectionPoint;
  58668. /**
  58669. * Gets the y operand input component
  58670. */
  58671. readonly y: NodeMaterialConnectionPoint;
  58672. /**
  58673. * Gets the output component
  58674. */
  58675. readonly output: NodeMaterialConnectionPoint;
  58676. protected _buildBlock(state: NodeMaterialBuildState): this;
  58677. }
  58678. }
  58679. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58683. /**
  58684. * Block used to smooth step a value
  58685. */
  58686. export class SmoothStepBlock extends NodeMaterialBlock {
  58687. /**
  58688. * Creates a new SmoothStepBlock
  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 value operand input component
  58699. */
  58700. readonly value: NodeMaterialConnectionPoint;
  58701. /**
  58702. * Gets the first edge operand input component
  58703. */
  58704. readonly edge0: NodeMaterialConnectionPoint;
  58705. /**
  58706. * Gets the second edge operand input component
  58707. */
  58708. readonly edge1: NodeMaterialConnectionPoint;
  58709. /**
  58710. * Gets the output component
  58711. */
  58712. readonly output: NodeMaterialConnectionPoint;
  58713. protected _buildBlock(state: NodeMaterialBuildState): this;
  58714. }
  58715. }
  58716. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58720. /**
  58721. * Block used to get the reciprocal (1 / x) of a value
  58722. */
  58723. export class ReciprocalBlock extends NodeMaterialBlock {
  58724. /**
  58725. * Creates a new ReciprocalBlock
  58726. * @param name defines the block name
  58727. */
  58728. constructor(name: string);
  58729. /**
  58730. * Gets the current class name
  58731. * @returns the class name
  58732. */
  58733. getClassName(): string;
  58734. /**
  58735. * Gets the input component
  58736. */
  58737. readonly input: NodeMaterialConnectionPoint;
  58738. /**
  58739. * Gets the output component
  58740. */
  58741. readonly output: NodeMaterialConnectionPoint;
  58742. protected _buildBlock(state: NodeMaterialBuildState): this;
  58743. }
  58744. }
  58745. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58749. /**
  58750. * Block used to replace a color by another one
  58751. */
  58752. export class ReplaceColorBlock extends NodeMaterialBlock {
  58753. /**
  58754. * Creates a new ReplaceColorBlock
  58755. * @param name defines the block name
  58756. */
  58757. constructor(name: string);
  58758. /**
  58759. * Gets the current class name
  58760. * @returns the class name
  58761. */
  58762. getClassName(): string;
  58763. /**
  58764. * Gets the value input component
  58765. */
  58766. readonly value: NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the reference input component
  58769. */
  58770. readonly reference: NodeMaterialConnectionPoint;
  58771. /**
  58772. * Gets the distance input component
  58773. */
  58774. readonly distance: NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the replacement input component
  58777. */
  58778. readonly replacement: NodeMaterialConnectionPoint;
  58779. /**
  58780. * Gets the output component
  58781. */
  58782. readonly output: NodeMaterialConnectionPoint;
  58783. protected _buildBlock(state: NodeMaterialBuildState): this;
  58784. }
  58785. }
  58786. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58790. /**
  58791. * Block used to posterize a value
  58792. * @see https://en.wikipedia.org/wiki/Posterization
  58793. */
  58794. export class PosterizeBlock extends NodeMaterialBlock {
  58795. /**
  58796. * Creates a new PosterizeBlock
  58797. * @param name defines the block name
  58798. */
  58799. constructor(name: string);
  58800. /**
  58801. * Gets the current class name
  58802. * @returns the class name
  58803. */
  58804. getClassName(): string;
  58805. /**
  58806. * Gets the value input component
  58807. */
  58808. readonly value: NodeMaterialConnectionPoint;
  58809. /**
  58810. * Gets the steps input component
  58811. */
  58812. readonly steps: NodeMaterialConnectionPoint;
  58813. /**
  58814. * Gets the output component
  58815. */
  58816. readonly output: NodeMaterialConnectionPoint;
  58817. protected _buildBlock(state: NodeMaterialBuildState): this;
  58818. }
  58819. }
  58820. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58824. import { Scene } from "babylonjs/scene";
  58825. /**
  58826. * Operations supported by the Wave block
  58827. */
  58828. export enum WaveBlockKind {
  58829. /** SawTooth */
  58830. SawTooth = 0,
  58831. /** Square */
  58832. Square = 1,
  58833. /** Triangle */
  58834. Triangle = 2
  58835. }
  58836. /**
  58837. * Block used to apply wave operation to floats
  58838. */
  58839. export class WaveBlock extends NodeMaterialBlock {
  58840. /**
  58841. * Gets or sets the kibnd of wave to be applied by the block
  58842. */
  58843. kind: WaveBlockKind;
  58844. /**
  58845. * Creates a new WaveBlock
  58846. * @param name defines the block name
  58847. */
  58848. constructor(name: string);
  58849. /**
  58850. * Gets the current class name
  58851. * @returns the class name
  58852. */
  58853. getClassName(): string;
  58854. /**
  58855. * Gets the input component
  58856. */
  58857. readonly input: NodeMaterialConnectionPoint;
  58858. /**
  58859. * Gets the output component
  58860. */
  58861. readonly output: NodeMaterialConnectionPoint;
  58862. protected _buildBlock(state: NodeMaterialBuildState): this;
  58863. serialize(): any;
  58864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58865. }
  58866. }
  58867. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58871. import { Color3 } from "babylonjs/Maths/math.color";
  58872. import { Scene } from "babylonjs/scene";
  58873. /**
  58874. * Class used to store a color step for the GradientBlock
  58875. */
  58876. export class GradientBlockColorStep {
  58877. /**
  58878. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58879. */
  58880. step: number;
  58881. /**
  58882. * Gets or sets the color associated with this step
  58883. */
  58884. color: Color3;
  58885. /**
  58886. * Creates a new GradientBlockColorStep
  58887. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58888. * @param color defines the color associated with this step
  58889. */
  58890. constructor(
  58891. /**
  58892. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58893. */
  58894. step: number,
  58895. /**
  58896. * Gets or sets the color associated with this step
  58897. */
  58898. color: Color3);
  58899. }
  58900. /**
  58901. * Block used to return a color from a gradient based on an input value between 0 and 1
  58902. */
  58903. export class GradientBlock extends NodeMaterialBlock {
  58904. /**
  58905. * Gets or sets the list of color steps
  58906. */
  58907. colorSteps: GradientBlockColorStep[];
  58908. /**
  58909. * Creates a new GradientBlock
  58910. * @param name defines the block name
  58911. */
  58912. constructor(name: string);
  58913. /**
  58914. * Gets the current class name
  58915. * @returns the class name
  58916. */
  58917. getClassName(): string;
  58918. /**
  58919. * Gets the gradient input component
  58920. */
  58921. readonly gradient: NodeMaterialConnectionPoint;
  58922. /**
  58923. * Gets the output component
  58924. */
  58925. readonly output: NodeMaterialConnectionPoint;
  58926. private _writeColorConstant;
  58927. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58928. serialize(): any;
  58929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58930. protected _dumpPropertiesCode(): string;
  58931. }
  58932. }
  58933. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58937. /**
  58938. * Block used to normalize lerp between 2 values
  58939. */
  58940. export class NLerpBlock extends NodeMaterialBlock {
  58941. /**
  58942. * Creates a new NLerpBlock
  58943. * @param name defines the block name
  58944. */
  58945. constructor(name: string);
  58946. /**
  58947. * Gets the current class name
  58948. * @returns the class name
  58949. */
  58950. getClassName(): string;
  58951. /**
  58952. * Gets the left operand input component
  58953. */
  58954. readonly left: NodeMaterialConnectionPoint;
  58955. /**
  58956. * Gets the right operand input component
  58957. */
  58958. readonly right: NodeMaterialConnectionPoint;
  58959. /**
  58960. * Gets the gradient operand input component
  58961. */
  58962. readonly gradient: NodeMaterialConnectionPoint;
  58963. /**
  58964. * Gets the output component
  58965. */
  58966. readonly output: NodeMaterialConnectionPoint;
  58967. protected _buildBlock(state: NodeMaterialBuildState): this;
  58968. }
  58969. }
  58970. declare module "babylonjs/Materials/Node/Blocks/frontFacingBlock" {
  58971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58974. /**
  58975. * Block used to test if the fragment shader is front facing
  58976. */
  58977. export class FrontFacingBlock extends NodeMaterialBlock {
  58978. /**
  58979. * Creates a new FrontFacingBlock
  58980. * @param name defines the block name
  58981. */
  58982. constructor(name: string);
  58983. /**
  58984. * Gets the current class name
  58985. * @returns the class name
  58986. */
  58987. getClassName(): string;
  58988. /**
  58989. * Gets the output component
  58990. */
  58991. readonly output: NodeMaterialConnectionPoint;
  58992. protected _buildBlock(state: NodeMaterialBuildState): this;
  58993. }
  58994. }
  58995. declare module "babylonjs/Materials/Node/Blocks/index" {
  58996. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58997. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58998. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58999. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59000. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59001. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59002. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59003. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59004. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59005. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59006. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59007. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59008. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59009. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59010. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59011. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59012. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59013. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59014. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59015. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59016. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59017. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59018. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59019. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59020. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59021. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59022. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59023. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59024. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59025. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59026. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59027. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59028. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59029. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59030. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59031. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59032. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59033. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59034. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59035. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59036. export * from "babylonjs/Materials/Node/Blocks/frontFacingBlock";
  59037. }
  59038. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59039. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59040. }
  59041. declare module "babylonjs/Materials/Node/index" {
  59042. export * from "babylonjs/Materials/Node/Enums/index";
  59043. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59044. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59045. export * from "babylonjs/Materials/Node/nodeMaterial";
  59046. export * from "babylonjs/Materials/Node/Blocks/index";
  59047. export * from "babylonjs/Materials/Node/Optimizers/index";
  59048. }
  59049. declare module "babylonjs/Materials/effectRenderer" {
  59050. import { Nullable } from "babylonjs/types";
  59051. import { Texture } from "babylonjs/Materials/Textures/texture";
  59052. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59053. import { Viewport } from "babylonjs/Maths/math.viewport";
  59054. import { Observable } from "babylonjs/Misc/observable";
  59055. import { Effect } from "babylonjs/Materials/effect";
  59056. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59057. import "babylonjs/Shaders/postprocess.vertex";
  59058. /**
  59059. * Effect Render Options
  59060. */
  59061. export interface IEffectRendererOptions {
  59062. /**
  59063. * Defines the vertices positions.
  59064. */
  59065. positions?: number[];
  59066. /**
  59067. * Defines the indices.
  59068. */
  59069. indices?: number[];
  59070. }
  59071. /**
  59072. * Helper class to render one or more effects
  59073. */
  59074. export class EffectRenderer {
  59075. private engine;
  59076. private static _DefaultOptions;
  59077. private _vertexBuffers;
  59078. private _indexBuffer;
  59079. private _ringBufferIndex;
  59080. private _ringScreenBuffer;
  59081. private _fullscreenViewport;
  59082. private _getNextFrameBuffer;
  59083. /**
  59084. * Creates an effect renderer
  59085. * @param engine the engine to use for rendering
  59086. * @param options defines the options of the effect renderer
  59087. */
  59088. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59089. /**
  59090. * Sets the current viewport in normalized coordinates 0-1
  59091. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59092. */
  59093. setViewport(viewport?: Viewport): void;
  59094. /**
  59095. * Binds the embedded attributes buffer to the effect.
  59096. * @param effect Defines the effect to bind the attributes for
  59097. */
  59098. bindBuffers(effect: Effect): void;
  59099. /**
  59100. * Sets the current effect wrapper to use during draw.
  59101. * The effect needs to be ready before calling this api.
  59102. * This also sets the default full screen position attribute.
  59103. * @param effectWrapper Defines the effect to draw with
  59104. */
  59105. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59106. /**
  59107. * Draws a full screen quad.
  59108. */
  59109. draw(): void;
  59110. /**
  59111. * renders one or more effects to a specified texture
  59112. * @param effectWrappers list of effects to renderer
  59113. * @param outputTexture texture to draw to, if null it will render to the screen
  59114. */
  59115. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59116. /**
  59117. * Disposes of the effect renderer
  59118. */
  59119. dispose(): void;
  59120. }
  59121. /**
  59122. * Options to create an EffectWrapper
  59123. */
  59124. interface EffectWrapperCreationOptions {
  59125. /**
  59126. * Engine to use to create the effect
  59127. */
  59128. engine: ThinEngine;
  59129. /**
  59130. * Fragment shader for the effect
  59131. */
  59132. fragmentShader: string;
  59133. /**
  59134. * Vertex shader for the effect
  59135. */
  59136. vertexShader?: string;
  59137. /**
  59138. * Attributes to use in the shader
  59139. */
  59140. attributeNames?: Array<string>;
  59141. /**
  59142. * Uniforms to use in the shader
  59143. */
  59144. uniformNames?: Array<string>;
  59145. /**
  59146. * Texture sampler names to use in the shader
  59147. */
  59148. samplerNames?: Array<string>;
  59149. /**
  59150. * The friendly name of the effect displayed in Spector.
  59151. */
  59152. name?: string;
  59153. }
  59154. /**
  59155. * Wraps an effect to be used for rendering
  59156. */
  59157. export class EffectWrapper {
  59158. /**
  59159. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59160. */
  59161. onApplyObservable: Observable<{}>;
  59162. /**
  59163. * The underlying effect
  59164. */
  59165. effect: Effect;
  59166. /**
  59167. * Creates an effect to be renderer
  59168. * @param creationOptions options to create the effect
  59169. */
  59170. constructor(creationOptions: EffectWrapperCreationOptions);
  59171. /**
  59172. * Disposes of the effect wrapper
  59173. */
  59174. dispose(): void;
  59175. }
  59176. }
  59177. declare module "babylonjs/Materials/index" {
  59178. export * from "babylonjs/Materials/Background/index";
  59179. export * from "babylonjs/Materials/colorCurves";
  59180. export * from "babylonjs/Materials/iEffectFallbacks";
  59181. export * from "babylonjs/Materials/effectFallbacks";
  59182. export * from "babylonjs/Materials/effect";
  59183. export * from "babylonjs/Materials/fresnelParameters";
  59184. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59185. export * from "babylonjs/Materials/material";
  59186. export * from "babylonjs/Materials/materialDefines";
  59187. export * from "babylonjs/Materials/materialHelper";
  59188. export * from "babylonjs/Materials/multiMaterial";
  59189. export * from "babylonjs/Materials/PBR/index";
  59190. export * from "babylonjs/Materials/pushMaterial";
  59191. export * from "babylonjs/Materials/shaderMaterial";
  59192. export * from "babylonjs/Materials/standardMaterial";
  59193. export * from "babylonjs/Materials/Textures/index";
  59194. export * from "babylonjs/Materials/uniformBuffer";
  59195. export * from "babylonjs/Materials/materialFlags";
  59196. export * from "babylonjs/Materials/Node/index";
  59197. export * from "babylonjs/Materials/effectRenderer";
  59198. }
  59199. declare module "babylonjs/Maths/index" {
  59200. export * from "babylonjs/Maths/math.scalar";
  59201. export * from "babylonjs/Maths/math";
  59202. export * from "babylonjs/Maths/sphericalPolynomial";
  59203. }
  59204. declare module "babylonjs/Misc/workerPool" {
  59205. import { IDisposable } from "babylonjs/scene";
  59206. /**
  59207. * Helper class to push actions to a pool of workers.
  59208. */
  59209. export class WorkerPool implements IDisposable {
  59210. private _workerInfos;
  59211. private _pendingActions;
  59212. /**
  59213. * Constructor
  59214. * @param workers Array of workers to use for actions
  59215. */
  59216. constructor(workers: Array<Worker>);
  59217. /**
  59218. * Terminates all workers and clears any pending actions.
  59219. */
  59220. dispose(): void;
  59221. /**
  59222. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59223. * pended until a worker has completed its action.
  59224. * @param action The action to perform. Call onComplete when the action is complete.
  59225. */
  59226. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59227. private _execute;
  59228. }
  59229. }
  59230. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59231. import { IDisposable } from "babylonjs/scene";
  59232. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59233. /**
  59234. * Configuration for Draco compression
  59235. */
  59236. export interface IDracoCompressionConfiguration {
  59237. /**
  59238. * Configuration for the decoder.
  59239. */
  59240. decoder: {
  59241. /**
  59242. * The url to the WebAssembly module.
  59243. */
  59244. wasmUrl?: string;
  59245. /**
  59246. * The url to the WebAssembly binary.
  59247. */
  59248. wasmBinaryUrl?: string;
  59249. /**
  59250. * The url to the fallback JavaScript module.
  59251. */
  59252. fallbackUrl?: string;
  59253. };
  59254. }
  59255. /**
  59256. * Draco compression (https://google.github.io/draco/)
  59257. *
  59258. * This class wraps the Draco module.
  59259. *
  59260. * **Encoder**
  59261. *
  59262. * The encoder is not currently implemented.
  59263. *
  59264. * **Decoder**
  59265. *
  59266. * 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.
  59267. *
  59268. * To update the configuration, use the following code:
  59269. * ```javascript
  59270. * DracoCompression.Configuration = {
  59271. * decoder: {
  59272. * wasmUrl: "<url to the WebAssembly library>",
  59273. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59274. * fallbackUrl: "<url to the fallback JavaScript library>",
  59275. * }
  59276. * };
  59277. * ```
  59278. *
  59279. * 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.
  59280. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59281. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59282. *
  59283. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59284. * ```javascript
  59285. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59286. * ```
  59287. *
  59288. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59289. */
  59290. export class DracoCompression implements IDisposable {
  59291. private _workerPoolPromise?;
  59292. private _decoderModulePromise?;
  59293. /**
  59294. * The configuration. Defaults to the following urls:
  59295. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59296. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59297. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59298. */
  59299. static Configuration: IDracoCompressionConfiguration;
  59300. /**
  59301. * Returns true if the decoder configuration is available.
  59302. */
  59303. static readonly DecoderAvailable: boolean;
  59304. /**
  59305. * Default number of workers to create when creating the draco compression object.
  59306. */
  59307. static DefaultNumWorkers: number;
  59308. private static GetDefaultNumWorkers;
  59309. private static _Default;
  59310. /**
  59311. * Default instance for the draco compression object.
  59312. */
  59313. static readonly Default: DracoCompression;
  59314. /**
  59315. * Constructor
  59316. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59317. */
  59318. constructor(numWorkers?: number);
  59319. /**
  59320. * Stop all async operations and release resources.
  59321. */
  59322. dispose(): void;
  59323. /**
  59324. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59325. * @returns a promise that resolves when ready
  59326. */
  59327. whenReadyAsync(): Promise<void>;
  59328. /**
  59329. * Decode Draco compressed mesh data to vertex data.
  59330. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59331. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59332. * @returns A promise that resolves with the decoded vertex data
  59333. */
  59334. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59335. [kind: string]: number;
  59336. }): Promise<VertexData>;
  59337. }
  59338. }
  59339. declare module "babylonjs/Meshes/Compression/index" {
  59340. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59341. }
  59342. declare module "babylonjs/Meshes/csg" {
  59343. import { Nullable } from "babylonjs/types";
  59344. import { Scene } from "babylonjs/scene";
  59345. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59346. import { Mesh } from "babylonjs/Meshes/mesh";
  59347. import { Material } from "babylonjs/Materials/material";
  59348. /**
  59349. * Class for building Constructive Solid Geometry
  59350. */
  59351. export class CSG {
  59352. private polygons;
  59353. /**
  59354. * The world matrix
  59355. */
  59356. matrix: Matrix;
  59357. /**
  59358. * Stores the position
  59359. */
  59360. position: Vector3;
  59361. /**
  59362. * Stores the rotation
  59363. */
  59364. rotation: Vector3;
  59365. /**
  59366. * Stores the rotation quaternion
  59367. */
  59368. rotationQuaternion: Nullable<Quaternion>;
  59369. /**
  59370. * Stores the scaling vector
  59371. */
  59372. scaling: Vector3;
  59373. /**
  59374. * Convert the Mesh to CSG
  59375. * @param mesh The Mesh to convert to CSG
  59376. * @returns A new CSG from the Mesh
  59377. */
  59378. static FromMesh(mesh: Mesh): CSG;
  59379. /**
  59380. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59381. * @param polygons Polygons used to construct a CSG solid
  59382. */
  59383. private static FromPolygons;
  59384. /**
  59385. * Clones, or makes a deep copy, of the CSG
  59386. * @returns A new CSG
  59387. */
  59388. clone(): CSG;
  59389. /**
  59390. * Unions this CSG with another CSG
  59391. * @param csg The CSG to union against this CSG
  59392. * @returns The unioned CSG
  59393. */
  59394. union(csg: CSG): CSG;
  59395. /**
  59396. * Unions this CSG with another CSG in place
  59397. * @param csg The CSG to union against this CSG
  59398. */
  59399. unionInPlace(csg: CSG): void;
  59400. /**
  59401. * Subtracts this CSG with another CSG
  59402. * @param csg The CSG to subtract against this CSG
  59403. * @returns A new CSG
  59404. */
  59405. subtract(csg: CSG): CSG;
  59406. /**
  59407. * Subtracts this CSG with another CSG in place
  59408. * @param csg The CSG to subtact against this CSG
  59409. */
  59410. subtractInPlace(csg: CSG): void;
  59411. /**
  59412. * Intersect this CSG with another CSG
  59413. * @param csg The CSG to intersect against this CSG
  59414. * @returns A new CSG
  59415. */
  59416. intersect(csg: CSG): CSG;
  59417. /**
  59418. * Intersects this CSG with another CSG in place
  59419. * @param csg The CSG to intersect against this CSG
  59420. */
  59421. intersectInPlace(csg: CSG): void;
  59422. /**
  59423. * Return a new CSG solid with solid and empty space switched. This solid is
  59424. * not modified.
  59425. * @returns A new CSG solid with solid and empty space switched
  59426. */
  59427. inverse(): CSG;
  59428. /**
  59429. * Inverses the CSG in place
  59430. */
  59431. inverseInPlace(): void;
  59432. /**
  59433. * This is used to keep meshes transformations so they can be restored
  59434. * when we build back a Babylon Mesh
  59435. * NB : All CSG operations are performed in world coordinates
  59436. * @param csg The CSG to copy the transform attributes from
  59437. * @returns This CSG
  59438. */
  59439. copyTransformAttributes(csg: CSG): CSG;
  59440. /**
  59441. * Build Raw mesh from CSG
  59442. * Coordinates here are in world space
  59443. * @param name The name of the mesh geometry
  59444. * @param scene The Scene
  59445. * @param keepSubMeshes Specifies if the submeshes should be kept
  59446. * @returns A new Mesh
  59447. */
  59448. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59449. /**
  59450. * Build Mesh from CSG taking material and transforms into account
  59451. * @param name The name of the Mesh
  59452. * @param material The material of the Mesh
  59453. * @param scene The Scene
  59454. * @param keepSubMeshes Specifies if submeshes should be kept
  59455. * @returns The new Mesh
  59456. */
  59457. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59458. }
  59459. }
  59460. declare module "babylonjs/Meshes/trailMesh" {
  59461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59462. import { Mesh } from "babylonjs/Meshes/mesh";
  59463. import { Scene } from "babylonjs/scene";
  59464. /**
  59465. * Class used to create a trail following a mesh
  59466. */
  59467. export class TrailMesh extends Mesh {
  59468. private _generator;
  59469. private _autoStart;
  59470. private _running;
  59471. private _diameter;
  59472. private _length;
  59473. private _sectionPolygonPointsCount;
  59474. private _sectionVectors;
  59475. private _sectionNormalVectors;
  59476. private _beforeRenderObserver;
  59477. /**
  59478. * @constructor
  59479. * @param name The value used by scene.getMeshByName() to do a lookup.
  59480. * @param generator The mesh to generate a trail.
  59481. * @param scene The scene to add this mesh to.
  59482. * @param diameter Diameter of trailing mesh. Default is 1.
  59483. * @param length Length of trailing mesh. Default is 60.
  59484. * @param autoStart Automatically start trailing mesh. Default true.
  59485. */
  59486. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59487. /**
  59488. * "TrailMesh"
  59489. * @returns "TrailMesh"
  59490. */
  59491. getClassName(): string;
  59492. private _createMesh;
  59493. /**
  59494. * Start trailing mesh.
  59495. */
  59496. start(): void;
  59497. /**
  59498. * Stop trailing mesh.
  59499. */
  59500. stop(): void;
  59501. /**
  59502. * Update trailing mesh geometry.
  59503. */
  59504. update(): void;
  59505. /**
  59506. * Returns a new TrailMesh object.
  59507. * @param name is a string, the name given to the new mesh
  59508. * @param newGenerator use new generator object for cloned trail mesh
  59509. * @returns a new mesh
  59510. */
  59511. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59512. /**
  59513. * Serializes this trail mesh
  59514. * @param serializationObject object to write serialization to
  59515. */
  59516. serialize(serializationObject: any): void;
  59517. /**
  59518. * Parses a serialized trail mesh
  59519. * @param parsedMesh the serialized mesh
  59520. * @param scene the scene to create the trail mesh in
  59521. * @returns the created trail mesh
  59522. */
  59523. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59524. }
  59525. }
  59526. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59527. import { Nullable } from "babylonjs/types";
  59528. import { Scene } from "babylonjs/scene";
  59529. import { Vector4 } from "babylonjs/Maths/math.vector";
  59530. import { Color4 } from "babylonjs/Maths/math.color";
  59531. import { Mesh } from "babylonjs/Meshes/mesh";
  59532. /**
  59533. * Class containing static functions to help procedurally build meshes
  59534. */
  59535. export class TiledBoxBuilder {
  59536. /**
  59537. * Creates a box mesh
  59538. * 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)
  59539. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59543. * @param name defines the name of the mesh
  59544. * @param options defines the options used to create the mesh
  59545. * @param scene defines the hosting scene
  59546. * @returns the box mesh
  59547. */
  59548. static CreateTiledBox(name: string, options: {
  59549. pattern?: number;
  59550. width?: number;
  59551. height?: number;
  59552. depth?: number;
  59553. tileSize?: number;
  59554. tileWidth?: number;
  59555. tileHeight?: number;
  59556. alignHorizontal?: number;
  59557. alignVertical?: number;
  59558. faceUV?: Vector4[];
  59559. faceColors?: Color4[];
  59560. sideOrientation?: number;
  59561. updatable?: boolean;
  59562. }, scene?: Nullable<Scene>): Mesh;
  59563. }
  59564. }
  59565. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59566. import { Vector4 } from "babylonjs/Maths/math.vector";
  59567. import { Mesh } from "babylonjs/Meshes/mesh";
  59568. /**
  59569. * Class containing static functions to help procedurally build meshes
  59570. */
  59571. export class TorusKnotBuilder {
  59572. /**
  59573. * Creates a torus knot mesh
  59574. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59575. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59576. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59577. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59581. * @param name defines the name of the mesh
  59582. * @param options defines the options used to create the mesh
  59583. * @param scene defines the hosting scene
  59584. * @returns the torus knot mesh
  59585. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59586. */
  59587. static CreateTorusKnot(name: string, options: {
  59588. radius?: number;
  59589. tube?: number;
  59590. radialSegments?: number;
  59591. tubularSegments?: number;
  59592. p?: number;
  59593. q?: number;
  59594. updatable?: boolean;
  59595. sideOrientation?: number;
  59596. frontUVs?: Vector4;
  59597. backUVs?: Vector4;
  59598. }, scene: any): Mesh;
  59599. }
  59600. }
  59601. declare module "babylonjs/Meshes/polygonMesh" {
  59602. import { Scene } from "babylonjs/scene";
  59603. import { Vector2 } from "babylonjs/Maths/math.vector";
  59604. import { Mesh } from "babylonjs/Meshes/mesh";
  59605. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59606. import { Path2 } from "babylonjs/Maths/math.path";
  59607. /**
  59608. * Polygon
  59609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59610. */
  59611. export class Polygon {
  59612. /**
  59613. * Creates a rectangle
  59614. * @param xmin bottom X coord
  59615. * @param ymin bottom Y coord
  59616. * @param xmax top X coord
  59617. * @param ymax top Y coord
  59618. * @returns points that make the resulting rectation
  59619. */
  59620. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59621. /**
  59622. * Creates a circle
  59623. * @param radius radius of circle
  59624. * @param cx scale in x
  59625. * @param cy scale in y
  59626. * @param numberOfSides number of sides that make up the circle
  59627. * @returns points that make the resulting circle
  59628. */
  59629. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59630. /**
  59631. * Creates a polygon from input string
  59632. * @param input Input polygon data
  59633. * @returns the parsed points
  59634. */
  59635. static Parse(input: string): Vector2[];
  59636. /**
  59637. * Starts building a polygon from x and y coordinates
  59638. * @param x x coordinate
  59639. * @param y y coordinate
  59640. * @returns the started path2
  59641. */
  59642. static StartingAt(x: number, y: number): Path2;
  59643. }
  59644. /**
  59645. * Builds a polygon
  59646. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59647. */
  59648. export class PolygonMeshBuilder {
  59649. private _points;
  59650. private _outlinepoints;
  59651. private _holes;
  59652. private _name;
  59653. private _scene;
  59654. private _epoints;
  59655. private _eholes;
  59656. private _addToepoint;
  59657. /**
  59658. * Babylon reference to the earcut plugin.
  59659. */
  59660. bjsEarcut: any;
  59661. /**
  59662. * Creates a PolygonMeshBuilder
  59663. * @param name name of the builder
  59664. * @param contours Path of the polygon
  59665. * @param scene scene to add to when creating the mesh
  59666. * @param earcutInjection can be used to inject your own earcut reference
  59667. */
  59668. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59669. /**
  59670. * Adds a whole within the polygon
  59671. * @param hole Array of points defining the hole
  59672. * @returns this
  59673. */
  59674. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59675. /**
  59676. * Creates the polygon
  59677. * @param updatable If the mesh should be updatable
  59678. * @param depth The depth of the mesh created
  59679. * @returns the created mesh
  59680. */
  59681. build(updatable?: boolean, depth?: number): Mesh;
  59682. /**
  59683. * Creates the polygon
  59684. * @param depth The depth of the mesh created
  59685. * @returns the created VertexData
  59686. */
  59687. buildVertexData(depth?: number): VertexData;
  59688. /**
  59689. * Adds a side to the polygon
  59690. * @param positions points that make the polygon
  59691. * @param normals normals of the polygon
  59692. * @param uvs uvs of the polygon
  59693. * @param indices indices of the polygon
  59694. * @param bounds bounds of the polygon
  59695. * @param points points of the polygon
  59696. * @param depth depth of the polygon
  59697. * @param flip flip of the polygon
  59698. */
  59699. private addSide;
  59700. }
  59701. }
  59702. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59703. import { Scene } from "babylonjs/scene";
  59704. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59705. import { Color4 } from "babylonjs/Maths/math.color";
  59706. import { Mesh } from "babylonjs/Meshes/mesh";
  59707. import { Nullable } from "babylonjs/types";
  59708. /**
  59709. * Class containing static functions to help procedurally build meshes
  59710. */
  59711. export class PolygonBuilder {
  59712. /**
  59713. * Creates a polygon mesh
  59714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59715. * * 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
  59716. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59719. * * Remember you can only change the shape positions, not their number when updating a polygon
  59720. * @param name defines the name of the mesh
  59721. * @param options defines the options used to create the mesh
  59722. * @param scene defines the hosting scene
  59723. * @param earcutInjection can be used to inject your own earcut reference
  59724. * @returns the polygon mesh
  59725. */
  59726. static CreatePolygon(name: string, options: {
  59727. shape: Vector3[];
  59728. holes?: Vector3[][];
  59729. depth?: number;
  59730. faceUV?: Vector4[];
  59731. faceColors?: Color4[];
  59732. updatable?: boolean;
  59733. sideOrientation?: number;
  59734. frontUVs?: Vector4;
  59735. backUVs?: Vector4;
  59736. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59737. /**
  59738. * Creates an extruded polygon mesh, with depth in the Y direction.
  59739. * * 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)
  59740. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59741. * @param name defines the name of the mesh
  59742. * @param options defines the options used to create the mesh
  59743. * @param scene defines the hosting scene
  59744. * @param earcutInjection can be used to inject your own earcut reference
  59745. * @returns the polygon mesh
  59746. */
  59747. static ExtrudePolygon(name: string, options: {
  59748. shape: Vector3[];
  59749. holes?: Vector3[][];
  59750. depth?: number;
  59751. faceUV?: Vector4[];
  59752. faceColors?: Color4[];
  59753. updatable?: boolean;
  59754. sideOrientation?: number;
  59755. frontUVs?: Vector4;
  59756. backUVs?: Vector4;
  59757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59758. }
  59759. }
  59760. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59761. import { Scene } from "babylonjs/scene";
  59762. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59763. import { Mesh } from "babylonjs/Meshes/mesh";
  59764. import { Nullable } from "babylonjs/types";
  59765. /**
  59766. * Class containing static functions to help procedurally build meshes
  59767. */
  59768. export class LatheBuilder {
  59769. /**
  59770. * Creates lathe mesh.
  59771. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59772. * * 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
  59773. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59774. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59775. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59776. * * 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
  59777. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59778. * * 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
  59779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59781. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59783. * @param name defines the name of the mesh
  59784. * @param options defines the options used to create the mesh
  59785. * @param scene defines the hosting scene
  59786. * @returns the lathe mesh
  59787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59788. */
  59789. static CreateLathe(name: string, options: {
  59790. shape: Vector3[];
  59791. radius?: number;
  59792. tessellation?: number;
  59793. clip?: number;
  59794. arc?: number;
  59795. closed?: boolean;
  59796. updatable?: boolean;
  59797. sideOrientation?: number;
  59798. frontUVs?: Vector4;
  59799. backUVs?: Vector4;
  59800. cap?: number;
  59801. invertUV?: boolean;
  59802. }, scene?: Nullable<Scene>): Mesh;
  59803. }
  59804. }
  59805. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59806. import { Nullable } from "babylonjs/types";
  59807. import { Scene } from "babylonjs/scene";
  59808. import { Vector4 } from "babylonjs/Maths/math.vector";
  59809. import { Mesh } from "babylonjs/Meshes/mesh";
  59810. /**
  59811. * Class containing static functions to help procedurally build meshes
  59812. */
  59813. export class TiledPlaneBuilder {
  59814. /**
  59815. * Creates a tiled plane mesh
  59816. * * The parameter `pattern` will, depending on value, do nothing or
  59817. * * * flip (reflect about central vertical) alternate tiles across and up
  59818. * * * flip every tile on alternate rows
  59819. * * * rotate (180 degs) alternate tiles across and up
  59820. * * * rotate every tile on alternate rows
  59821. * * * flip and rotate alternate tiles across and up
  59822. * * * flip and rotate every tile on alternate rows
  59823. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59824. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59827. * * 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)
  59828. * * 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)
  59829. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59830. * @param name defines the name of the mesh
  59831. * @param options defines the options used to create the mesh
  59832. * @param scene defines the hosting scene
  59833. * @returns the box mesh
  59834. */
  59835. static CreateTiledPlane(name: string, options: {
  59836. pattern?: number;
  59837. tileSize?: number;
  59838. tileWidth?: number;
  59839. tileHeight?: number;
  59840. size?: number;
  59841. width?: number;
  59842. height?: number;
  59843. alignHorizontal?: number;
  59844. alignVertical?: number;
  59845. sideOrientation?: number;
  59846. frontUVs?: Vector4;
  59847. backUVs?: Vector4;
  59848. updatable?: boolean;
  59849. }, scene?: Nullable<Scene>): Mesh;
  59850. }
  59851. }
  59852. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59853. import { Nullable } from "babylonjs/types";
  59854. import { Scene } from "babylonjs/scene";
  59855. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59856. import { Mesh } from "babylonjs/Meshes/mesh";
  59857. /**
  59858. * Class containing static functions to help procedurally build meshes
  59859. */
  59860. export class TubeBuilder {
  59861. /**
  59862. * Creates a tube mesh.
  59863. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59864. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59865. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59866. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59867. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59868. * * 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)
  59869. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59870. * * 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
  59871. * * 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
  59872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59876. * @param name defines the name of the mesh
  59877. * @param options defines the options used to create the mesh
  59878. * @param scene defines the hosting scene
  59879. * @returns the tube mesh
  59880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59881. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59882. */
  59883. static CreateTube(name: string, options: {
  59884. path: Vector3[];
  59885. radius?: number;
  59886. tessellation?: number;
  59887. radiusFunction?: {
  59888. (i: number, distance: number): number;
  59889. };
  59890. cap?: number;
  59891. arc?: number;
  59892. updatable?: boolean;
  59893. sideOrientation?: number;
  59894. frontUVs?: Vector4;
  59895. backUVs?: Vector4;
  59896. instance?: Mesh;
  59897. invertUV?: boolean;
  59898. }, scene?: Nullable<Scene>): Mesh;
  59899. }
  59900. }
  59901. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59902. import { Scene } from "babylonjs/scene";
  59903. import { Vector4 } from "babylonjs/Maths/math.vector";
  59904. import { Mesh } from "babylonjs/Meshes/mesh";
  59905. import { Nullable } from "babylonjs/types";
  59906. /**
  59907. * Class containing static functions to help procedurally build meshes
  59908. */
  59909. export class IcoSphereBuilder {
  59910. /**
  59911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59913. * * 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`)
  59914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59915. * * 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
  59916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59919. * @param name defines the name of the mesh
  59920. * @param options defines the options used to create the mesh
  59921. * @param scene defines the hosting scene
  59922. * @returns the icosahedron mesh
  59923. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59924. */
  59925. static CreateIcoSphere(name: string, options: {
  59926. radius?: number;
  59927. radiusX?: number;
  59928. radiusY?: number;
  59929. radiusZ?: number;
  59930. flat?: boolean;
  59931. subdivisions?: number;
  59932. sideOrientation?: number;
  59933. frontUVs?: Vector4;
  59934. backUVs?: Vector4;
  59935. updatable?: boolean;
  59936. }, scene?: Nullable<Scene>): Mesh;
  59937. }
  59938. }
  59939. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59940. import { Vector3 } from "babylonjs/Maths/math.vector";
  59941. import { Mesh } from "babylonjs/Meshes/mesh";
  59942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59943. /**
  59944. * Class containing static functions to help procedurally build meshes
  59945. */
  59946. export class DecalBuilder {
  59947. /**
  59948. * Creates a decal mesh.
  59949. * 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
  59950. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59951. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59952. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59953. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59954. * @param name defines the name of the mesh
  59955. * @param sourceMesh defines the mesh where the decal must be applied
  59956. * @param options defines the options used to create the mesh
  59957. * @param scene defines the hosting scene
  59958. * @returns the decal mesh
  59959. * @see https://doc.babylonjs.com/how_to/decals
  59960. */
  59961. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59962. position?: Vector3;
  59963. normal?: Vector3;
  59964. size?: Vector3;
  59965. angle?: number;
  59966. }): Mesh;
  59967. }
  59968. }
  59969. declare module "babylonjs/Meshes/meshBuilder" {
  59970. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59971. import { Nullable } from "babylonjs/types";
  59972. import { Scene } from "babylonjs/scene";
  59973. import { Mesh } from "babylonjs/Meshes/mesh";
  59974. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59975. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59977. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59978. import { Plane } from "babylonjs/Maths/math.plane";
  59979. /**
  59980. * Class containing static functions to help procedurally build meshes
  59981. */
  59982. export class MeshBuilder {
  59983. /**
  59984. * Creates a box mesh
  59985. * * The parameter `size` sets the size (float) of each box side (default 1)
  59986. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59987. * * 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)
  59988. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59992. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59993. * @param name defines the name of the mesh
  59994. * @param options defines the options used to create the mesh
  59995. * @param scene defines the hosting scene
  59996. * @returns the box mesh
  59997. */
  59998. static CreateBox(name: string, options: {
  59999. size?: number;
  60000. width?: number;
  60001. height?: number;
  60002. depth?: number;
  60003. faceUV?: Vector4[];
  60004. faceColors?: Color4[];
  60005. sideOrientation?: number;
  60006. frontUVs?: Vector4;
  60007. backUVs?: Vector4;
  60008. updatable?: boolean;
  60009. }, scene?: Nullable<Scene>): Mesh;
  60010. /**
  60011. * Creates a tiled box mesh
  60012. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60014. * @param name defines the name of the mesh
  60015. * @param options defines the options used to create the mesh
  60016. * @param scene defines the hosting scene
  60017. * @returns the tiled box mesh
  60018. */
  60019. static CreateTiledBox(name: string, options: {
  60020. pattern?: number;
  60021. size?: number;
  60022. width?: number;
  60023. height?: number;
  60024. depth: number;
  60025. tileSize?: number;
  60026. tileWidth?: number;
  60027. tileHeight?: number;
  60028. faceUV?: Vector4[];
  60029. faceColors?: Color4[];
  60030. alignHorizontal?: number;
  60031. alignVertical?: number;
  60032. sideOrientation?: number;
  60033. updatable?: boolean;
  60034. }, scene?: Nullable<Scene>): Mesh;
  60035. /**
  60036. * Creates a sphere mesh
  60037. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60038. * * 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`)
  60039. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60040. * * 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
  60041. * * 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)
  60042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60045. * @param name defines the name of the mesh
  60046. * @param options defines the options used to create the mesh
  60047. * @param scene defines the hosting scene
  60048. * @returns the sphere mesh
  60049. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60050. */
  60051. static CreateSphere(name: string, options: {
  60052. segments?: number;
  60053. diameter?: number;
  60054. diameterX?: number;
  60055. diameterY?: number;
  60056. diameterZ?: number;
  60057. arc?: number;
  60058. slice?: number;
  60059. sideOrientation?: number;
  60060. frontUVs?: Vector4;
  60061. backUVs?: Vector4;
  60062. updatable?: boolean;
  60063. }, scene?: Nullable<Scene>): Mesh;
  60064. /**
  60065. * Creates a plane polygonal mesh. By default, this is a disc
  60066. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60067. * * 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
  60068. * * 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
  60069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60072. * @param name defines the name of the mesh
  60073. * @param options defines the options used to create the mesh
  60074. * @param scene defines the hosting scene
  60075. * @returns the plane polygonal mesh
  60076. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60077. */
  60078. static CreateDisc(name: string, options: {
  60079. radius?: number;
  60080. tessellation?: number;
  60081. arc?: number;
  60082. updatable?: boolean;
  60083. sideOrientation?: number;
  60084. frontUVs?: Vector4;
  60085. backUVs?: Vector4;
  60086. }, scene?: Nullable<Scene>): Mesh;
  60087. /**
  60088. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60089. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60090. * * 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`)
  60091. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60092. * * 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
  60093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60096. * @param name defines the name of the mesh
  60097. * @param options defines the options used to create the mesh
  60098. * @param scene defines the hosting scene
  60099. * @returns the icosahedron mesh
  60100. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60101. */
  60102. static CreateIcoSphere(name: string, options: {
  60103. radius?: number;
  60104. radiusX?: number;
  60105. radiusY?: number;
  60106. radiusZ?: number;
  60107. flat?: boolean;
  60108. subdivisions?: number;
  60109. sideOrientation?: number;
  60110. frontUVs?: Vector4;
  60111. backUVs?: Vector4;
  60112. updatable?: boolean;
  60113. }, scene?: Nullable<Scene>): Mesh;
  60114. /**
  60115. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60116. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60117. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60118. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60119. * * 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
  60120. * * 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
  60121. * * 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
  60122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60125. * * 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
  60126. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60127. * * 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
  60128. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60130. * @param name defines the name of the mesh
  60131. * @param options defines the options used to create the mesh
  60132. * @param scene defines the hosting scene
  60133. * @returns the ribbon mesh
  60134. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60136. */
  60137. static CreateRibbon(name: string, options: {
  60138. pathArray: Vector3[][];
  60139. closeArray?: boolean;
  60140. closePath?: boolean;
  60141. offset?: number;
  60142. updatable?: boolean;
  60143. sideOrientation?: number;
  60144. frontUVs?: Vector4;
  60145. backUVs?: Vector4;
  60146. instance?: Mesh;
  60147. invertUV?: boolean;
  60148. uvs?: Vector2[];
  60149. colors?: Color4[];
  60150. }, scene?: Nullable<Scene>): Mesh;
  60151. /**
  60152. * Creates a cylinder or a cone mesh
  60153. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60154. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60155. * * 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.
  60156. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60157. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60158. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60159. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60160. * * 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).
  60161. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60162. * * 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).
  60163. * * 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
  60164. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60165. * * 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
  60166. * * 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.
  60167. * * If `enclose` is false, a ring surface is one element.
  60168. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60169. * * 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
  60170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60173. * @param name defines the name of the mesh
  60174. * @param options defines the options used to create the mesh
  60175. * @param scene defines the hosting scene
  60176. * @returns the cylinder mesh
  60177. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60178. */
  60179. static CreateCylinder(name: string, options: {
  60180. height?: number;
  60181. diameterTop?: number;
  60182. diameterBottom?: number;
  60183. diameter?: number;
  60184. tessellation?: number;
  60185. subdivisions?: number;
  60186. arc?: number;
  60187. faceColors?: Color4[];
  60188. faceUV?: Vector4[];
  60189. updatable?: boolean;
  60190. hasRings?: boolean;
  60191. enclose?: boolean;
  60192. cap?: number;
  60193. sideOrientation?: number;
  60194. frontUVs?: Vector4;
  60195. backUVs?: Vector4;
  60196. }, scene?: Nullable<Scene>): Mesh;
  60197. /**
  60198. * Creates a torus mesh
  60199. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60200. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60201. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60205. * @param name defines the name of the mesh
  60206. * @param options defines the options used to create the mesh
  60207. * @param scene defines the hosting scene
  60208. * @returns the torus mesh
  60209. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60210. */
  60211. static CreateTorus(name: string, options: {
  60212. diameter?: number;
  60213. thickness?: number;
  60214. tessellation?: number;
  60215. updatable?: boolean;
  60216. sideOrientation?: number;
  60217. frontUVs?: Vector4;
  60218. backUVs?: Vector4;
  60219. }, scene?: Nullable<Scene>): Mesh;
  60220. /**
  60221. * Creates a torus knot mesh
  60222. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60223. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60224. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60225. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60229. * @param name defines the name of the mesh
  60230. * @param options defines the options used to create the mesh
  60231. * @param scene defines the hosting scene
  60232. * @returns the torus knot mesh
  60233. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60234. */
  60235. static CreateTorusKnot(name: string, options: {
  60236. radius?: number;
  60237. tube?: number;
  60238. radialSegments?: number;
  60239. tubularSegments?: number;
  60240. p?: number;
  60241. q?: number;
  60242. updatable?: boolean;
  60243. sideOrientation?: number;
  60244. frontUVs?: Vector4;
  60245. backUVs?: Vector4;
  60246. }, scene?: Nullable<Scene>): Mesh;
  60247. /**
  60248. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60249. * * 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
  60250. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60251. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60252. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60253. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60254. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60255. * * 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
  60256. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60259. * @param name defines the name of the new line system
  60260. * @param options defines the options used to create the line system
  60261. * @param scene defines the hosting scene
  60262. * @returns a new line system mesh
  60263. */
  60264. static CreateLineSystem(name: string, options: {
  60265. lines: Vector3[][];
  60266. updatable?: boolean;
  60267. instance?: Nullable<LinesMesh>;
  60268. colors?: Nullable<Color4[][]>;
  60269. useVertexAlpha?: boolean;
  60270. }, scene: Nullable<Scene>): LinesMesh;
  60271. /**
  60272. * Creates a line mesh
  60273. * 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
  60274. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60275. * * The parameter `points` is an array successive Vector3
  60276. * * 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
  60277. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60278. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60279. * * When updating an instance, remember that only point positions can change, not the number of points
  60280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60282. * @param name defines the name of the new line system
  60283. * @param options defines the options used to create the line system
  60284. * @param scene defines the hosting scene
  60285. * @returns a new line mesh
  60286. */
  60287. static CreateLines(name: string, options: {
  60288. points: Vector3[];
  60289. updatable?: boolean;
  60290. instance?: Nullable<LinesMesh>;
  60291. colors?: Color4[];
  60292. useVertexAlpha?: boolean;
  60293. }, scene?: Nullable<Scene>): LinesMesh;
  60294. /**
  60295. * Creates a dashed line mesh
  60296. * * 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
  60297. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60298. * * The parameter `points` is an array successive Vector3
  60299. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60300. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60301. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60302. * * 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
  60303. * * When updating an instance, remember that only point positions can change, not the number of points
  60304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60305. * @param name defines the name of the mesh
  60306. * @param options defines the options used to create the mesh
  60307. * @param scene defines the hosting scene
  60308. * @returns the dashed line mesh
  60309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60310. */
  60311. static CreateDashedLines(name: string, options: {
  60312. points: Vector3[];
  60313. dashSize?: number;
  60314. gapSize?: number;
  60315. dashNb?: number;
  60316. updatable?: boolean;
  60317. instance?: LinesMesh;
  60318. }, scene?: Nullable<Scene>): LinesMesh;
  60319. /**
  60320. * 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.
  60321. * * 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.
  60322. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60323. * * 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.
  60324. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60325. * * 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
  60326. * * 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
  60327. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60332. * @param name defines the name of the mesh
  60333. * @param options defines the options used to create the mesh
  60334. * @param scene defines the hosting scene
  60335. * @returns the extruded shape mesh
  60336. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60338. */
  60339. static ExtrudeShape(name: string, options: {
  60340. shape: Vector3[];
  60341. path: Vector3[];
  60342. scale?: number;
  60343. rotation?: number;
  60344. cap?: number;
  60345. updatable?: boolean;
  60346. sideOrientation?: number;
  60347. frontUVs?: Vector4;
  60348. backUVs?: Vector4;
  60349. instance?: Mesh;
  60350. invertUV?: boolean;
  60351. }, scene?: Nullable<Scene>): Mesh;
  60352. /**
  60353. * Creates an custom extruded shape mesh.
  60354. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60355. * * 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.
  60356. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60357. * * 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
  60358. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60359. * * 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
  60360. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60361. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60362. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60363. * * 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
  60364. * * 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
  60365. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60370. * @param name defines the name of the mesh
  60371. * @param options defines the options used to create the mesh
  60372. * @param scene defines the hosting scene
  60373. * @returns the custom extruded shape mesh
  60374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60375. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60377. */
  60378. static ExtrudeShapeCustom(name: string, options: {
  60379. shape: Vector3[];
  60380. path: Vector3[];
  60381. scaleFunction?: any;
  60382. rotationFunction?: any;
  60383. ribbonCloseArray?: boolean;
  60384. ribbonClosePath?: boolean;
  60385. cap?: number;
  60386. updatable?: boolean;
  60387. sideOrientation?: number;
  60388. frontUVs?: Vector4;
  60389. backUVs?: Vector4;
  60390. instance?: Mesh;
  60391. invertUV?: boolean;
  60392. }, scene?: Nullable<Scene>): Mesh;
  60393. /**
  60394. * Creates lathe mesh.
  60395. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60396. * * 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
  60397. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60398. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60399. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60400. * * 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
  60401. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60402. * * 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
  60403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60407. * @param name defines the name of the mesh
  60408. * @param options defines the options used to create the mesh
  60409. * @param scene defines the hosting scene
  60410. * @returns the lathe mesh
  60411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60412. */
  60413. static CreateLathe(name: string, options: {
  60414. shape: Vector3[];
  60415. radius?: number;
  60416. tessellation?: number;
  60417. clip?: number;
  60418. arc?: number;
  60419. closed?: boolean;
  60420. updatable?: boolean;
  60421. sideOrientation?: number;
  60422. frontUVs?: Vector4;
  60423. backUVs?: Vector4;
  60424. cap?: number;
  60425. invertUV?: boolean;
  60426. }, scene?: Nullable<Scene>): Mesh;
  60427. /**
  60428. * Creates a tiled plane mesh
  60429. * * You can set a limited pattern arrangement with the tiles
  60430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60433. * @param name defines the name of the mesh
  60434. * @param options defines the options used to create the mesh
  60435. * @param scene defines the hosting scene
  60436. * @returns the plane mesh
  60437. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60438. */
  60439. static CreateTiledPlane(name: string, options: {
  60440. pattern?: number;
  60441. tileSize?: number;
  60442. tileWidth?: number;
  60443. tileHeight?: number;
  60444. size?: number;
  60445. width?: number;
  60446. height?: number;
  60447. alignHorizontal?: number;
  60448. alignVertical?: number;
  60449. sideOrientation?: number;
  60450. frontUVs?: Vector4;
  60451. backUVs?: Vector4;
  60452. updatable?: boolean;
  60453. }, scene?: Nullable<Scene>): Mesh;
  60454. /**
  60455. * Creates a plane mesh
  60456. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60457. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60458. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60462. * @param name defines the name of the mesh
  60463. * @param options defines the options used to create the mesh
  60464. * @param scene defines the hosting scene
  60465. * @returns the plane mesh
  60466. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60467. */
  60468. static CreatePlane(name: string, options: {
  60469. size?: number;
  60470. width?: number;
  60471. height?: number;
  60472. sideOrientation?: number;
  60473. frontUVs?: Vector4;
  60474. backUVs?: Vector4;
  60475. updatable?: boolean;
  60476. sourcePlane?: Plane;
  60477. }, scene?: Nullable<Scene>): Mesh;
  60478. /**
  60479. * Creates a ground mesh
  60480. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60481. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60483. * @param name defines the name of the mesh
  60484. * @param options defines the options used to create the mesh
  60485. * @param scene defines the hosting scene
  60486. * @returns the ground mesh
  60487. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60488. */
  60489. static CreateGround(name: string, options: {
  60490. width?: number;
  60491. height?: number;
  60492. subdivisions?: number;
  60493. subdivisionsX?: number;
  60494. subdivisionsY?: number;
  60495. updatable?: boolean;
  60496. }, scene?: Nullable<Scene>): Mesh;
  60497. /**
  60498. * Creates a tiled ground mesh
  60499. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60500. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60501. * * 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
  60502. * * 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
  60503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60504. * @param name defines the name of the mesh
  60505. * @param options defines the options used to create the mesh
  60506. * @param scene defines the hosting scene
  60507. * @returns the tiled ground mesh
  60508. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60509. */
  60510. static CreateTiledGround(name: string, options: {
  60511. xmin: number;
  60512. zmin: number;
  60513. xmax: number;
  60514. zmax: number;
  60515. subdivisions?: {
  60516. w: number;
  60517. h: number;
  60518. };
  60519. precision?: {
  60520. w: number;
  60521. h: number;
  60522. };
  60523. updatable?: boolean;
  60524. }, scene?: Nullable<Scene>): Mesh;
  60525. /**
  60526. * Creates a ground mesh from a height map
  60527. * * The parameter `url` sets the URL of the height map image resource.
  60528. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60529. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60530. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60531. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60532. * * 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.
  60533. * * 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).
  60534. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60536. * @param name defines the name of the mesh
  60537. * @param url defines the url to the height map
  60538. * @param options defines the options used to create the mesh
  60539. * @param scene defines the hosting scene
  60540. * @returns the ground mesh
  60541. * @see https://doc.babylonjs.com/babylon101/height_map
  60542. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60543. */
  60544. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60545. width?: number;
  60546. height?: number;
  60547. subdivisions?: number;
  60548. minHeight?: number;
  60549. maxHeight?: number;
  60550. colorFilter?: Color3;
  60551. alphaFilter?: number;
  60552. updatable?: boolean;
  60553. onReady?: (mesh: GroundMesh) => void;
  60554. }, scene?: Nullable<Scene>): GroundMesh;
  60555. /**
  60556. * Creates a polygon mesh
  60557. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60558. * * 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
  60559. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60562. * * Remember you can only change the shape positions, not their number when updating a polygon
  60563. * @param name defines the name of the mesh
  60564. * @param options defines the options used to create the mesh
  60565. * @param scene defines the hosting scene
  60566. * @param earcutInjection can be used to inject your own earcut reference
  60567. * @returns the polygon mesh
  60568. */
  60569. static CreatePolygon(name: string, options: {
  60570. shape: Vector3[];
  60571. holes?: Vector3[][];
  60572. depth?: number;
  60573. faceUV?: Vector4[];
  60574. faceColors?: Color4[];
  60575. updatable?: boolean;
  60576. sideOrientation?: number;
  60577. frontUVs?: Vector4;
  60578. backUVs?: Vector4;
  60579. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60580. /**
  60581. * Creates an extruded polygon mesh, with depth in the Y direction.
  60582. * * 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)
  60583. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60584. * @param name defines the name of the mesh
  60585. * @param options defines the options used to create the mesh
  60586. * @param scene defines the hosting scene
  60587. * @param earcutInjection can be used to inject your own earcut reference
  60588. * @returns the polygon mesh
  60589. */
  60590. static ExtrudePolygon(name: string, options: {
  60591. shape: Vector3[];
  60592. holes?: Vector3[][];
  60593. depth?: number;
  60594. faceUV?: Vector4[];
  60595. faceColors?: Color4[];
  60596. updatable?: boolean;
  60597. sideOrientation?: number;
  60598. frontUVs?: Vector4;
  60599. backUVs?: Vector4;
  60600. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60601. /**
  60602. * Creates a tube mesh.
  60603. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60604. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60605. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60606. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60607. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60608. * * 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)
  60609. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60610. * * 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
  60611. * * 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
  60612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60616. * @param name defines the name of the mesh
  60617. * @param options defines the options used to create the mesh
  60618. * @param scene defines the hosting scene
  60619. * @returns the tube mesh
  60620. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60621. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60622. */
  60623. static CreateTube(name: string, options: {
  60624. path: Vector3[];
  60625. radius?: number;
  60626. tessellation?: number;
  60627. radiusFunction?: {
  60628. (i: number, distance: number): number;
  60629. };
  60630. cap?: number;
  60631. arc?: number;
  60632. updatable?: boolean;
  60633. sideOrientation?: number;
  60634. frontUVs?: Vector4;
  60635. backUVs?: Vector4;
  60636. instance?: Mesh;
  60637. invertUV?: boolean;
  60638. }, scene?: Nullable<Scene>): Mesh;
  60639. /**
  60640. * Creates a polyhedron mesh
  60641. * * 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
  60642. * * The parameter `size` (positive float, default 1) sets the polygon size
  60643. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60644. * * 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`
  60645. * * 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
  60646. * * 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)`)
  60647. * * 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
  60648. * * 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
  60649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 polyhedron mesh
  60656. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60657. */
  60658. static CreatePolyhedron(name: string, options: {
  60659. type?: number;
  60660. size?: number;
  60661. sizeX?: number;
  60662. sizeY?: number;
  60663. sizeZ?: number;
  60664. custom?: any;
  60665. faceUV?: Vector4[];
  60666. faceColors?: Color4[];
  60667. flat?: boolean;
  60668. updatable?: boolean;
  60669. sideOrientation?: number;
  60670. frontUVs?: Vector4;
  60671. backUVs?: Vector4;
  60672. }, scene?: Nullable<Scene>): Mesh;
  60673. /**
  60674. * Creates a decal mesh.
  60675. * 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
  60676. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60677. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60678. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60679. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60680. * @param name defines the name of the mesh
  60681. * @param sourceMesh defines the mesh where the decal must be applied
  60682. * @param options defines the options used to create the mesh
  60683. * @param scene defines the hosting scene
  60684. * @returns the decal mesh
  60685. * @see https://doc.babylonjs.com/how_to/decals
  60686. */
  60687. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60688. position?: Vector3;
  60689. normal?: Vector3;
  60690. size?: Vector3;
  60691. angle?: number;
  60692. }): Mesh;
  60693. }
  60694. }
  60695. declare module "babylonjs/Meshes/meshSimplification" {
  60696. import { Mesh } from "babylonjs/Meshes/mesh";
  60697. /**
  60698. * A simplifier interface for future simplification implementations
  60699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60700. */
  60701. export interface ISimplifier {
  60702. /**
  60703. * Simplification of a given mesh according to the given settings.
  60704. * Since this requires computation, it is assumed that the function runs async.
  60705. * @param settings The settings of the simplification, including quality and distance
  60706. * @param successCallback A callback that will be called after the mesh was simplified.
  60707. * @param errorCallback in case of an error, this callback will be called. optional.
  60708. */
  60709. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60710. }
  60711. /**
  60712. * Expected simplification settings.
  60713. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60714. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60715. */
  60716. export interface ISimplificationSettings {
  60717. /**
  60718. * Gets or sets the expected quality
  60719. */
  60720. quality: number;
  60721. /**
  60722. * Gets or sets the distance when this optimized version should be used
  60723. */
  60724. distance: number;
  60725. /**
  60726. * Gets an already optimized mesh
  60727. */
  60728. optimizeMesh?: boolean;
  60729. }
  60730. /**
  60731. * Class used to specify simplification options
  60732. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60733. */
  60734. export class SimplificationSettings implements ISimplificationSettings {
  60735. /** expected quality */
  60736. quality: number;
  60737. /** distance when this optimized version should be used */
  60738. distance: number;
  60739. /** already optimized mesh */
  60740. optimizeMesh?: boolean | undefined;
  60741. /**
  60742. * Creates a SimplificationSettings
  60743. * @param quality expected quality
  60744. * @param distance distance when this optimized version should be used
  60745. * @param optimizeMesh already optimized mesh
  60746. */
  60747. constructor(
  60748. /** expected quality */
  60749. quality: number,
  60750. /** distance when this optimized version should be used */
  60751. distance: number,
  60752. /** already optimized mesh */
  60753. optimizeMesh?: boolean | undefined);
  60754. }
  60755. /**
  60756. * Interface used to define a simplification task
  60757. */
  60758. export interface ISimplificationTask {
  60759. /**
  60760. * Array of settings
  60761. */
  60762. settings: Array<ISimplificationSettings>;
  60763. /**
  60764. * Simplification type
  60765. */
  60766. simplificationType: SimplificationType;
  60767. /**
  60768. * Mesh to simplify
  60769. */
  60770. mesh: Mesh;
  60771. /**
  60772. * Callback called on success
  60773. */
  60774. successCallback?: () => void;
  60775. /**
  60776. * Defines if parallel processing can be used
  60777. */
  60778. parallelProcessing: boolean;
  60779. }
  60780. /**
  60781. * Queue used to order the simplification tasks
  60782. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60783. */
  60784. export class SimplificationQueue {
  60785. private _simplificationArray;
  60786. /**
  60787. * Gets a boolean indicating that the process is still running
  60788. */
  60789. running: boolean;
  60790. /**
  60791. * Creates a new queue
  60792. */
  60793. constructor();
  60794. /**
  60795. * Adds a new simplification task
  60796. * @param task defines a task to add
  60797. */
  60798. addTask(task: ISimplificationTask): void;
  60799. /**
  60800. * Execute next task
  60801. */
  60802. executeNext(): void;
  60803. /**
  60804. * Execute a simplification task
  60805. * @param task defines the task to run
  60806. */
  60807. runSimplification(task: ISimplificationTask): void;
  60808. private getSimplifier;
  60809. }
  60810. /**
  60811. * The implemented types of simplification
  60812. * At the moment only Quadratic Error Decimation is implemented
  60813. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60814. */
  60815. export enum SimplificationType {
  60816. /** Quadratic error decimation */
  60817. QUADRATIC = 0
  60818. }
  60819. }
  60820. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60821. import { Scene } from "babylonjs/scene";
  60822. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60823. import { ISceneComponent } from "babylonjs/sceneComponent";
  60824. module "babylonjs/scene" {
  60825. interface Scene {
  60826. /** @hidden (Backing field) */
  60827. _simplificationQueue: SimplificationQueue;
  60828. /**
  60829. * Gets or sets the simplification queue attached to the scene
  60830. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60831. */
  60832. simplificationQueue: SimplificationQueue;
  60833. }
  60834. }
  60835. module "babylonjs/Meshes/mesh" {
  60836. interface Mesh {
  60837. /**
  60838. * Simplify the mesh according to the given array of settings.
  60839. * Function will return immediately and will simplify async
  60840. * @param settings a collection of simplification settings
  60841. * @param parallelProcessing should all levels calculate parallel or one after the other
  60842. * @param simplificationType the type of simplification to run
  60843. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60844. * @returns the current mesh
  60845. */
  60846. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60847. }
  60848. }
  60849. /**
  60850. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60851. * created in a scene
  60852. */
  60853. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60854. /**
  60855. * The component name helpfull to identify the component in the list of scene components.
  60856. */
  60857. readonly name: string;
  60858. /**
  60859. * The scene the component belongs to.
  60860. */
  60861. scene: Scene;
  60862. /**
  60863. * Creates a new instance of the component for the given scene
  60864. * @param scene Defines the scene to register the component in
  60865. */
  60866. constructor(scene: Scene);
  60867. /**
  60868. * Registers the component in a given scene
  60869. */
  60870. register(): void;
  60871. /**
  60872. * Rebuilds the elements related to this component in case of
  60873. * context lost for instance.
  60874. */
  60875. rebuild(): void;
  60876. /**
  60877. * Disposes the component and the associated ressources
  60878. */
  60879. dispose(): void;
  60880. private _beforeCameraUpdate;
  60881. }
  60882. }
  60883. declare module "babylonjs/Meshes/Builders/index" {
  60884. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60885. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60886. export * from "babylonjs/Meshes/Builders/discBuilder";
  60887. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60888. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60889. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60890. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60891. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60892. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60893. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60894. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60895. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60896. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60897. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60898. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60899. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60900. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60901. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60902. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60903. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60904. }
  60905. declare module "babylonjs/Meshes/index" {
  60906. export * from "babylonjs/Meshes/abstractMesh";
  60907. export * from "babylonjs/Meshes/buffer";
  60908. export * from "babylonjs/Meshes/Compression/index";
  60909. export * from "babylonjs/Meshes/csg";
  60910. export * from "babylonjs/Meshes/geometry";
  60911. export * from "babylonjs/Meshes/groundMesh";
  60912. export * from "babylonjs/Meshes/trailMesh";
  60913. export * from "babylonjs/Meshes/instancedMesh";
  60914. export * from "babylonjs/Meshes/linesMesh";
  60915. export * from "babylonjs/Meshes/mesh";
  60916. export * from "babylonjs/Meshes/mesh.vertexData";
  60917. export * from "babylonjs/Meshes/meshBuilder";
  60918. export * from "babylonjs/Meshes/meshSimplification";
  60919. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60920. export * from "babylonjs/Meshes/polygonMesh";
  60921. export * from "babylonjs/Meshes/subMesh";
  60922. export * from "babylonjs/Meshes/meshLODLevel";
  60923. export * from "babylonjs/Meshes/transformNode";
  60924. export * from "babylonjs/Meshes/Builders/index";
  60925. export * from "babylonjs/Meshes/dataBuffer";
  60926. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60927. }
  60928. declare module "babylonjs/Morph/index" {
  60929. export * from "babylonjs/Morph/morphTarget";
  60930. export * from "babylonjs/Morph/morphTargetManager";
  60931. }
  60932. declare module "babylonjs/Navigation/INavigationEngine" {
  60933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60934. import { Vector3 } from "babylonjs/Maths/math";
  60935. import { Mesh } from "babylonjs/Meshes/mesh";
  60936. import { Scene } from "babylonjs/scene";
  60937. /**
  60938. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60939. */
  60940. export interface INavigationEnginePlugin {
  60941. /**
  60942. * plugin name
  60943. */
  60944. name: string;
  60945. /**
  60946. * Creates a navigation mesh
  60947. * @param meshes array of all the geometry used to compute the navigatio mesh
  60948. * @param parameters bunch of parameters used to filter geometry
  60949. */
  60950. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60951. /**
  60952. * Create a navigation mesh debug mesh
  60953. * @param scene is where the mesh will be added
  60954. * @returns debug display mesh
  60955. */
  60956. createDebugNavMesh(scene: Scene): Mesh;
  60957. /**
  60958. * Get a navigation mesh constrained position, closest to the parameter position
  60959. * @param position world position
  60960. * @returns the closest point to position constrained by the navigation mesh
  60961. */
  60962. getClosestPoint(position: Vector3): Vector3;
  60963. /**
  60964. * Get a navigation mesh constrained position, within a particular radius
  60965. * @param position world position
  60966. * @param maxRadius the maximum distance to the constrained world position
  60967. * @returns the closest point to position constrained by the navigation mesh
  60968. */
  60969. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60970. /**
  60971. * Compute the final position from a segment made of destination-position
  60972. * @param position world position
  60973. * @param destination world position
  60974. * @returns the resulting point along the navmesh
  60975. */
  60976. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60977. /**
  60978. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60979. * @param start world position
  60980. * @param end world position
  60981. * @returns array containing world position composing the path
  60982. */
  60983. computePath(start: Vector3, end: Vector3): Vector3[];
  60984. /**
  60985. * If this plugin is supported
  60986. * @returns true if plugin is supported
  60987. */
  60988. isSupported(): boolean;
  60989. /**
  60990. * Create a new Crowd so you can add agents
  60991. * @param maxAgents the maximum agent count in the crowd
  60992. * @param maxAgentRadius the maximum radius an agent can have
  60993. * @param scene to attach the crowd to
  60994. * @returns the crowd you can add agents to
  60995. */
  60996. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60997. /**
  60998. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60999. * The queries will try to find a solution within those bounds
  61000. * default is (1,1,1)
  61001. * @param extent x,y,z value that define the extent around the queries point of reference
  61002. */
  61003. setDefaultQueryExtent(extent: Vector3): void;
  61004. /**
  61005. * Get the Bounding box extent specified by setDefaultQueryExtent
  61006. * @returns the box extent values
  61007. */
  61008. getDefaultQueryExtent(): Vector3;
  61009. /**
  61010. * Release all resources
  61011. */
  61012. dispose(): void;
  61013. }
  61014. /**
  61015. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61016. */
  61017. export interface ICrowd {
  61018. /**
  61019. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61020. * You can attach anything to that node. The node position is updated in the scene update tick.
  61021. * @param pos world position that will be constrained by the navigation mesh
  61022. * @param parameters agent parameters
  61023. * @param transform hooked to the agent that will be update by the scene
  61024. * @returns agent index
  61025. */
  61026. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61027. /**
  61028. * Returns the agent position in world space
  61029. * @param index agent index returned by addAgent
  61030. * @returns world space position
  61031. */
  61032. getAgentPosition(index: number): Vector3;
  61033. /**
  61034. * Gets the agent velocity in world space
  61035. * @param index agent index returned by addAgent
  61036. * @returns world space velocity
  61037. */
  61038. getAgentVelocity(index: number): Vector3;
  61039. /**
  61040. * remove a particular agent previously created
  61041. * @param index agent index returned by addAgent
  61042. */
  61043. removeAgent(index: number): void;
  61044. /**
  61045. * get the list of all agents attached to this crowd
  61046. * @returns list of agent indices
  61047. */
  61048. getAgents(): number[];
  61049. /**
  61050. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61051. * @param deltaTime in seconds
  61052. */
  61053. update(deltaTime: number): void;
  61054. /**
  61055. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61056. * @param index agent index returned by addAgent
  61057. * @param destination targeted world position
  61058. */
  61059. agentGoto(index: number, destination: Vector3): void;
  61060. /**
  61061. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61062. * The queries will try to find a solution within those bounds
  61063. * default is (1,1,1)
  61064. * @param extent x,y,z value that define the extent around the queries point of reference
  61065. */
  61066. setDefaultQueryExtent(extent: Vector3): void;
  61067. /**
  61068. * Get the Bounding box extent specified by setDefaultQueryExtent
  61069. * @returns the box extent values
  61070. */
  61071. getDefaultQueryExtent(): Vector3;
  61072. /**
  61073. * Release all resources
  61074. */
  61075. dispose(): void;
  61076. }
  61077. /**
  61078. * Configures an agent
  61079. */
  61080. export interface IAgentParameters {
  61081. /**
  61082. * Agent radius. [Limit: >= 0]
  61083. */
  61084. radius: number;
  61085. /**
  61086. * Agent height. [Limit: > 0]
  61087. */
  61088. height: number;
  61089. /**
  61090. * Maximum allowed acceleration. [Limit: >= 0]
  61091. */
  61092. maxAcceleration: number;
  61093. /**
  61094. * Maximum allowed speed. [Limit: >= 0]
  61095. */
  61096. maxSpeed: number;
  61097. /**
  61098. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61099. */
  61100. collisionQueryRange: number;
  61101. /**
  61102. * The path visibility optimization range. [Limit: > 0]
  61103. */
  61104. pathOptimizationRange: number;
  61105. /**
  61106. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61107. */
  61108. separationWeight: number;
  61109. }
  61110. /**
  61111. * Configures the navigation mesh creation
  61112. */
  61113. export interface INavMeshParameters {
  61114. /**
  61115. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61116. */
  61117. cs: number;
  61118. /**
  61119. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61120. */
  61121. ch: number;
  61122. /**
  61123. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61124. */
  61125. walkableSlopeAngle: number;
  61126. /**
  61127. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61128. * be considered walkable. [Limit: >= 3] [Units: vx]
  61129. */
  61130. walkableHeight: number;
  61131. /**
  61132. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61133. */
  61134. walkableClimb: number;
  61135. /**
  61136. * The distance to erode/shrink the walkable area of the heightfield away from
  61137. * obstructions. [Limit: >=0] [Units: vx]
  61138. */
  61139. walkableRadius: number;
  61140. /**
  61141. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61142. */
  61143. maxEdgeLen: number;
  61144. /**
  61145. * The maximum distance a simplfied contour's border edges should deviate
  61146. * the original raw contour. [Limit: >=0] [Units: vx]
  61147. */
  61148. maxSimplificationError: number;
  61149. /**
  61150. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61151. */
  61152. minRegionArea: number;
  61153. /**
  61154. * Any regions with a span count smaller than this value will, if possible,
  61155. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61156. */
  61157. mergeRegionArea: number;
  61158. /**
  61159. * The maximum number of vertices allowed for polygons generated during the
  61160. * contour to polygon conversion process. [Limit: >= 3]
  61161. */
  61162. maxVertsPerPoly: number;
  61163. /**
  61164. * Sets the sampling distance to use when generating the detail mesh.
  61165. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61166. */
  61167. detailSampleDist: number;
  61168. /**
  61169. * The maximum distance the detail mesh surface should deviate from heightfield
  61170. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61171. */
  61172. detailSampleMaxError: number;
  61173. }
  61174. }
  61175. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61176. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61177. import { Mesh } from "babylonjs/Meshes/mesh";
  61178. import { Scene } from "babylonjs/scene";
  61179. import { Vector3 } from "babylonjs/Maths/math";
  61180. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61181. /**
  61182. * RecastJS navigation plugin
  61183. */
  61184. export class RecastJSPlugin implements INavigationEnginePlugin {
  61185. /**
  61186. * Reference to the Recast library
  61187. */
  61188. bjsRECAST: any;
  61189. /**
  61190. * plugin name
  61191. */
  61192. name: string;
  61193. /**
  61194. * the first navmesh created. We might extend this to support multiple navmeshes
  61195. */
  61196. navMesh: any;
  61197. /**
  61198. * Initializes the recastJS plugin
  61199. * @param recastInjection can be used to inject your own recast reference
  61200. */
  61201. constructor(recastInjection?: any);
  61202. /**
  61203. * Creates a navigation mesh
  61204. * @param meshes array of all the geometry used to compute the navigatio mesh
  61205. * @param parameters bunch of parameters used to filter geometry
  61206. */
  61207. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61208. /**
  61209. * Create a navigation mesh debug mesh
  61210. * @param scene is where the mesh will be added
  61211. * @returns debug display mesh
  61212. */
  61213. createDebugNavMesh(scene: Scene): Mesh;
  61214. /**
  61215. * Get a navigation mesh constrained position, closest to the parameter position
  61216. * @param position world position
  61217. * @returns the closest point to position constrained by the navigation mesh
  61218. */
  61219. getClosestPoint(position: Vector3): Vector3;
  61220. /**
  61221. * Get a navigation mesh constrained position, within a particular radius
  61222. * @param position world position
  61223. * @param maxRadius the maximum distance to the constrained world position
  61224. * @returns the closest point to position constrained by the navigation mesh
  61225. */
  61226. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61227. /**
  61228. * Compute the final position from a segment made of destination-position
  61229. * @param position world position
  61230. * @param destination world position
  61231. * @returns the resulting point along the navmesh
  61232. */
  61233. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61234. /**
  61235. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61236. * @param start world position
  61237. * @param end world position
  61238. * @returns array containing world position composing the path
  61239. */
  61240. computePath(start: Vector3, end: Vector3): Vector3[];
  61241. /**
  61242. * Create a new Crowd so you can add agents
  61243. * @param maxAgents the maximum agent count in the crowd
  61244. * @param maxAgentRadius the maximum radius an agent can have
  61245. * @param scene to attach the crowd to
  61246. * @returns the crowd you can add agents to
  61247. */
  61248. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61249. /**
  61250. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61251. * The queries will try to find a solution within those bounds
  61252. * default is (1,1,1)
  61253. * @param extent x,y,z value that define the extent around the queries point of reference
  61254. */
  61255. setDefaultQueryExtent(extent: Vector3): void;
  61256. /**
  61257. * Get the Bounding box extent specified by setDefaultQueryExtent
  61258. * @returns the box extent values
  61259. */
  61260. getDefaultQueryExtent(): Vector3;
  61261. /**
  61262. * Disposes
  61263. */
  61264. dispose(): void;
  61265. /**
  61266. * If this plugin is supported
  61267. * @returns true if plugin is supported
  61268. */
  61269. isSupported(): boolean;
  61270. }
  61271. /**
  61272. * Recast detour crowd implementation
  61273. */
  61274. export class RecastJSCrowd implements ICrowd {
  61275. /**
  61276. * Recast/detour plugin
  61277. */
  61278. bjsRECASTPlugin: RecastJSPlugin;
  61279. /**
  61280. * Link to the detour crowd
  61281. */
  61282. recastCrowd: any;
  61283. /**
  61284. * One transform per agent
  61285. */
  61286. transforms: TransformNode[];
  61287. /**
  61288. * All agents created
  61289. */
  61290. agents: number[];
  61291. /**
  61292. * Link to the scene is kept to unregister the crowd from the scene
  61293. */
  61294. private _scene;
  61295. /**
  61296. * Observer for crowd updates
  61297. */
  61298. private _onBeforeAnimationsObserver;
  61299. /**
  61300. * Constructor
  61301. * @param plugin recastJS plugin
  61302. * @param maxAgents the maximum agent count in the crowd
  61303. * @param maxAgentRadius the maximum radius an agent can have
  61304. * @param scene to attach the crowd to
  61305. * @returns the crowd you can add agents to
  61306. */
  61307. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61308. /**
  61309. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61310. * You can attach anything to that node. The node position is updated in the scene update tick.
  61311. * @param pos world position that will be constrained by the navigation mesh
  61312. * @param parameters agent parameters
  61313. * @param transform hooked to the agent that will be update by the scene
  61314. * @returns agent index
  61315. */
  61316. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61317. /**
  61318. * Returns the agent position in world space
  61319. * @param index agent index returned by addAgent
  61320. * @returns world space position
  61321. */
  61322. getAgentPosition(index: number): Vector3;
  61323. /**
  61324. * Returns the agent velocity in world space
  61325. * @param index agent index returned by addAgent
  61326. * @returns world space velocity
  61327. */
  61328. getAgentVelocity(index: number): Vector3;
  61329. /**
  61330. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61331. * @param index agent index returned by addAgent
  61332. * @param destination targeted world position
  61333. */
  61334. agentGoto(index: number, destination: Vector3): void;
  61335. /**
  61336. * remove a particular agent previously created
  61337. * @param index agent index returned by addAgent
  61338. */
  61339. removeAgent(index: number): void;
  61340. /**
  61341. * get the list of all agents attached to this crowd
  61342. * @returns list of agent indices
  61343. */
  61344. getAgents(): number[];
  61345. /**
  61346. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61347. * @param deltaTime in seconds
  61348. */
  61349. update(deltaTime: number): void;
  61350. /**
  61351. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61352. * The queries will try to find a solution within those bounds
  61353. * default is (1,1,1)
  61354. * @param extent x,y,z value that define the extent around the queries point of reference
  61355. */
  61356. setDefaultQueryExtent(extent: Vector3): void;
  61357. /**
  61358. * Get the Bounding box extent specified by setDefaultQueryExtent
  61359. * @returns the box extent values
  61360. */
  61361. getDefaultQueryExtent(): Vector3;
  61362. /**
  61363. * Release all resources
  61364. */
  61365. dispose(): void;
  61366. }
  61367. }
  61368. declare module "babylonjs/Navigation/Plugins/index" {
  61369. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61370. }
  61371. declare module "babylonjs/Navigation/index" {
  61372. export * from "babylonjs/Navigation/INavigationEngine";
  61373. export * from "babylonjs/Navigation/Plugins/index";
  61374. }
  61375. declare module "babylonjs/Offline/database" {
  61376. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61377. /**
  61378. * Class used to enable access to IndexedDB
  61379. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61380. */
  61381. export class Database implements IOfflineProvider {
  61382. private _callbackManifestChecked;
  61383. private _currentSceneUrl;
  61384. private _db;
  61385. private _enableSceneOffline;
  61386. private _enableTexturesOffline;
  61387. private _manifestVersionFound;
  61388. private _mustUpdateRessources;
  61389. private _hasReachedQuota;
  61390. private _isSupported;
  61391. private _idbFactory;
  61392. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61393. private static IsUASupportingBlobStorage;
  61394. /**
  61395. * Gets a boolean indicating if Database storate is enabled (off by default)
  61396. */
  61397. static IDBStorageEnabled: boolean;
  61398. /**
  61399. * Gets a boolean indicating if scene must be saved in the database
  61400. */
  61401. readonly enableSceneOffline: boolean;
  61402. /**
  61403. * Gets a boolean indicating if textures must be saved in the database
  61404. */
  61405. readonly enableTexturesOffline: boolean;
  61406. /**
  61407. * Creates a new Database
  61408. * @param urlToScene defines the url to load the scene
  61409. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61410. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61411. */
  61412. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61413. private static _ParseURL;
  61414. private static _ReturnFullUrlLocation;
  61415. private _checkManifestFile;
  61416. /**
  61417. * Open the database and make it available
  61418. * @param successCallback defines the callback to call on success
  61419. * @param errorCallback defines the callback to call on error
  61420. */
  61421. open(successCallback: () => void, errorCallback: () => void): void;
  61422. /**
  61423. * Loads an image from the database
  61424. * @param url defines the url to load from
  61425. * @param image defines the target DOM image
  61426. */
  61427. loadImage(url: string, image: HTMLImageElement): void;
  61428. private _loadImageFromDBAsync;
  61429. private _saveImageIntoDBAsync;
  61430. private _checkVersionFromDB;
  61431. private _loadVersionFromDBAsync;
  61432. private _saveVersionIntoDBAsync;
  61433. /**
  61434. * Loads a file from database
  61435. * @param url defines the URL to load from
  61436. * @param sceneLoaded defines a callback to call on success
  61437. * @param progressCallBack defines a callback to call when progress changed
  61438. * @param errorCallback defines a callback to call on error
  61439. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61440. */
  61441. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61442. private _loadFileAsync;
  61443. private _saveFileAsync;
  61444. /**
  61445. * Validates if xhr data is correct
  61446. * @param xhr defines the request to validate
  61447. * @param dataType defines the expected data type
  61448. * @returns true if data is correct
  61449. */
  61450. private static _ValidateXHRData;
  61451. }
  61452. }
  61453. declare module "babylonjs/Offline/index" {
  61454. export * from "babylonjs/Offline/database";
  61455. export * from "babylonjs/Offline/IOfflineProvider";
  61456. }
  61457. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61458. /** @hidden */
  61459. export var gpuUpdateParticlesPixelShader: {
  61460. name: string;
  61461. shader: string;
  61462. };
  61463. }
  61464. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61465. /** @hidden */
  61466. export var gpuUpdateParticlesVertexShader: {
  61467. name: string;
  61468. shader: string;
  61469. };
  61470. }
  61471. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61472. /** @hidden */
  61473. export var clipPlaneFragmentDeclaration2: {
  61474. name: string;
  61475. shader: string;
  61476. };
  61477. }
  61478. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61479. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61480. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61482. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61484. /** @hidden */
  61485. export var gpuRenderParticlesPixelShader: {
  61486. name: string;
  61487. shader: string;
  61488. };
  61489. }
  61490. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61491. /** @hidden */
  61492. export var clipPlaneVertexDeclaration2: {
  61493. name: string;
  61494. shader: string;
  61495. };
  61496. }
  61497. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61499. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61500. /** @hidden */
  61501. export var gpuRenderParticlesVertexShader: {
  61502. name: string;
  61503. shader: string;
  61504. };
  61505. }
  61506. declare module "babylonjs/Particles/gpuParticleSystem" {
  61507. import { Nullable } from "babylonjs/types";
  61508. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61509. import { Observable } from "babylonjs/Misc/observable";
  61510. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61511. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61512. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61513. import { Scene, IDisposable } from "babylonjs/scene";
  61514. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61516. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61517. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61518. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61519. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61520. /**
  61521. * This represents a GPU particle system in Babylon
  61522. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61523. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61524. */
  61525. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61526. /**
  61527. * The layer mask we are rendering the particles through.
  61528. */
  61529. layerMask: number;
  61530. private _capacity;
  61531. private _activeCount;
  61532. private _currentActiveCount;
  61533. private _accumulatedCount;
  61534. private _renderEffect;
  61535. private _updateEffect;
  61536. private _buffer0;
  61537. private _buffer1;
  61538. private _spriteBuffer;
  61539. private _updateVAO;
  61540. private _renderVAO;
  61541. private _targetIndex;
  61542. private _sourceBuffer;
  61543. private _targetBuffer;
  61544. private _engine;
  61545. private _currentRenderId;
  61546. private _started;
  61547. private _stopped;
  61548. private _timeDelta;
  61549. private _randomTexture;
  61550. private _randomTexture2;
  61551. private _attributesStrideSize;
  61552. private _updateEffectOptions;
  61553. private _randomTextureSize;
  61554. private _actualFrame;
  61555. private readonly _rawTextureWidth;
  61556. /**
  61557. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61558. */
  61559. static readonly IsSupported: boolean;
  61560. /**
  61561. * An event triggered when the system is disposed.
  61562. */
  61563. onDisposeObservable: Observable<GPUParticleSystem>;
  61564. /**
  61565. * Gets the maximum number of particles active at the same time.
  61566. * @returns The max number of active particles.
  61567. */
  61568. getCapacity(): number;
  61569. /**
  61570. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61571. * to override the particles.
  61572. */
  61573. forceDepthWrite: boolean;
  61574. /**
  61575. * Gets or set the number of active particles
  61576. */
  61577. activeParticleCount: number;
  61578. private _preWarmDone;
  61579. /**
  61580. * Is this system ready to be used/rendered
  61581. * @return true if the system is ready
  61582. */
  61583. isReady(): boolean;
  61584. /**
  61585. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61586. * @returns True if it has been started, otherwise false.
  61587. */
  61588. isStarted(): boolean;
  61589. /**
  61590. * Starts the particle system and begins to emit
  61591. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61592. */
  61593. start(delay?: number): void;
  61594. /**
  61595. * Stops the particle system.
  61596. */
  61597. stop(): void;
  61598. /**
  61599. * Remove all active particles
  61600. */
  61601. reset(): void;
  61602. /**
  61603. * Returns the string "GPUParticleSystem"
  61604. * @returns a string containing the class name
  61605. */
  61606. getClassName(): string;
  61607. private _colorGradientsTexture;
  61608. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61609. /**
  61610. * Adds a new color gradient
  61611. * @param gradient defines the gradient to use (between 0 and 1)
  61612. * @param color1 defines the color to affect to the specified gradient
  61613. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61614. * @returns the current particle system
  61615. */
  61616. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61617. /**
  61618. * Remove a specific color gradient
  61619. * @param gradient defines the gradient to remove
  61620. * @returns the current particle system
  61621. */
  61622. removeColorGradient(gradient: number): GPUParticleSystem;
  61623. private _angularSpeedGradientsTexture;
  61624. private _sizeGradientsTexture;
  61625. private _velocityGradientsTexture;
  61626. private _limitVelocityGradientsTexture;
  61627. private _dragGradientsTexture;
  61628. private _addFactorGradient;
  61629. /**
  61630. * Adds a new size gradient
  61631. * @param gradient defines the gradient to use (between 0 and 1)
  61632. * @param factor defines the size factor to affect to the specified gradient
  61633. * @returns the current particle system
  61634. */
  61635. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61636. /**
  61637. * Remove a specific size gradient
  61638. * @param gradient defines the gradient to remove
  61639. * @returns the current particle system
  61640. */
  61641. removeSizeGradient(gradient: number): GPUParticleSystem;
  61642. /**
  61643. * Adds a new angular speed gradient
  61644. * @param gradient defines the gradient to use (between 0 and 1)
  61645. * @param factor defines the angular speed to affect to the specified gradient
  61646. * @returns the current particle system
  61647. */
  61648. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61649. /**
  61650. * Remove a specific angular speed gradient
  61651. * @param gradient defines the gradient to remove
  61652. * @returns the current particle system
  61653. */
  61654. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61655. /**
  61656. * Adds a new velocity gradient
  61657. * @param gradient defines the gradient to use (between 0 and 1)
  61658. * @param factor defines the velocity to affect to the specified gradient
  61659. * @returns the current particle system
  61660. */
  61661. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61662. /**
  61663. * Remove a specific velocity gradient
  61664. * @param gradient defines the gradient to remove
  61665. * @returns the current particle system
  61666. */
  61667. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61668. /**
  61669. * Adds a new limit velocity gradient
  61670. * @param gradient defines the gradient to use (between 0 and 1)
  61671. * @param factor defines the limit velocity value to affect to the specified gradient
  61672. * @returns the current particle system
  61673. */
  61674. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61675. /**
  61676. * Remove a specific limit velocity gradient
  61677. * @param gradient defines the gradient to remove
  61678. * @returns the current particle system
  61679. */
  61680. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61681. /**
  61682. * Adds a new drag gradient
  61683. * @param gradient defines the gradient to use (between 0 and 1)
  61684. * @param factor defines the drag value to affect to the specified gradient
  61685. * @returns the current particle system
  61686. */
  61687. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61688. /**
  61689. * Remove a specific drag gradient
  61690. * @param gradient defines the gradient to remove
  61691. * @returns the current particle system
  61692. */
  61693. removeDragGradient(gradient: number): GPUParticleSystem;
  61694. /**
  61695. * Not supported by GPUParticleSystem
  61696. * @param gradient defines the gradient to use (between 0 and 1)
  61697. * @param factor defines the emit rate value to affect to the specified gradient
  61698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61699. * @returns the current particle system
  61700. */
  61701. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61702. /**
  61703. * Not supported by GPUParticleSystem
  61704. * @param gradient defines the gradient to remove
  61705. * @returns the current particle system
  61706. */
  61707. removeEmitRateGradient(gradient: number): IParticleSystem;
  61708. /**
  61709. * Not supported by GPUParticleSystem
  61710. * @param gradient defines the gradient to use (between 0 and 1)
  61711. * @param factor defines the start size value to affect to the specified gradient
  61712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61713. * @returns the current particle system
  61714. */
  61715. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61716. /**
  61717. * Not supported by GPUParticleSystem
  61718. * @param gradient defines the gradient to remove
  61719. * @returns the current particle system
  61720. */
  61721. removeStartSizeGradient(gradient: number): IParticleSystem;
  61722. /**
  61723. * Not supported by GPUParticleSystem
  61724. * @param gradient defines the gradient to use (between 0 and 1)
  61725. * @param min defines the color remap minimal range
  61726. * @param max defines the color remap maximal range
  61727. * @returns the current particle system
  61728. */
  61729. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61730. /**
  61731. * Not supported by GPUParticleSystem
  61732. * @param gradient defines the gradient to remove
  61733. * @returns the current particle system
  61734. */
  61735. removeColorRemapGradient(): IParticleSystem;
  61736. /**
  61737. * Not supported by GPUParticleSystem
  61738. * @param gradient defines the gradient to use (between 0 and 1)
  61739. * @param min defines the alpha remap minimal range
  61740. * @param max defines the alpha remap maximal range
  61741. * @returns the current particle system
  61742. */
  61743. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61744. /**
  61745. * Not supported by GPUParticleSystem
  61746. * @param gradient defines the gradient to remove
  61747. * @returns the current particle system
  61748. */
  61749. removeAlphaRemapGradient(): IParticleSystem;
  61750. /**
  61751. * Not supported by GPUParticleSystem
  61752. * @param gradient defines the gradient to use (between 0 and 1)
  61753. * @param color defines the color to affect to the specified gradient
  61754. * @returns the current particle system
  61755. */
  61756. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61757. /**
  61758. * Not supported by GPUParticleSystem
  61759. * @param gradient defines the gradient to remove
  61760. * @returns the current particle system
  61761. */
  61762. removeRampGradient(): IParticleSystem;
  61763. /**
  61764. * Not supported by GPUParticleSystem
  61765. * @returns the list of ramp gradients
  61766. */
  61767. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61768. /**
  61769. * Not supported by GPUParticleSystem
  61770. * Gets or sets a boolean indicating that ramp gradients must be used
  61771. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61772. */
  61773. useRampGradients: boolean;
  61774. /**
  61775. * Not supported by GPUParticleSystem
  61776. * @param gradient defines the gradient to use (between 0 and 1)
  61777. * @param factor defines the life time factor to affect to the specified gradient
  61778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61779. * @returns the current particle system
  61780. */
  61781. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61782. /**
  61783. * Not supported by GPUParticleSystem
  61784. * @param gradient defines the gradient to remove
  61785. * @returns the current particle system
  61786. */
  61787. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61788. /**
  61789. * Instantiates a GPU particle system.
  61790. * 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.
  61791. * @param name The name of the particle system
  61792. * @param options The options used to create the system
  61793. * @param scene The scene the particle system belongs to
  61794. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61795. */
  61796. constructor(name: string, options: Partial<{
  61797. capacity: number;
  61798. randomTextureSize: number;
  61799. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61800. protected _reset(): void;
  61801. private _createUpdateVAO;
  61802. private _createRenderVAO;
  61803. private _initialize;
  61804. /** @hidden */
  61805. _recreateUpdateEffect(): void;
  61806. /** @hidden */
  61807. _recreateRenderEffect(): void;
  61808. /**
  61809. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61810. * @param preWarm defines if we are in the pre-warmimg phase
  61811. */
  61812. animate(preWarm?: boolean): void;
  61813. private _createFactorGradientTexture;
  61814. private _createSizeGradientTexture;
  61815. private _createAngularSpeedGradientTexture;
  61816. private _createVelocityGradientTexture;
  61817. private _createLimitVelocityGradientTexture;
  61818. private _createDragGradientTexture;
  61819. private _createColorGradientTexture;
  61820. /**
  61821. * Renders the particle system in its current state
  61822. * @param preWarm defines if the system should only update the particles but not render them
  61823. * @returns the current number of particles
  61824. */
  61825. render(preWarm?: boolean): number;
  61826. /**
  61827. * Rebuilds the particle system
  61828. */
  61829. rebuild(): void;
  61830. private _releaseBuffers;
  61831. private _releaseVAOs;
  61832. /**
  61833. * Disposes the particle system and free the associated resources
  61834. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61835. */
  61836. dispose(disposeTexture?: boolean): void;
  61837. /**
  61838. * Clones the particle system.
  61839. * @param name The name of the cloned object
  61840. * @param newEmitter The new emitter to use
  61841. * @returns the cloned particle system
  61842. */
  61843. clone(name: string, newEmitter: any): GPUParticleSystem;
  61844. /**
  61845. * Serializes the particle system to a JSON object.
  61846. * @returns the JSON object
  61847. */
  61848. serialize(): any;
  61849. /**
  61850. * Parses a JSON object to create a GPU particle system.
  61851. * @param parsedParticleSystem The JSON object to parse
  61852. * @param scene The scene to create the particle system in
  61853. * @param rootUrl The root url to use to load external dependencies like texture
  61854. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61855. * @returns the parsed GPU particle system
  61856. */
  61857. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61858. }
  61859. }
  61860. declare module "babylonjs/Particles/particleSystemSet" {
  61861. import { Nullable } from "babylonjs/types";
  61862. import { Color3 } from "babylonjs/Maths/math.color";
  61863. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61865. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61866. import { Scene, IDisposable } from "babylonjs/scene";
  61867. /**
  61868. * Represents a set of particle systems working together to create a specific effect
  61869. */
  61870. export class ParticleSystemSet implements IDisposable {
  61871. /**
  61872. * Gets or sets base Assets URL
  61873. */
  61874. static BaseAssetsUrl: string;
  61875. private _emitterCreationOptions;
  61876. private _emitterNode;
  61877. /**
  61878. * Gets the particle system list
  61879. */
  61880. systems: IParticleSystem[];
  61881. /**
  61882. * Gets the emitter node used with this set
  61883. */
  61884. readonly emitterNode: Nullable<TransformNode>;
  61885. /**
  61886. * Creates a new emitter mesh as a sphere
  61887. * @param options defines the options used to create the sphere
  61888. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61889. * @param scene defines the hosting scene
  61890. */
  61891. setEmitterAsSphere(options: {
  61892. diameter: number;
  61893. segments: number;
  61894. color: Color3;
  61895. }, renderingGroupId: number, scene: Scene): void;
  61896. /**
  61897. * Starts all particle systems of the set
  61898. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61899. */
  61900. start(emitter?: AbstractMesh): void;
  61901. /**
  61902. * Release all associated resources
  61903. */
  61904. dispose(): void;
  61905. /**
  61906. * Serialize the set into a JSON compatible object
  61907. * @returns a JSON compatible representation of the set
  61908. */
  61909. serialize(): any;
  61910. /**
  61911. * Parse a new ParticleSystemSet from a serialized source
  61912. * @param data defines a JSON compatible representation of the set
  61913. * @param scene defines the hosting scene
  61914. * @param gpu defines if we want GPU particles or CPU particles
  61915. * @returns a new ParticleSystemSet
  61916. */
  61917. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61918. }
  61919. }
  61920. declare module "babylonjs/Particles/particleHelper" {
  61921. import { Nullable } from "babylonjs/types";
  61922. import { Scene } from "babylonjs/scene";
  61923. import { Vector3 } from "babylonjs/Maths/math.vector";
  61924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61925. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61926. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61927. /**
  61928. * This class is made for on one-liner static method to help creating particle system set.
  61929. */
  61930. export class ParticleHelper {
  61931. /**
  61932. * Gets or sets base Assets URL
  61933. */
  61934. static BaseAssetsUrl: string;
  61935. /**
  61936. * Create a default particle system that you can tweak
  61937. * @param emitter defines the emitter to use
  61938. * @param capacity defines the system capacity (default is 500 particles)
  61939. * @param scene defines the hosting scene
  61940. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61941. * @returns the new Particle system
  61942. */
  61943. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61944. /**
  61945. * This is the main static method (one-liner) of this helper to create different particle systems
  61946. * @param type This string represents the type to the particle system to create
  61947. * @param scene The scene where the particle system should live
  61948. * @param gpu If the system will use gpu
  61949. * @returns the ParticleSystemSet created
  61950. */
  61951. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61952. /**
  61953. * Static function used to export a particle system to a ParticleSystemSet variable.
  61954. * Please note that the emitter shape is not exported
  61955. * @param systems defines the particle systems to export
  61956. * @returns the created particle system set
  61957. */
  61958. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61959. }
  61960. }
  61961. declare module "babylonjs/Particles/particleSystemComponent" {
  61962. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61963. import { Effect } from "babylonjs/Materials/effect";
  61964. import "babylonjs/Shaders/particles.vertex";
  61965. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61966. module "babylonjs/Engines/engine" {
  61967. interface Engine {
  61968. /**
  61969. * Create an effect to use with particle systems.
  61970. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61971. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61972. * @param uniformsNames defines a list of attribute names
  61973. * @param samplers defines an array of string used to represent textures
  61974. * @param defines defines the string containing the defines to use to compile the shaders
  61975. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61976. * @param onCompiled defines a function to call when the effect creation is successful
  61977. * @param onError defines a function to call when the effect creation has failed
  61978. * @returns the new Effect
  61979. */
  61980. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61981. }
  61982. }
  61983. module "babylonjs/Meshes/mesh" {
  61984. interface Mesh {
  61985. /**
  61986. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61987. * @returns an array of IParticleSystem
  61988. */
  61989. getEmittedParticleSystems(): IParticleSystem[];
  61990. /**
  61991. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61992. * @returns an array of IParticleSystem
  61993. */
  61994. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61995. }
  61996. }
  61997. /**
  61998. * @hidden
  61999. */
  62000. export var _IDoNeedToBeInTheBuild: number;
  62001. }
  62002. declare module "babylonjs/Particles/pointsCloudSystem" {
  62003. import { Color4 } from "babylonjs/Maths/math";
  62004. import { Mesh } from "babylonjs/Meshes/mesh";
  62005. import { Scene, IDisposable } from "babylonjs/scene";
  62006. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62007. /** Defines the 4 color options */
  62008. export enum PointColor {
  62009. /** color value */
  62010. Color = 2,
  62011. /** uv value */
  62012. UV = 1,
  62013. /** random value */
  62014. Random = 0,
  62015. /** stated value */
  62016. Stated = 3
  62017. }
  62018. /**
  62019. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62020. * 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.
  62021. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62022. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62023. *
  62024. * Full documentation here : TO BE ENTERED
  62025. */
  62026. export class PointsCloudSystem implements IDisposable {
  62027. /**
  62028. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62029. * Example : var p = SPS.particles[i];
  62030. */
  62031. particles: CloudPoint[];
  62032. /**
  62033. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62034. */
  62035. nbParticles: number;
  62036. /**
  62037. * This a counter for your own usage. It's not set by any SPS functions.
  62038. */
  62039. counter: number;
  62040. /**
  62041. * The PCS name. This name is also given to the underlying mesh.
  62042. */
  62043. name: string;
  62044. /**
  62045. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62046. */
  62047. mesh: Mesh;
  62048. /**
  62049. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62050. * Please read :
  62051. */
  62052. vars: any;
  62053. /**
  62054. * @hidden
  62055. */
  62056. _size: number;
  62057. private _scene;
  62058. private _promises;
  62059. private _positions;
  62060. private _indices;
  62061. private _normals;
  62062. private _colors;
  62063. private _uvs;
  62064. private _indices32;
  62065. private _positions32;
  62066. private _colors32;
  62067. private _uvs32;
  62068. private _updatable;
  62069. private _isVisibilityBoxLocked;
  62070. private _alwaysVisible;
  62071. private _groups;
  62072. private _groupCounter;
  62073. private _computeParticleColor;
  62074. private _computeParticleTexture;
  62075. private _computeParticleRotation;
  62076. private _computeBoundingBox;
  62077. private _isReady;
  62078. /**
  62079. * Creates a PCS (Points Cloud System) object
  62080. * @param name (String) is the PCS name, this will be the underlying mesh name
  62081. * @param pointSize (number) is the size for each point
  62082. * @param scene (Scene) is the scene in which the PCS is added
  62083. * @param options defines the options of the PCS e.g.
  62084. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62085. */
  62086. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62087. updatable?: boolean;
  62088. });
  62089. /**
  62090. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62091. * If no points were added to the PCS, the returned mesh is just a single point.
  62092. * @returns a promise for the created mesh
  62093. */
  62094. buildMeshAsync(): Promise<Mesh>;
  62095. /**
  62096. * @hidden
  62097. */
  62098. private _buildMesh;
  62099. private _addParticle;
  62100. private _randomUnitVector;
  62101. private _getColorIndicesForCoord;
  62102. private _setPointsColorOrUV;
  62103. private _colorFromTexture;
  62104. private _calculateDensity;
  62105. /**
  62106. * Adds points to the PCS in random positions within a unit sphere
  62107. * @param nb (positive integer) the number of particles to be created from this model
  62108. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62109. * @returns the number of groups in the system
  62110. */
  62111. addPoints(nb: number, pointFunction?: any): number;
  62112. /**
  62113. * Adds points to the PCS from the surface of the model shape
  62114. * @param mesh is any Mesh object that will be used as a surface model for the points
  62115. * @param nb (positive integer) the number of particles to be created from this model
  62116. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62117. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62118. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62119. * @returns the number of groups in the system
  62120. */
  62121. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62122. /**
  62123. * Adds points to the PCS inside the model shape
  62124. * @param mesh is any Mesh object that will be used as a surface model for the points
  62125. * @param nb (positive integer) the number of particles to be created from this model
  62126. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62127. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62128. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62129. * @returns the number of groups in the system
  62130. */
  62131. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62132. /**
  62133. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62134. * This method calls `updateParticle()` for each particle of the SPS.
  62135. * For an animated SPS, it is usually called within the render loop.
  62136. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62137. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62138. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62139. * @returns the PCS.
  62140. */
  62141. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62142. /**
  62143. * Disposes the PCS.
  62144. */
  62145. dispose(): void;
  62146. /**
  62147. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62148. * doc :
  62149. * @returns the PCS.
  62150. */
  62151. refreshVisibleSize(): PointsCloudSystem;
  62152. /**
  62153. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62154. * @param size the size (float) of the visibility box
  62155. * note : this doesn't lock the PCS mesh bounding box.
  62156. * doc :
  62157. */
  62158. setVisibilityBox(size: number): void;
  62159. /**
  62160. * Gets whether the PCS is always visible or not
  62161. * doc :
  62162. */
  62163. /**
  62164. * Sets the PCS as always visible or not
  62165. * doc :
  62166. */
  62167. isAlwaysVisible: boolean;
  62168. /**
  62169. * Tells to `setParticles()` to compute the particle rotations or not
  62170. * Default value : false. The PCS is faster when it's set to false
  62171. * Note : particle rotations are only applied to parent particles
  62172. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62173. */
  62174. computeParticleRotation: boolean;
  62175. /**
  62176. * Tells to `setParticles()` to compute the particle colors or not.
  62177. * Default value : true. The PCS is faster when it's set to false.
  62178. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62179. */
  62180. /**
  62181. * Gets if `setParticles()` computes the particle colors or not.
  62182. * Default value : false. The PCS is faster when it's set to false.
  62183. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62184. */
  62185. computeParticleColor: boolean;
  62186. /**
  62187. * Gets if `setParticles()` computes the particle textures or not.
  62188. * Default value : false. The PCS is faster when it's set to false.
  62189. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62190. */
  62191. computeParticleTexture: boolean;
  62192. /**
  62193. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62194. */
  62195. /**
  62196. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62197. */
  62198. computeBoundingBox: boolean;
  62199. /**
  62200. * This function does nothing. It may be overwritten to set all the particle first values.
  62201. * The PCS doesn't call this function, you may have to call it by your own.
  62202. * doc :
  62203. */
  62204. initParticles(): void;
  62205. /**
  62206. * This function does nothing. It may be overwritten to recycle a particle
  62207. * The PCS doesn't call this function, you can to call it
  62208. * doc :
  62209. * @param particle The particle to recycle
  62210. * @returns the recycled particle
  62211. */
  62212. recycleParticle(particle: CloudPoint): CloudPoint;
  62213. /**
  62214. * Updates a particle : this function should be overwritten by the user.
  62215. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62216. * doc :
  62217. * @example : just set a particle position or velocity and recycle conditions
  62218. * @param particle The particle to update
  62219. * @returns the updated particle
  62220. */
  62221. updateParticle(particle: CloudPoint): CloudPoint;
  62222. /**
  62223. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62224. * This does nothing and may be overwritten by the user.
  62225. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62226. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62227. * @param update the boolean update value actually passed to setParticles()
  62228. */
  62229. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62230. /**
  62231. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62232. * This will be passed three parameters.
  62233. * This does nothing and may be overwritten by the user.
  62234. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62235. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62236. * @param update the boolean update value actually passed to setParticles()
  62237. */
  62238. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62239. }
  62240. }
  62241. declare module "babylonjs/Particles/cloudPoint" {
  62242. import { Nullable } from "babylonjs/types";
  62243. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62244. import { Mesh } from "babylonjs/Meshes/mesh";
  62245. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62246. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62247. /**
  62248. * Represents one particle of a points cloud system.
  62249. */
  62250. export class CloudPoint {
  62251. /**
  62252. * particle global index
  62253. */
  62254. idx: number;
  62255. /**
  62256. * The color of the particle
  62257. */
  62258. color: Nullable<Color4>;
  62259. /**
  62260. * The world space position of the particle.
  62261. */
  62262. position: Vector3;
  62263. /**
  62264. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62265. */
  62266. rotation: Vector3;
  62267. /**
  62268. * The world space rotation quaternion of the particle.
  62269. */
  62270. rotationQuaternion: Nullable<Quaternion>;
  62271. /**
  62272. * The uv of the particle.
  62273. */
  62274. uv: Nullable<Vector2>;
  62275. /**
  62276. * The current speed of the particle.
  62277. */
  62278. velocity: Vector3;
  62279. /**
  62280. * The pivot point in the particle local space.
  62281. */
  62282. pivot: Vector3;
  62283. /**
  62284. * Must the particle be translated from its pivot point in its local space ?
  62285. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62286. * Default : false
  62287. */
  62288. translateFromPivot: boolean;
  62289. /**
  62290. * Index of this particle in the global "positions" array (Internal use)
  62291. * @hidden
  62292. */
  62293. _pos: number;
  62294. /**
  62295. * @hidden Index of this particle in the global "indices" array (Internal use)
  62296. */
  62297. _ind: number;
  62298. /**
  62299. * Group this particle belongs to
  62300. */
  62301. _group: PointsGroup;
  62302. /**
  62303. * Group id of this particle
  62304. */
  62305. groupId: number;
  62306. /**
  62307. * Index of the particle in its group id (Internal use)
  62308. */
  62309. idxInGroup: number;
  62310. /**
  62311. * @hidden Particle BoundingInfo object (Internal use)
  62312. */
  62313. _boundingInfo: BoundingInfo;
  62314. /**
  62315. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62316. */
  62317. _pcs: PointsCloudSystem;
  62318. /**
  62319. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62320. */
  62321. _stillInvisible: boolean;
  62322. /**
  62323. * @hidden Last computed particle rotation matrix
  62324. */
  62325. _rotationMatrix: number[];
  62326. /**
  62327. * Parent particle Id, if any.
  62328. * Default null.
  62329. */
  62330. parentId: Nullable<number>;
  62331. /**
  62332. * @hidden Internal global position in the PCS.
  62333. */
  62334. _globalPosition: Vector3;
  62335. /**
  62336. * Creates a Point Cloud object.
  62337. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62338. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62339. * @param group (PointsGroup) is the group the particle belongs to
  62340. * @param groupId (integer) is the group identifier in the PCS.
  62341. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62342. * @param pcs defines the PCS it is associated to
  62343. */
  62344. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62345. /**
  62346. * get point size
  62347. */
  62348. /**
  62349. * Set point size
  62350. */
  62351. size: Vector3;
  62352. /**
  62353. * Legacy support, changed quaternion to rotationQuaternion
  62354. */
  62355. /**
  62356. * Legacy support, changed quaternion to rotationQuaternion
  62357. */
  62358. quaternion: Nullable<Quaternion>;
  62359. /**
  62360. * Returns a boolean. True if the particle intersects a mesh, else false
  62361. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62362. * @param target is the object (point or mesh) what the intersection is computed against
  62363. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62364. * @returns true if it intersects
  62365. */
  62366. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62367. /**
  62368. * get the rotation matrix of the particle
  62369. * @hidden
  62370. */
  62371. getRotationMatrix(m: Matrix): void;
  62372. }
  62373. /**
  62374. * Represents a group of points in a points cloud system
  62375. * * PCS internal tool, don't use it manually.
  62376. */
  62377. export class PointsGroup {
  62378. /**
  62379. * The group id
  62380. * @hidden
  62381. */
  62382. groupID: number;
  62383. /**
  62384. * image data for group (internal use)
  62385. * @hidden
  62386. */
  62387. _groupImageData: Nullable<ArrayBufferView>;
  62388. /**
  62389. * Image Width (internal use)
  62390. * @hidden
  62391. */
  62392. _groupImgWidth: number;
  62393. /**
  62394. * Image Height (internal use)
  62395. * @hidden
  62396. */
  62397. _groupImgHeight: number;
  62398. /**
  62399. * Custom position function (internal use)
  62400. * @hidden
  62401. */
  62402. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62403. /**
  62404. * density per facet for surface points
  62405. * @hidden
  62406. */
  62407. _groupDensity: number[];
  62408. /**
  62409. * Only when points are colored by texture carries pointer to texture list array
  62410. * @hidden
  62411. */
  62412. _textureNb: number;
  62413. /**
  62414. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62415. * PCS internal tool, don't use it manually.
  62416. * @hidden
  62417. */
  62418. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62419. }
  62420. }
  62421. declare module "babylonjs/Particles/index" {
  62422. export * from "babylonjs/Particles/baseParticleSystem";
  62423. export * from "babylonjs/Particles/EmitterTypes/index";
  62424. export * from "babylonjs/Particles/gpuParticleSystem";
  62425. export * from "babylonjs/Particles/IParticleSystem";
  62426. export * from "babylonjs/Particles/particle";
  62427. export * from "babylonjs/Particles/particleHelper";
  62428. export * from "babylonjs/Particles/particleSystem";
  62429. export * from "babylonjs/Particles/particleSystemComponent";
  62430. export * from "babylonjs/Particles/particleSystemSet";
  62431. export * from "babylonjs/Particles/solidParticle";
  62432. export * from "babylonjs/Particles/solidParticleSystem";
  62433. export * from "babylonjs/Particles/cloudPoint";
  62434. export * from "babylonjs/Particles/pointsCloudSystem";
  62435. export * from "babylonjs/Particles/subEmitter";
  62436. }
  62437. declare module "babylonjs/Physics/physicsEngineComponent" {
  62438. import { Nullable } from "babylonjs/types";
  62439. import { Observable, Observer } from "babylonjs/Misc/observable";
  62440. import { Vector3 } from "babylonjs/Maths/math.vector";
  62441. import { Mesh } from "babylonjs/Meshes/mesh";
  62442. import { ISceneComponent } from "babylonjs/sceneComponent";
  62443. import { Scene } from "babylonjs/scene";
  62444. import { Node } from "babylonjs/node";
  62445. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62446. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62447. module "babylonjs/scene" {
  62448. interface Scene {
  62449. /** @hidden (Backing field) */
  62450. _physicsEngine: Nullable<IPhysicsEngine>;
  62451. /**
  62452. * Gets the current physics engine
  62453. * @returns a IPhysicsEngine or null if none attached
  62454. */
  62455. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62456. /**
  62457. * Enables physics to the current scene
  62458. * @param gravity defines the scene's gravity for the physics engine
  62459. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62460. * @return a boolean indicating if the physics engine was initialized
  62461. */
  62462. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62463. /**
  62464. * Disables and disposes the physics engine associated with the scene
  62465. */
  62466. disablePhysicsEngine(): void;
  62467. /**
  62468. * Gets a boolean indicating if there is an active physics engine
  62469. * @returns a boolean indicating if there is an active physics engine
  62470. */
  62471. isPhysicsEnabled(): boolean;
  62472. /**
  62473. * Deletes a physics compound impostor
  62474. * @param compound defines the compound to delete
  62475. */
  62476. deleteCompoundImpostor(compound: any): void;
  62477. /**
  62478. * An event triggered when physic simulation is about to be run
  62479. */
  62480. onBeforePhysicsObservable: Observable<Scene>;
  62481. /**
  62482. * An event triggered when physic simulation has been done
  62483. */
  62484. onAfterPhysicsObservable: Observable<Scene>;
  62485. }
  62486. }
  62487. module "babylonjs/Meshes/abstractMesh" {
  62488. interface AbstractMesh {
  62489. /** @hidden */
  62490. _physicsImpostor: Nullable<PhysicsImpostor>;
  62491. /**
  62492. * Gets or sets impostor used for physic simulation
  62493. * @see http://doc.babylonjs.com/features/physics_engine
  62494. */
  62495. physicsImpostor: Nullable<PhysicsImpostor>;
  62496. /**
  62497. * Gets the current physics impostor
  62498. * @see http://doc.babylonjs.com/features/physics_engine
  62499. * @returns a physics impostor or null
  62500. */
  62501. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62502. /** Apply a physic impulse to the mesh
  62503. * @param force defines the force to apply
  62504. * @param contactPoint defines where to apply the force
  62505. * @returns the current mesh
  62506. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62507. */
  62508. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62509. /**
  62510. * Creates a physic joint between two meshes
  62511. * @param otherMesh defines the other mesh to use
  62512. * @param pivot1 defines the pivot to use on this mesh
  62513. * @param pivot2 defines the pivot to use on the other mesh
  62514. * @param options defines additional options (can be plugin dependent)
  62515. * @returns the current mesh
  62516. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62517. */
  62518. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62519. /** @hidden */
  62520. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62521. }
  62522. }
  62523. /**
  62524. * Defines the physics engine scene component responsible to manage a physics engine
  62525. */
  62526. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62527. /**
  62528. * The component name helpful to identify the component in the list of scene components.
  62529. */
  62530. readonly name: string;
  62531. /**
  62532. * The scene the component belongs to.
  62533. */
  62534. scene: Scene;
  62535. /**
  62536. * Creates a new instance of the component for the given scene
  62537. * @param scene Defines the scene to register the component in
  62538. */
  62539. constructor(scene: Scene);
  62540. /**
  62541. * Registers the component in a given scene
  62542. */
  62543. register(): void;
  62544. /**
  62545. * Rebuilds the elements related to this component in case of
  62546. * context lost for instance.
  62547. */
  62548. rebuild(): void;
  62549. /**
  62550. * Disposes the component and the associated ressources
  62551. */
  62552. dispose(): void;
  62553. }
  62554. }
  62555. declare module "babylonjs/Physics/physicsHelper" {
  62556. import { Nullable } from "babylonjs/types";
  62557. import { Vector3 } from "babylonjs/Maths/math.vector";
  62558. import { Mesh } from "babylonjs/Meshes/mesh";
  62559. import { Scene } from "babylonjs/scene";
  62560. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62561. /**
  62562. * A helper for physics simulations
  62563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62564. */
  62565. export class PhysicsHelper {
  62566. private _scene;
  62567. private _physicsEngine;
  62568. /**
  62569. * Initializes the Physics helper
  62570. * @param scene Babylon.js scene
  62571. */
  62572. constructor(scene: Scene);
  62573. /**
  62574. * Applies a radial explosion impulse
  62575. * @param origin the origin of the explosion
  62576. * @param radiusOrEventOptions the radius or the options of radial explosion
  62577. * @param strength the explosion strength
  62578. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62579. * @returns A physics radial explosion event, or null
  62580. */
  62581. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62582. /**
  62583. * Applies a radial explosion force
  62584. * @param origin the origin of the explosion
  62585. * @param radiusOrEventOptions the radius or the options of radial explosion
  62586. * @param strength the explosion strength
  62587. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62588. * @returns A physics radial explosion event, or null
  62589. */
  62590. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62591. /**
  62592. * Creates a gravitational field
  62593. * @param origin the origin of the explosion
  62594. * @param radiusOrEventOptions the radius or the options of radial explosion
  62595. * @param strength the explosion strength
  62596. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62597. * @returns A physics gravitational field event, or null
  62598. */
  62599. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62600. /**
  62601. * Creates a physics updraft event
  62602. * @param origin the origin of the updraft
  62603. * @param radiusOrEventOptions the radius or the options of the updraft
  62604. * @param strength the strength of the updraft
  62605. * @param height the height of the updraft
  62606. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62607. * @returns A physics updraft event, or null
  62608. */
  62609. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62610. /**
  62611. * Creates a physics vortex event
  62612. * @param origin the of the vortex
  62613. * @param radiusOrEventOptions the radius or the options of the vortex
  62614. * @param strength the strength of the vortex
  62615. * @param height the height of the vortex
  62616. * @returns a Physics vortex event, or null
  62617. * A physics vortex event or null
  62618. */
  62619. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62620. }
  62621. /**
  62622. * Represents a physics radial explosion event
  62623. */
  62624. class PhysicsRadialExplosionEvent {
  62625. private _scene;
  62626. private _options;
  62627. private _sphere;
  62628. private _dataFetched;
  62629. /**
  62630. * Initializes a radial explosioin event
  62631. * @param _scene BabylonJS scene
  62632. * @param _options The options for the vortex event
  62633. */
  62634. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62635. /**
  62636. * Returns the data related to the radial explosion event (sphere).
  62637. * @returns The radial explosion event data
  62638. */
  62639. getData(): PhysicsRadialExplosionEventData;
  62640. /**
  62641. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62642. * @param impostor A physics imposter
  62643. * @param origin the origin of the explosion
  62644. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62645. */
  62646. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62647. /**
  62648. * Triggers affecterd impostors callbacks
  62649. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62650. */
  62651. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62652. /**
  62653. * Disposes the sphere.
  62654. * @param force Specifies if the sphere should be disposed by force
  62655. */
  62656. dispose(force?: boolean): void;
  62657. /*** Helpers ***/
  62658. private _prepareSphere;
  62659. private _intersectsWithSphere;
  62660. }
  62661. /**
  62662. * Represents a gravitational field event
  62663. */
  62664. class PhysicsGravitationalFieldEvent {
  62665. private _physicsHelper;
  62666. private _scene;
  62667. private _origin;
  62668. private _options;
  62669. private _tickCallback;
  62670. private _sphere;
  62671. private _dataFetched;
  62672. /**
  62673. * Initializes the physics gravitational field event
  62674. * @param _physicsHelper A physics helper
  62675. * @param _scene BabylonJS scene
  62676. * @param _origin The origin position of the gravitational field event
  62677. * @param _options The options for the vortex event
  62678. */
  62679. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62680. /**
  62681. * Returns the data related to the gravitational field event (sphere).
  62682. * @returns A gravitational field event
  62683. */
  62684. getData(): PhysicsGravitationalFieldEventData;
  62685. /**
  62686. * Enables the gravitational field.
  62687. */
  62688. enable(): void;
  62689. /**
  62690. * Disables the gravitational field.
  62691. */
  62692. disable(): void;
  62693. /**
  62694. * Disposes the sphere.
  62695. * @param force The force to dispose from the gravitational field event
  62696. */
  62697. dispose(force?: boolean): void;
  62698. private _tick;
  62699. }
  62700. /**
  62701. * Represents a physics updraft event
  62702. */
  62703. class PhysicsUpdraftEvent {
  62704. private _scene;
  62705. private _origin;
  62706. private _options;
  62707. private _physicsEngine;
  62708. private _originTop;
  62709. private _originDirection;
  62710. private _tickCallback;
  62711. private _cylinder;
  62712. private _cylinderPosition;
  62713. private _dataFetched;
  62714. /**
  62715. * Initializes the physics updraft event
  62716. * @param _scene BabylonJS scene
  62717. * @param _origin The origin position of the updraft
  62718. * @param _options The options for the updraft event
  62719. */
  62720. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62721. /**
  62722. * Returns the data related to the updraft event (cylinder).
  62723. * @returns A physics updraft event
  62724. */
  62725. getData(): PhysicsUpdraftEventData;
  62726. /**
  62727. * Enables the updraft.
  62728. */
  62729. enable(): void;
  62730. /**
  62731. * Disables the updraft.
  62732. */
  62733. disable(): void;
  62734. /**
  62735. * Disposes the cylinder.
  62736. * @param force Specifies if the updraft should be disposed by force
  62737. */
  62738. dispose(force?: boolean): void;
  62739. private getImpostorHitData;
  62740. private _tick;
  62741. /*** Helpers ***/
  62742. private _prepareCylinder;
  62743. private _intersectsWithCylinder;
  62744. }
  62745. /**
  62746. * Represents a physics vortex event
  62747. */
  62748. class PhysicsVortexEvent {
  62749. private _scene;
  62750. private _origin;
  62751. private _options;
  62752. private _physicsEngine;
  62753. private _originTop;
  62754. private _tickCallback;
  62755. private _cylinder;
  62756. private _cylinderPosition;
  62757. private _dataFetched;
  62758. /**
  62759. * Initializes the physics vortex event
  62760. * @param _scene The BabylonJS scene
  62761. * @param _origin The origin position of the vortex
  62762. * @param _options The options for the vortex event
  62763. */
  62764. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62765. /**
  62766. * Returns the data related to the vortex event (cylinder).
  62767. * @returns The physics vortex event data
  62768. */
  62769. getData(): PhysicsVortexEventData;
  62770. /**
  62771. * Enables the vortex.
  62772. */
  62773. enable(): void;
  62774. /**
  62775. * Disables the cortex.
  62776. */
  62777. disable(): void;
  62778. /**
  62779. * Disposes the sphere.
  62780. * @param force
  62781. */
  62782. dispose(force?: boolean): void;
  62783. private getImpostorHitData;
  62784. private _tick;
  62785. /*** Helpers ***/
  62786. private _prepareCylinder;
  62787. private _intersectsWithCylinder;
  62788. }
  62789. /**
  62790. * Options fot the radial explosion event
  62791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62792. */
  62793. export class PhysicsRadialExplosionEventOptions {
  62794. /**
  62795. * The radius of the sphere for the radial explosion.
  62796. */
  62797. radius: number;
  62798. /**
  62799. * The strenth of the explosion.
  62800. */
  62801. strength: number;
  62802. /**
  62803. * The strenght of the force in correspondence to the distance of the affected object
  62804. */
  62805. falloff: PhysicsRadialImpulseFalloff;
  62806. /**
  62807. * Sphere options for the radial explosion.
  62808. */
  62809. sphere: {
  62810. segments: number;
  62811. diameter: number;
  62812. };
  62813. /**
  62814. * Sphere options for the radial explosion.
  62815. */
  62816. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62817. }
  62818. /**
  62819. * Options fot the updraft event
  62820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62821. */
  62822. export class PhysicsUpdraftEventOptions {
  62823. /**
  62824. * The radius of the cylinder for the vortex
  62825. */
  62826. radius: number;
  62827. /**
  62828. * The strenth of the updraft.
  62829. */
  62830. strength: number;
  62831. /**
  62832. * The height of the cylinder for the updraft.
  62833. */
  62834. height: number;
  62835. /**
  62836. * The mode for the the updraft.
  62837. */
  62838. updraftMode: PhysicsUpdraftMode;
  62839. }
  62840. /**
  62841. * Options fot the vortex event
  62842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62843. */
  62844. export class PhysicsVortexEventOptions {
  62845. /**
  62846. * The radius of the cylinder for the vortex
  62847. */
  62848. radius: number;
  62849. /**
  62850. * The strenth of the vortex.
  62851. */
  62852. strength: number;
  62853. /**
  62854. * The height of the cylinder for the vortex.
  62855. */
  62856. height: number;
  62857. /**
  62858. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62859. */
  62860. centripetalForceThreshold: number;
  62861. /**
  62862. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62863. */
  62864. centripetalForceMultiplier: number;
  62865. /**
  62866. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62867. */
  62868. centrifugalForceMultiplier: number;
  62869. /**
  62870. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62871. */
  62872. updraftForceMultiplier: number;
  62873. }
  62874. /**
  62875. * The strenght of the force in correspondence to the distance of the affected object
  62876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62877. */
  62878. export enum PhysicsRadialImpulseFalloff {
  62879. /** Defines that impulse is constant in strength across it's whole radius */
  62880. Constant = 0,
  62881. /** Defines that impulse gets weaker if it's further from the origin */
  62882. Linear = 1
  62883. }
  62884. /**
  62885. * The strength of the force in correspondence to the distance of the affected object
  62886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62887. */
  62888. export enum PhysicsUpdraftMode {
  62889. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62890. Center = 0,
  62891. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62892. Perpendicular = 1
  62893. }
  62894. /**
  62895. * Interface for a physics hit data
  62896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62897. */
  62898. export interface PhysicsHitData {
  62899. /**
  62900. * The force applied at the contact point
  62901. */
  62902. force: Vector3;
  62903. /**
  62904. * The contact point
  62905. */
  62906. contactPoint: Vector3;
  62907. /**
  62908. * The distance from the origin to the contact point
  62909. */
  62910. distanceFromOrigin: number;
  62911. }
  62912. /**
  62913. * Interface for radial explosion event data
  62914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62915. */
  62916. export interface PhysicsRadialExplosionEventData {
  62917. /**
  62918. * A sphere used for the radial explosion event
  62919. */
  62920. sphere: Mesh;
  62921. }
  62922. /**
  62923. * Interface for gravitational field event data
  62924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62925. */
  62926. export interface PhysicsGravitationalFieldEventData {
  62927. /**
  62928. * A sphere mesh used for the gravitational field event
  62929. */
  62930. sphere: Mesh;
  62931. }
  62932. /**
  62933. * Interface for updraft event data
  62934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62935. */
  62936. export interface PhysicsUpdraftEventData {
  62937. /**
  62938. * A cylinder used for the updraft event
  62939. */
  62940. cylinder: Mesh;
  62941. }
  62942. /**
  62943. * Interface for vortex event data
  62944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62945. */
  62946. export interface PhysicsVortexEventData {
  62947. /**
  62948. * A cylinder used for the vortex event
  62949. */
  62950. cylinder: Mesh;
  62951. }
  62952. /**
  62953. * Interface for an affected physics impostor
  62954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62955. */
  62956. export interface PhysicsAffectedImpostorWithData {
  62957. /**
  62958. * The impostor affected by the effect
  62959. */
  62960. impostor: PhysicsImpostor;
  62961. /**
  62962. * The data about the hit/horce from the explosion
  62963. */
  62964. hitData: PhysicsHitData;
  62965. }
  62966. }
  62967. declare module "babylonjs/Physics/Plugins/index" {
  62968. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62969. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62970. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62971. }
  62972. declare module "babylonjs/Physics/index" {
  62973. export * from "babylonjs/Physics/IPhysicsEngine";
  62974. export * from "babylonjs/Physics/physicsEngine";
  62975. export * from "babylonjs/Physics/physicsEngineComponent";
  62976. export * from "babylonjs/Physics/physicsHelper";
  62977. export * from "babylonjs/Physics/physicsImpostor";
  62978. export * from "babylonjs/Physics/physicsJoint";
  62979. export * from "babylonjs/Physics/Plugins/index";
  62980. }
  62981. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62982. /** @hidden */
  62983. export var blackAndWhitePixelShader: {
  62984. name: string;
  62985. shader: string;
  62986. };
  62987. }
  62988. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62989. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62990. import { Camera } from "babylonjs/Cameras/camera";
  62991. import { Engine } from "babylonjs/Engines/engine";
  62992. import "babylonjs/Shaders/blackAndWhite.fragment";
  62993. /**
  62994. * Post process used to render in black and white
  62995. */
  62996. export class BlackAndWhitePostProcess extends PostProcess {
  62997. /**
  62998. * Linear about to convert he result to black and white (default: 1)
  62999. */
  63000. degree: number;
  63001. /**
  63002. * Creates a black and white post process
  63003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63004. * @param name The name of the effect.
  63005. * @param options The required width/height ratio to downsize to before computing the render pass.
  63006. * @param camera The camera to apply the render pass to.
  63007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63008. * @param engine The engine which the post process will be applied. (default: current engine)
  63009. * @param reusable If the post process can be reused on the same frame. (default: false)
  63010. */
  63011. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63012. }
  63013. }
  63014. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63015. import { Nullable } from "babylonjs/types";
  63016. import { Camera } from "babylonjs/Cameras/camera";
  63017. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63018. import { Engine } from "babylonjs/Engines/engine";
  63019. /**
  63020. * This represents a set of one or more post processes in Babylon.
  63021. * A post process can be used to apply a shader to a texture after it is rendered.
  63022. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63023. */
  63024. export class PostProcessRenderEffect {
  63025. private _postProcesses;
  63026. private _getPostProcesses;
  63027. private _singleInstance;
  63028. private _cameras;
  63029. private _indicesForCamera;
  63030. /**
  63031. * Name of the effect
  63032. * @hidden
  63033. */
  63034. _name: string;
  63035. /**
  63036. * Instantiates a post process render effect.
  63037. * A post process can be used to apply a shader to a texture after it is rendered.
  63038. * @param engine The engine the effect is tied to
  63039. * @param name The name of the effect
  63040. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63041. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63042. */
  63043. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63044. /**
  63045. * Checks if all the post processes in the effect are supported.
  63046. */
  63047. readonly isSupported: boolean;
  63048. /**
  63049. * Updates the current state of the effect
  63050. * @hidden
  63051. */
  63052. _update(): void;
  63053. /**
  63054. * Attaches the effect on cameras
  63055. * @param cameras The camera to attach to.
  63056. * @hidden
  63057. */
  63058. _attachCameras(cameras: Camera): void;
  63059. /**
  63060. * Attaches the effect on cameras
  63061. * @param cameras The camera to attach to.
  63062. * @hidden
  63063. */
  63064. _attachCameras(cameras: Camera[]): void;
  63065. /**
  63066. * Detaches the effect on cameras
  63067. * @param cameras The camera to detatch from.
  63068. * @hidden
  63069. */
  63070. _detachCameras(cameras: Camera): void;
  63071. /**
  63072. * Detatches the effect on cameras
  63073. * @param cameras The camera to detatch from.
  63074. * @hidden
  63075. */
  63076. _detachCameras(cameras: Camera[]): void;
  63077. /**
  63078. * Enables the effect on given cameras
  63079. * @param cameras The camera to enable.
  63080. * @hidden
  63081. */
  63082. _enable(cameras: Camera): void;
  63083. /**
  63084. * Enables the effect on given cameras
  63085. * @param cameras The camera to enable.
  63086. * @hidden
  63087. */
  63088. _enable(cameras: Nullable<Camera[]>): void;
  63089. /**
  63090. * Disables the effect on the given cameras
  63091. * @param cameras The camera to disable.
  63092. * @hidden
  63093. */
  63094. _disable(cameras: Camera): void;
  63095. /**
  63096. * Disables the effect on the given cameras
  63097. * @param cameras The camera to disable.
  63098. * @hidden
  63099. */
  63100. _disable(cameras: Nullable<Camera[]>): void;
  63101. /**
  63102. * Gets a list of the post processes contained in the effect.
  63103. * @param camera The camera to get the post processes on.
  63104. * @returns The list of the post processes in the effect.
  63105. */
  63106. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63107. }
  63108. }
  63109. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63111. /** @hidden */
  63112. export var extractHighlightsPixelShader: {
  63113. name: string;
  63114. shader: string;
  63115. };
  63116. }
  63117. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63118. import { Nullable } from "babylonjs/types";
  63119. import { Camera } from "babylonjs/Cameras/camera";
  63120. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63121. import { Engine } from "babylonjs/Engines/engine";
  63122. import "babylonjs/Shaders/extractHighlights.fragment";
  63123. /**
  63124. * 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.
  63125. */
  63126. export class ExtractHighlightsPostProcess extends PostProcess {
  63127. /**
  63128. * The luminance threshold, pixels below this value will be set to black.
  63129. */
  63130. threshold: number;
  63131. /** @hidden */
  63132. _exposure: number;
  63133. /**
  63134. * Post process which has the input texture to be used when performing highlight extraction
  63135. * @hidden
  63136. */
  63137. _inputPostProcess: Nullable<PostProcess>;
  63138. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63139. }
  63140. }
  63141. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63142. /** @hidden */
  63143. export var bloomMergePixelShader: {
  63144. name: string;
  63145. shader: string;
  63146. };
  63147. }
  63148. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63150. import { Nullable } from "babylonjs/types";
  63151. import { Engine } from "babylonjs/Engines/engine";
  63152. import { Camera } from "babylonjs/Cameras/camera";
  63153. import "babylonjs/Shaders/bloomMerge.fragment";
  63154. /**
  63155. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63156. */
  63157. export class BloomMergePostProcess extends PostProcess {
  63158. /** Weight of the bloom to be added to the original input. */
  63159. weight: number;
  63160. /**
  63161. * Creates a new instance of @see BloomMergePostProcess
  63162. * @param name The name of the effect.
  63163. * @param originalFromInput Post process which's input will be used for the merge.
  63164. * @param blurred Blurred highlights post process which's output will be used.
  63165. * @param weight Weight of the bloom to be added to the original input.
  63166. * @param options The required width/height ratio to downsize to before computing the render pass.
  63167. * @param camera The camera to apply the render pass to.
  63168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63169. * @param engine The engine which the post process will be applied. (default: current engine)
  63170. * @param reusable If the post process can be reused on the same frame. (default: false)
  63171. * @param textureType Type of textures used when performing the post process. (default: 0)
  63172. * @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)
  63173. */
  63174. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63175. /** Weight of the bloom to be added to the original input. */
  63176. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63177. }
  63178. }
  63179. declare module "babylonjs/PostProcesses/bloomEffect" {
  63180. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63182. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63183. import { Camera } from "babylonjs/Cameras/camera";
  63184. import { Scene } from "babylonjs/scene";
  63185. /**
  63186. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63187. */
  63188. export class BloomEffect extends PostProcessRenderEffect {
  63189. private bloomScale;
  63190. /**
  63191. * @hidden Internal
  63192. */
  63193. _effects: Array<PostProcess>;
  63194. /**
  63195. * @hidden Internal
  63196. */
  63197. _downscale: ExtractHighlightsPostProcess;
  63198. private _blurX;
  63199. private _blurY;
  63200. private _merge;
  63201. /**
  63202. * The luminance threshold to find bright areas of the image to bloom.
  63203. */
  63204. threshold: number;
  63205. /**
  63206. * The strength of the bloom.
  63207. */
  63208. weight: number;
  63209. /**
  63210. * Specifies the size of the bloom blur kernel, relative to the final output size
  63211. */
  63212. kernel: number;
  63213. /**
  63214. * Creates a new instance of @see BloomEffect
  63215. * @param scene The scene the effect belongs to.
  63216. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63217. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63218. * @param bloomWeight The the strength of bloom.
  63219. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63220. * @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)
  63221. */
  63222. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63223. /**
  63224. * Disposes each of the internal effects for a given camera.
  63225. * @param camera The camera to dispose the effect on.
  63226. */
  63227. disposeEffects(camera: Camera): void;
  63228. /**
  63229. * @hidden Internal
  63230. */
  63231. _updateEffects(): void;
  63232. /**
  63233. * Internal
  63234. * @returns if all the contained post processes are ready.
  63235. * @hidden
  63236. */
  63237. _isReady(): boolean;
  63238. }
  63239. }
  63240. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63241. /** @hidden */
  63242. export var chromaticAberrationPixelShader: {
  63243. name: string;
  63244. shader: string;
  63245. };
  63246. }
  63247. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63248. import { Vector2 } from "babylonjs/Maths/math.vector";
  63249. import { Nullable } from "babylonjs/types";
  63250. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63251. import { Camera } from "babylonjs/Cameras/camera";
  63252. import { Engine } from "babylonjs/Engines/engine";
  63253. import "babylonjs/Shaders/chromaticAberration.fragment";
  63254. /**
  63255. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63256. */
  63257. export class ChromaticAberrationPostProcess extends PostProcess {
  63258. /**
  63259. * The amount of seperation of rgb channels (default: 30)
  63260. */
  63261. aberrationAmount: number;
  63262. /**
  63263. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63264. */
  63265. radialIntensity: number;
  63266. /**
  63267. * 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))
  63268. */
  63269. direction: Vector2;
  63270. /**
  63271. * 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))
  63272. */
  63273. centerPosition: Vector2;
  63274. /**
  63275. * Creates a new instance ChromaticAberrationPostProcess
  63276. * @param name The name of the effect.
  63277. * @param screenWidth The width of the screen to apply the effect on.
  63278. * @param screenHeight The height of the screen to apply the effect on.
  63279. * @param options The required width/height ratio to downsize to before computing the render pass.
  63280. * @param camera The camera to apply the render pass to.
  63281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63282. * @param engine The engine which the post process will be applied. (default: current engine)
  63283. * @param reusable If the post process can be reused on the same frame. (default: false)
  63284. * @param textureType Type of textures used when performing the post process. (default: 0)
  63285. * @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)
  63286. */
  63287. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63288. }
  63289. }
  63290. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63291. /** @hidden */
  63292. export var circleOfConfusionPixelShader: {
  63293. name: string;
  63294. shader: string;
  63295. };
  63296. }
  63297. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63298. import { Nullable } from "babylonjs/types";
  63299. import { Engine } from "babylonjs/Engines/engine";
  63300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63302. import { Camera } from "babylonjs/Cameras/camera";
  63303. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63304. /**
  63305. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63306. */
  63307. export class CircleOfConfusionPostProcess extends PostProcess {
  63308. /**
  63309. * 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.
  63310. */
  63311. lensSize: number;
  63312. /**
  63313. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63314. */
  63315. fStop: number;
  63316. /**
  63317. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63318. */
  63319. focusDistance: number;
  63320. /**
  63321. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63322. */
  63323. focalLength: number;
  63324. private _depthTexture;
  63325. /**
  63326. * Creates a new instance CircleOfConfusionPostProcess
  63327. * @param name The name of the effect.
  63328. * @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.
  63329. * @param options The required width/height ratio to downsize to before computing the render pass.
  63330. * @param camera The camera to apply the render pass to.
  63331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63332. * @param engine The engine which the post process will be applied. (default: current engine)
  63333. * @param reusable If the post process can be reused on the same frame. (default: false)
  63334. * @param textureType Type of textures used when performing the post process. (default: 0)
  63335. * @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)
  63336. */
  63337. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63338. /**
  63339. * 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.
  63340. */
  63341. depthTexture: RenderTargetTexture;
  63342. }
  63343. }
  63344. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63345. /** @hidden */
  63346. export var colorCorrectionPixelShader: {
  63347. name: string;
  63348. shader: string;
  63349. };
  63350. }
  63351. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63353. import { Engine } from "babylonjs/Engines/engine";
  63354. import { Camera } from "babylonjs/Cameras/camera";
  63355. import "babylonjs/Shaders/colorCorrection.fragment";
  63356. /**
  63357. *
  63358. * This post-process allows the modification of rendered colors by using
  63359. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63360. *
  63361. * The object needs to be provided an url to a texture containing the color
  63362. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63363. * Use an image editing software to tweak the LUT to match your needs.
  63364. *
  63365. * For an example of a color LUT, see here:
  63366. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63367. * For explanations on color grading, see here:
  63368. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63369. *
  63370. */
  63371. export class ColorCorrectionPostProcess extends PostProcess {
  63372. private _colorTableTexture;
  63373. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63374. }
  63375. }
  63376. declare module "babylonjs/Shaders/convolution.fragment" {
  63377. /** @hidden */
  63378. export var convolutionPixelShader: {
  63379. name: string;
  63380. shader: string;
  63381. };
  63382. }
  63383. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63385. import { Nullable } from "babylonjs/types";
  63386. import { Camera } from "babylonjs/Cameras/camera";
  63387. import { Engine } from "babylonjs/Engines/engine";
  63388. import "babylonjs/Shaders/convolution.fragment";
  63389. /**
  63390. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63391. * input texture to perform effects such as edge detection or sharpening
  63392. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63393. */
  63394. export class ConvolutionPostProcess extends PostProcess {
  63395. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63396. kernel: number[];
  63397. /**
  63398. * Creates a new instance ConvolutionPostProcess
  63399. * @param name The name of the effect.
  63400. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63401. * @param options The required width/height ratio to downsize to before computing the render pass.
  63402. * @param camera The camera to apply the render pass to.
  63403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63404. * @param engine The engine which the post process will be applied. (default: current engine)
  63405. * @param reusable If the post process can be reused on the same frame. (default: false)
  63406. * @param textureType Type of textures used when performing the post process. (default: 0)
  63407. */
  63408. constructor(name: string,
  63409. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63410. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63411. /**
  63412. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63413. */
  63414. static EdgeDetect0Kernel: number[];
  63415. /**
  63416. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63417. */
  63418. static EdgeDetect1Kernel: number[];
  63419. /**
  63420. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63421. */
  63422. static EdgeDetect2Kernel: number[];
  63423. /**
  63424. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63425. */
  63426. static SharpenKernel: number[];
  63427. /**
  63428. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63429. */
  63430. static EmbossKernel: number[];
  63431. /**
  63432. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63433. */
  63434. static GaussianKernel: number[];
  63435. }
  63436. }
  63437. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63438. import { Nullable } from "babylonjs/types";
  63439. import { Vector2 } from "babylonjs/Maths/math.vector";
  63440. import { Camera } from "babylonjs/Cameras/camera";
  63441. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63442. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63443. import { Engine } from "babylonjs/Engines/engine";
  63444. import { Scene } from "babylonjs/scene";
  63445. /**
  63446. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63447. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63448. * based on samples that have a large difference in distance than the center pixel.
  63449. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63450. */
  63451. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63452. direction: Vector2;
  63453. /**
  63454. * Creates a new instance CircleOfConfusionPostProcess
  63455. * @param name The name of the effect.
  63456. * @param scene The scene the effect belongs to.
  63457. * @param direction The direction the blur should be applied.
  63458. * @param kernel The size of the kernel used to blur.
  63459. * @param options The required width/height ratio to downsize to before computing the render pass.
  63460. * @param camera The camera to apply the render pass to.
  63461. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63462. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63464. * @param engine The engine which the post process will be applied. (default: current engine)
  63465. * @param reusable If the post process can be reused on the same frame. (default: false)
  63466. * @param textureType Type of textures used when performing the post process. (default: 0)
  63467. * @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)
  63468. */
  63469. 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);
  63470. }
  63471. }
  63472. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63473. /** @hidden */
  63474. export var depthOfFieldMergePixelShader: {
  63475. name: string;
  63476. shader: string;
  63477. };
  63478. }
  63479. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63480. import { Nullable } from "babylonjs/types";
  63481. import { Camera } from "babylonjs/Cameras/camera";
  63482. import { Effect } from "babylonjs/Materials/effect";
  63483. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63484. import { Engine } from "babylonjs/Engines/engine";
  63485. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63486. /**
  63487. * Options to be set when merging outputs from the default pipeline.
  63488. */
  63489. export class DepthOfFieldMergePostProcessOptions {
  63490. /**
  63491. * The original image to merge on top of
  63492. */
  63493. originalFromInput: PostProcess;
  63494. /**
  63495. * Parameters to perform the merge of the depth of field effect
  63496. */
  63497. depthOfField?: {
  63498. circleOfConfusion: PostProcess;
  63499. blurSteps: Array<PostProcess>;
  63500. };
  63501. /**
  63502. * Parameters to perform the merge of bloom effect
  63503. */
  63504. bloom?: {
  63505. blurred: PostProcess;
  63506. weight: number;
  63507. };
  63508. }
  63509. /**
  63510. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63511. */
  63512. export class DepthOfFieldMergePostProcess extends PostProcess {
  63513. private blurSteps;
  63514. /**
  63515. * Creates a new instance of DepthOfFieldMergePostProcess
  63516. * @param name The name of the effect.
  63517. * @param originalFromInput Post process which's input will be used for the merge.
  63518. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63519. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63520. * @param options The required width/height ratio to downsize to before computing the render pass.
  63521. * @param camera The camera to apply the render pass to.
  63522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63523. * @param engine The engine which the post process will be applied. (default: current engine)
  63524. * @param reusable If the post process can be reused on the same frame. (default: false)
  63525. * @param textureType Type of textures used when performing the post process. (default: 0)
  63526. * @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)
  63527. */
  63528. 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);
  63529. /**
  63530. * Updates the effect with the current post process compile time values and recompiles the shader.
  63531. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63532. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63533. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63534. * @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
  63535. * @param onCompiled Called when the shader has been compiled.
  63536. * @param onError Called if there is an error when compiling a shader.
  63537. */
  63538. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63539. }
  63540. }
  63541. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63542. import { Nullable } from "babylonjs/types";
  63543. import { Camera } from "babylonjs/Cameras/camera";
  63544. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63545. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63546. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63547. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63548. import { Scene } from "babylonjs/scene";
  63549. /**
  63550. * Specifies the level of max blur that should be applied when using the depth of field effect
  63551. */
  63552. export enum DepthOfFieldEffectBlurLevel {
  63553. /**
  63554. * Subtle blur
  63555. */
  63556. Low = 0,
  63557. /**
  63558. * Medium blur
  63559. */
  63560. Medium = 1,
  63561. /**
  63562. * Large blur
  63563. */
  63564. High = 2
  63565. }
  63566. /**
  63567. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63568. */
  63569. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63570. private _circleOfConfusion;
  63571. /**
  63572. * @hidden Internal, blurs from high to low
  63573. */
  63574. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63575. private _depthOfFieldBlurY;
  63576. private _dofMerge;
  63577. /**
  63578. * @hidden Internal post processes in depth of field effect
  63579. */
  63580. _effects: Array<PostProcess>;
  63581. /**
  63582. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63583. */
  63584. focalLength: number;
  63585. /**
  63586. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63587. */
  63588. fStop: number;
  63589. /**
  63590. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63591. */
  63592. focusDistance: number;
  63593. /**
  63594. * 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.
  63595. */
  63596. lensSize: number;
  63597. /**
  63598. * Creates a new instance DepthOfFieldEffect
  63599. * @param scene The scene the effect belongs to.
  63600. * @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.
  63601. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63602. * @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)
  63603. */
  63604. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63605. /**
  63606. * Get the current class name of the current effet
  63607. * @returns "DepthOfFieldEffect"
  63608. */
  63609. getClassName(): string;
  63610. /**
  63611. * 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.
  63612. */
  63613. depthTexture: RenderTargetTexture;
  63614. /**
  63615. * Disposes each of the internal effects for a given camera.
  63616. * @param camera The camera to dispose the effect on.
  63617. */
  63618. disposeEffects(camera: Camera): void;
  63619. /**
  63620. * @hidden Internal
  63621. */
  63622. _updateEffects(): void;
  63623. /**
  63624. * Internal
  63625. * @returns if all the contained post processes are ready.
  63626. * @hidden
  63627. */
  63628. _isReady(): boolean;
  63629. }
  63630. }
  63631. declare module "babylonjs/Shaders/displayPass.fragment" {
  63632. /** @hidden */
  63633. export var displayPassPixelShader: {
  63634. name: string;
  63635. shader: string;
  63636. };
  63637. }
  63638. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63639. import { Nullable } from "babylonjs/types";
  63640. import { Camera } from "babylonjs/Cameras/camera";
  63641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63642. import { Engine } from "babylonjs/Engines/engine";
  63643. import "babylonjs/Shaders/displayPass.fragment";
  63644. /**
  63645. * DisplayPassPostProcess which produces an output the same as it's input
  63646. */
  63647. export class DisplayPassPostProcess extends PostProcess {
  63648. /**
  63649. * Creates the DisplayPassPostProcess
  63650. * @param name The name of the effect.
  63651. * @param options The required width/height ratio to downsize to before computing the render pass.
  63652. * @param camera The camera to apply the render pass to.
  63653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63654. * @param engine The engine which the post process will be applied. (default: current engine)
  63655. * @param reusable If the post process can be reused on the same frame. (default: false)
  63656. */
  63657. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63658. }
  63659. }
  63660. declare module "babylonjs/Shaders/filter.fragment" {
  63661. /** @hidden */
  63662. export var filterPixelShader: {
  63663. name: string;
  63664. shader: string;
  63665. };
  63666. }
  63667. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63668. import { Nullable } from "babylonjs/types";
  63669. import { Matrix } from "babylonjs/Maths/math.vector";
  63670. import { Camera } from "babylonjs/Cameras/camera";
  63671. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63672. import { Engine } from "babylonjs/Engines/engine";
  63673. import "babylonjs/Shaders/filter.fragment";
  63674. /**
  63675. * Applies a kernel filter to the image
  63676. */
  63677. export class FilterPostProcess extends PostProcess {
  63678. /** The matrix to be applied to the image */
  63679. kernelMatrix: Matrix;
  63680. /**
  63681. *
  63682. * @param name The name of the effect.
  63683. * @param kernelMatrix The matrix to be applied to the image
  63684. * @param options The required width/height ratio to downsize to before computing the render pass.
  63685. * @param camera The camera to apply the render pass to.
  63686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63687. * @param engine The engine which the post process will be applied. (default: current engine)
  63688. * @param reusable If the post process can be reused on the same frame. (default: false)
  63689. */
  63690. constructor(name: string,
  63691. /** The matrix to be applied to the image */
  63692. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63693. }
  63694. }
  63695. declare module "babylonjs/Shaders/fxaa.fragment" {
  63696. /** @hidden */
  63697. export var fxaaPixelShader: {
  63698. name: string;
  63699. shader: string;
  63700. };
  63701. }
  63702. declare module "babylonjs/Shaders/fxaa.vertex" {
  63703. /** @hidden */
  63704. export var fxaaVertexShader: {
  63705. name: string;
  63706. shader: string;
  63707. };
  63708. }
  63709. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63710. import { Nullable } from "babylonjs/types";
  63711. import { Camera } from "babylonjs/Cameras/camera";
  63712. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63713. import { Engine } from "babylonjs/Engines/engine";
  63714. import "babylonjs/Shaders/fxaa.fragment";
  63715. import "babylonjs/Shaders/fxaa.vertex";
  63716. /**
  63717. * Fxaa post process
  63718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63719. */
  63720. export class FxaaPostProcess extends PostProcess {
  63721. /** @hidden */
  63722. texelWidth: number;
  63723. /** @hidden */
  63724. texelHeight: number;
  63725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63726. private _getDefines;
  63727. }
  63728. }
  63729. declare module "babylonjs/Shaders/grain.fragment" {
  63730. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63731. /** @hidden */
  63732. export var grainPixelShader: {
  63733. name: string;
  63734. shader: string;
  63735. };
  63736. }
  63737. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63738. import { Nullable } from "babylonjs/types";
  63739. import { Camera } from "babylonjs/Cameras/camera";
  63740. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63741. import { Engine } from "babylonjs/Engines/engine";
  63742. import "babylonjs/Shaders/grain.fragment";
  63743. /**
  63744. * The GrainPostProcess adds noise to the image at mid luminance levels
  63745. */
  63746. export class GrainPostProcess extends PostProcess {
  63747. /**
  63748. * The intensity of the grain added (default: 30)
  63749. */
  63750. intensity: number;
  63751. /**
  63752. * If the grain should be randomized on every frame
  63753. */
  63754. animated: boolean;
  63755. /**
  63756. * Creates a new instance of @see GrainPostProcess
  63757. * @param name The name of the effect.
  63758. * @param options The required width/height ratio to downsize to before computing the render pass.
  63759. * @param camera The camera to apply the render pass to.
  63760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63761. * @param engine The engine which the post process will be applied. (default: current engine)
  63762. * @param reusable If the post process can be reused on the same frame. (default: false)
  63763. * @param textureType Type of textures used when performing the post process. (default: 0)
  63764. * @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)
  63765. */
  63766. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63767. }
  63768. }
  63769. declare module "babylonjs/Shaders/highlights.fragment" {
  63770. /** @hidden */
  63771. export var highlightsPixelShader: {
  63772. name: string;
  63773. shader: string;
  63774. };
  63775. }
  63776. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63777. import { Nullable } from "babylonjs/types";
  63778. import { Camera } from "babylonjs/Cameras/camera";
  63779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63780. import { Engine } from "babylonjs/Engines/engine";
  63781. import "babylonjs/Shaders/highlights.fragment";
  63782. /**
  63783. * Extracts highlights from the image
  63784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63785. */
  63786. export class HighlightsPostProcess extends PostProcess {
  63787. /**
  63788. * Extracts highlights from the image
  63789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63790. * @param name The name of the effect.
  63791. * @param options The required width/height ratio to downsize to before computing the render pass.
  63792. * @param camera The camera to apply the render pass to.
  63793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63794. * @param engine The engine which the post process will be applied. (default: current engine)
  63795. * @param reusable If the post process can be reused on the same frame. (default: false)
  63796. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63797. */
  63798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63799. }
  63800. }
  63801. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63802. /** @hidden */
  63803. export var mrtFragmentDeclaration: {
  63804. name: string;
  63805. shader: string;
  63806. };
  63807. }
  63808. declare module "babylonjs/Shaders/geometry.fragment" {
  63809. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63810. /** @hidden */
  63811. export var geometryPixelShader: {
  63812. name: string;
  63813. shader: string;
  63814. };
  63815. }
  63816. declare module "babylonjs/Shaders/geometry.vertex" {
  63817. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63818. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63820. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63822. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63823. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63824. /** @hidden */
  63825. export var geometryVertexShader: {
  63826. name: string;
  63827. shader: string;
  63828. };
  63829. }
  63830. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63831. import { Matrix } from "babylonjs/Maths/math.vector";
  63832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63833. import { Mesh } from "babylonjs/Meshes/mesh";
  63834. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63835. import { Effect } from "babylonjs/Materials/effect";
  63836. import { Scene } from "babylonjs/scene";
  63837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63838. import "babylonjs/Shaders/geometry.fragment";
  63839. import "babylonjs/Shaders/geometry.vertex";
  63840. /** @hidden */
  63841. interface ISavedTransformationMatrix {
  63842. world: Matrix;
  63843. viewProjection: Matrix;
  63844. }
  63845. /**
  63846. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63847. */
  63848. export class GeometryBufferRenderer {
  63849. /**
  63850. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63851. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63852. */
  63853. static readonly POSITION_TEXTURE_TYPE: number;
  63854. /**
  63855. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63856. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63857. */
  63858. static readonly VELOCITY_TEXTURE_TYPE: number;
  63859. /**
  63860. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63861. * in order to compute objects velocities when enableVelocity is set to "true"
  63862. * @hidden
  63863. */
  63864. _previousTransformationMatrices: {
  63865. [index: number]: ISavedTransformationMatrix;
  63866. };
  63867. /**
  63868. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63869. * in order to compute objects velocities when enableVelocity is set to "true"
  63870. * @hidden
  63871. */
  63872. _previousBonesTransformationMatrices: {
  63873. [index: number]: Float32Array;
  63874. };
  63875. /**
  63876. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63877. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63878. */
  63879. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63880. private _scene;
  63881. private _multiRenderTarget;
  63882. private _ratio;
  63883. private _enablePosition;
  63884. private _enableVelocity;
  63885. private _positionIndex;
  63886. private _velocityIndex;
  63887. protected _effect: Effect;
  63888. protected _cachedDefines: string;
  63889. /**
  63890. * Set the render list (meshes to be rendered) used in the G buffer.
  63891. */
  63892. renderList: Mesh[];
  63893. /**
  63894. * Gets wether or not G buffer are supported by the running hardware.
  63895. * This requires draw buffer supports
  63896. */
  63897. readonly isSupported: boolean;
  63898. /**
  63899. * Returns the index of the given texture type in the G-Buffer textures array
  63900. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63901. * @returns the index of the given texture type in the G-Buffer textures array
  63902. */
  63903. getTextureIndex(textureType: number): number;
  63904. /**
  63905. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63906. */
  63907. /**
  63908. * Sets whether or not objects positions are enabled for the G buffer.
  63909. */
  63910. enablePosition: boolean;
  63911. /**
  63912. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63913. */
  63914. /**
  63915. * Sets wether or not objects velocities are enabled for the G buffer.
  63916. */
  63917. enableVelocity: boolean;
  63918. /**
  63919. * Gets the scene associated with the buffer.
  63920. */
  63921. readonly scene: Scene;
  63922. /**
  63923. * Gets the ratio used by the buffer during its creation.
  63924. * How big is the buffer related to the main canvas.
  63925. */
  63926. readonly ratio: number;
  63927. /** @hidden */
  63928. static _SceneComponentInitialization: (scene: Scene) => void;
  63929. /**
  63930. * Creates a new G Buffer for the scene
  63931. * @param scene The scene the buffer belongs to
  63932. * @param ratio How big is the buffer related to the main canvas.
  63933. */
  63934. constructor(scene: Scene, ratio?: number);
  63935. /**
  63936. * Checks wether everything is ready to render a submesh to the G buffer.
  63937. * @param subMesh the submesh to check readiness for
  63938. * @param useInstances is the mesh drawn using instance or not
  63939. * @returns true if ready otherwise false
  63940. */
  63941. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63942. /**
  63943. * Gets the current underlying G Buffer.
  63944. * @returns the buffer
  63945. */
  63946. getGBuffer(): MultiRenderTarget;
  63947. /**
  63948. * Gets the number of samples used to render the buffer (anti aliasing).
  63949. */
  63950. /**
  63951. * Sets the number of samples used to render the buffer (anti aliasing).
  63952. */
  63953. samples: number;
  63954. /**
  63955. * Disposes the renderer and frees up associated resources.
  63956. */
  63957. dispose(): void;
  63958. protected _createRenderTargets(): void;
  63959. private _copyBonesTransformationMatrices;
  63960. }
  63961. }
  63962. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63963. import { Nullable } from "babylonjs/types";
  63964. import { Scene } from "babylonjs/scene";
  63965. import { ISceneComponent } from "babylonjs/sceneComponent";
  63966. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63967. module "babylonjs/scene" {
  63968. interface Scene {
  63969. /** @hidden (Backing field) */
  63970. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63971. /**
  63972. * Gets or Sets the current geometry buffer associated to the scene.
  63973. */
  63974. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63975. /**
  63976. * Enables a GeometryBufferRender and associates it with the scene
  63977. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63978. * @returns the GeometryBufferRenderer
  63979. */
  63980. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63981. /**
  63982. * Disables the GeometryBufferRender associated with the scene
  63983. */
  63984. disableGeometryBufferRenderer(): void;
  63985. }
  63986. }
  63987. /**
  63988. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63989. * in several rendering techniques.
  63990. */
  63991. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63992. /**
  63993. * The component name helpful to identify the component in the list of scene components.
  63994. */
  63995. readonly name: string;
  63996. /**
  63997. * The scene the component belongs to.
  63998. */
  63999. scene: Scene;
  64000. /**
  64001. * Creates a new instance of the component for the given scene
  64002. * @param scene Defines the scene to register the component in
  64003. */
  64004. constructor(scene: Scene);
  64005. /**
  64006. * Registers the component in a given scene
  64007. */
  64008. register(): void;
  64009. /**
  64010. * Rebuilds the elements related to this component in case of
  64011. * context lost for instance.
  64012. */
  64013. rebuild(): void;
  64014. /**
  64015. * Disposes the component and the associated ressources
  64016. */
  64017. dispose(): void;
  64018. private _gatherRenderTargets;
  64019. }
  64020. }
  64021. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64022. /** @hidden */
  64023. export var motionBlurPixelShader: {
  64024. name: string;
  64025. shader: string;
  64026. };
  64027. }
  64028. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64029. import { Nullable } from "babylonjs/types";
  64030. import { Camera } from "babylonjs/Cameras/camera";
  64031. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64032. import { Scene } from "babylonjs/scene";
  64033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64034. import "babylonjs/Animations/animatable";
  64035. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64036. import "babylonjs/Shaders/motionBlur.fragment";
  64037. import { Engine } from "babylonjs/Engines/engine";
  64038. /**
  64039. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64040. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64041. * As an example, all you have to do is to create the post-process:
  64042. * var mb = new BABYLON.MotionBlurPostProcess(
  64043. * 'mb', // The name of the effect.
  64044. * scene, // The scene containing the objects to blur according to their velocity.
  64045. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64046. * camera // The camera to apply the render pass to.
  64047. * );
  64048. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64049. */
  64050. export class MotionBlurPostProcess extends PostProcess {
  64051. /**
  64052. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64053. */
  64054. motionStrength: number;
  64055. /**
  64056. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64057. */
  64058. /**
  64059. * Sets the number of iterations to be used for motion blur quality
  64060. */
  64061. motionBlurSamples: number;
  64062. private _motionBlurSamples;
  64063. private _geometryBufferRenderer;
  64064. /**
  64065. * Creates a new instance MotionBlurPostProcess
  64066. * @param name The name of the effect.
  64067. * @param scene The scene containing the objects to blur according to their velocity.
  64068. * @param options The required width/height ratio to downsize to before computing the render pass.
  64069. * @param camera The camera to apply the render pass to.
  64070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64071. * @param engine The engine which the post process will be applied. (default: current engine)
  64072. * @param reusable If the post process can be reused on the same frame. (default: false)
  64073. * @param textureType Type of textures used when performing the post process. (default: 0)
  64074. * @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)
  64075. */
  64076. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64077. /**
  64078. * Excludes the given skinned mesh from computing bones velocities.
  64079. * 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.
  64080. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64081. */
  64082. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64083. /**
  64084. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64085. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64086. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64087. */
  64088. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64089. /**
  64090. * Disposes the post process.
  64091. * @param camera The camera to dispose the post process on.
  64092. */
  64093. dispose(camera?: Camera): void;
  64094. }
  64095. }
  64096. declare module "babylonjs/Shaders/refraction.fragment" {
  64097. /** @hidden */
  64098. export var refractionPixelShader: {
  64099. name: string;
  64100. shader: string;
  64101. };
  64102. }
  64103. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64104. import { Color3 } from "babylonjs/Maths/math.color";
  64105. import { Camera } from "babylonjs/Cameras/camera";
  64106. import { Texture } from "babylonjs/Materials/Textures/texture";
  64107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64108. import { Engine } from "babylonjs/Engines/engine";
  64109. import "babylonjs/Shaders/refraction.fragment";
  64110. /**
  64111. * Post process which applies a refractin texture
  64112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64113. */
  64114. export class RefractionPostProcess extends PostProcess {
  64115. /** the base color of the refraction (used to taint the rendering) */
  64116. color: Color3;
  64117. /** simulated refraction depth */
  64118. depth: number;
  64119. /** the coefficient of the base color (0 to remove base color tainting) */
  64120. colorLevel: number;
  64121. private _refTexture;
  64122. private _ownRefractionTexture;
  64123. /**
  64124. * Gets or sets the refraction texture
  64125. * Please note that you are responsible for disposing the texture if you set it manually
  64126. */
  64127. refractionTexture: Texture;
  64128. /**
  64129. * Initializes the RefractionPostProcess
  64130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64131. * @param name The name of the effect.
  64132. * @param refractionTextureUrl Url of the refraction texture to use
  64133. * @param color the base color of the refraction (used to taint the rendering)
  64134. * @param depth simulated refraction depth
  64135. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64136. * @param camera The camera to apply the render pass to.
  64137. * @param options The required width/height ratio to downsize to before computing the render pass.
  64138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64139. * @param engine The engine which the post process will be applied. (default: current engine)
  64140. * @param reusable If the post process can be reused on the same frame. (default: false)
  64141. */
  64142. constructor(name: string, refractionTextureUrl: string,
  64143. /** the base color of the refraction (used to taint the rendering) */
  64144. color: Color3,
  64145. /** simulated refraction depth */
  64146. depth: number,
  64147. /** the coefficient of the base color (0 to remove base color tainting) */
  64148. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64149. /**
  64150. * Disposes of the post process
  64151. * @param camera Camera to dispose post process on
  64152. */
  64153. dispose(camera: Camera): void;
  64154. }
  64155. }
  64156. declare module "babylonjs/Shaders/sharpen.fragment" {
  64157. /** @hidden */
  64158. export var sharpenPixelShader: {
  64159. name: string;
  64160. shader: string;
  64161. };
  64162. }
  64163. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64164. import { Nullable } from "babylonjs/types";
  64165. import { Camera } from "babylonjs/Cameras/camera";
  64166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64167. import "babylonjs/Shaders/sharpen.fragment";
  64168. import { Engine } from "babylonjs/Engines/engine";
  64169. /**
  64170. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64171. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64172. */
  64173. export class SharpenPostProcess extends PostProcess {
  64174. /**
  64175. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64176. */
  64177. colorAmount: number;
  64178. /**
  64179. * How much sharpness should be applied (default: 0.3)
  64180. */
  64181. edgeAmount: number;
  64182. /**
  64183. * Creates a new instance ConvolutionPostProcess
  64184. * @param name The name of the effect.
  64185. * @param options The required width/height ratio to downsize to before computing the render pass.
  64186. * @param camera The camera to apply the render pass to.
  64187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64188. * @param engine The engine which the post process will be applied. (default: current engine)
  64189. * @param reusable If the post process can be reused on the same frame. (default: false)
  64190. * @param textureType Type of textures used when performing the post process. (default: 0)
  64191. * @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)
  64192. */
  64193. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64194. }
  64195. }
  64196. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64197. import { Nullable } from "babylonjs/types";
  64198. import { Camera } from "babylonjs/Cameras/camera";
  64199. import { Engine } from "babylonjs/Engines/engine";
  64200. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64201. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64202. /**
  64203. * PostProcessRenderPipeline
  64204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64205. */
  64206. export class PostProcessRenderPipeline {
  64207. private engine;
  64208. private _renderEffects;
  64209. private _renderEffectsForIsolatedPass;
  64210. /**
  64211. * List of inspectable custom properties (used by the Inspector)
  64212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64213. */
  64214. inspectableCustomProperties: IInspectable[];
  64215. /**
  64216. * @hidden
  64217. */
  64218. protected _cameras: Camera[];
  64219. /** @hidden */
  64220. _name: string;
  64221. /**
  64222. * Gets pipeline name
  64223. */
  64224. readonly name: string;
  64225. /** Gets the list of attached cameras */
  64226. readonly cameras: Camera[];
  64227. /**
  64228. * Initializes a PostProcessRenderPipeline
  64229. * @param engine engine to add the pipeline to
  64230. * @param name name of the pipeline
  64231. */
  64232. constructor(engine: Engine, name: string);
  64233. /**
  64234. * Gets the class name
  64235. * @returns "PostProcessRenderPipeline"
  64236. */
  64237. getClassName(): string;
  64238. /**
  64239. * If all the render effects in the pipeline are supported
  64240. */
  64241. readonly isSupported: boolean;
  64242. /**
  64243. * Adds an effect to the pipeline
  64244. * @param renderEffect the effect to add
  64245. */
  64246. addEffect(renderEffect: PostProcessRenderEffect): void;
  64247. /** @hidden */
  64248. _rebuild(): void;
  64249. /** @hidden */
  64250. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64251. /** @hidden */
  64252. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64253. /** @hidden */
  64254. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64255. /** @hidden */
  64256. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64257. /** @hidden */
  64258. _attachCameras(cameras: Camera, unique: boolean): void;
  64259. /** @hidden */
  64260. _attachCameras(cameras: Camera[], unique: boolean): void;
  64261. /** @hidden */
  64262. _detachCameras(cameras: Camera): void;
  64263. /** @hidden */
  64264. _detachCameras(cameras: Nullable<Camera[]>): void;
  64265. /** @hidden */
  64266. _update(): void;
  64267. /** @hidden */
  64268. _reset(): void;
  64269. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64270. /**
  64271. * Disposes of the pipeline
  64272. */
  64273. dispose(): void;
  64274. }
  64275. }
  64276. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64277. import { Camera } from "babylonjs/Cameras/camera";
  64278. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64279. /**
  64280. * PostProcessRenderPipelineManager class
  64281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64282. */
  64283. export class PostProcessRenderPipelineManager {
  64284. private _renderPipelines;
  64285. /**
  64286. * Initializes a PostProcessRenderPipelineManager
  64287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64288. */
  64289. constructor();
  64290. /**
  64291. * Gets the list of supported render pipelines
  64292. */
  64293. readonly supportedPipelines: PostProcessRenderPipeline[];
  64294. /**
  64295. * Adds a pipeline to the manager
  64296. * @param renderPipeline The pipeline to add
  64297. */
  64298. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64299. /**
  64300. * Attaches a camera to the pipeline
  64301. * @param renderPipelineName The name of the pipeline to attach to
  64302. * @param cameras the camera to attach
  64303. * @param unique if the camera can be attached multiple times to the pipeline
  64304. */
  64305. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64306. /**
  64307. * Detaches a camera from the pipeline
  64308. * @param renderPipelineName The name of the pipeline to detach from
  64309. * @param cameras the camera to detach
  64310. */
  64311. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64312. /**
  64313. * Enables an effect by name on a pipeline
  64314. * @param renderPipelineName the name of the pipeline to enable the effect in
  64315. * @param renderEffectName the name of the effect to enable
  64316. * @param cameras the cameras that the effect should be enabled on
  64317. */
  64318. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64319. /**
  64320. * Disables an effect by name on a pipeline
  64321. * @param renderPipelineName the name of the pipeline to disable the effect in
  64322. * @param renderEffectName the name of the effect to disable
  64323. * @param cameras the cameras that the effect should be disabled on
  64324. */
  64325. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64326. /**
  64327. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64328. */
  64329. update(): void;
  64330. /** @hidden */
  64331. _rebuild(): void;
  64332. /**
  64333. * Disposes of the manager and pipelines
  64334. */
  64335. dispose(): void;
  64336. }
  64337. }
  64338. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64339. import { ISceneComponent } from "babylonjs/sceneComponent";
  64340. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64341. import { Scene } from "babylonjs/scene";
  64342. module "babylonjs/scene" {
  64343. interface Scene {
  64344. /** @hidden (Backing field) */
  64345. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64346. /**
  64347. * Gets the postprocess render pipeline manager
  64348. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64349. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64350. */
  64351. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64352. }
  64353. }
  64354. /**
  64355. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64356. */
  64357. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64358. /**
  64359. * The component name helpfull to identify the component in the list of scene components.
  64360. */
  64361. readonly name: string;
  64362. /**
  64363. * The scene the component belongs to.
  64364. */
  64365. scene: Scene;
  64366. /**
  64367. * Creates a new instance of the component for the given scene
  64368. * @param scene Defines the scene to register the component in
  64369. */
  64370. constructor(scene: Scene);
  64371. /**
  64372. * Registers the component in a given scene
  64373. */
  64374. register(): void;
  64375. /**
  64376. * Rebuilds the elements related to this component in case of
  64377. * context lost for instance.
  64378. */
  64379. rebuild(): void;
  64380. /**
  64381. * Disposes the component and the associated ressources
  64382. */
  64383. dispose(): void;
  64384. private _gatherRenderTargets;
  64385. }
  64386. }
  64387. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64388. import { Nullable } from "babylonjs/types";
  64389. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64390. import { Camera } from "babylonjs/Cameras/camera";
  64391. import { IDisposable } from "babylonjs/scene";
  64392. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64393. import { Scene } from "babylonjs/scene";
  64394. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64395. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64396. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64397. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64398. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64399. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64400. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64401. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64402. import { Animation } from "babylonjs/Animations/animation";
  64403. /**
  64404. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64405. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64406. */
  64407. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64408. private _scene;
  64409. private _camerasToBeAttached;
  64410. /**
  64411. * ID of the sharpen post process,
  64412. */
  64413. private readonly SharpenPostProcessId;
  64414. /**
  64415. * @ignore
  64416. * ID of the image processing post process;
  64417. */
  64418. readonly ImageProcessingPostProcessId: string;
  64419. /**
  64420. * @ignore
  64421. * ID of the Fast Approximate Anti-Aliasing post process;
  64422. */
  64423. readonly FxaaPostProcessId: string;
  64424. /**
  64425. * ID of the chromatic aberration post process,
  64426. */
  64427. private readonly ChromaticAberrationPostProcessId;
  64428. /**
  64429. * ID of the grain post process
  64430. */
  64431. private readonly GrainPostProcessId;
  64432. /**
  64433. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64434. */
  64435. sharpen: SharpenPostProcess;
  64436. private _sharpenEffect;
  64437. private bloom;
  64438. /**
  64439. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64440. */
  64441. depthOfField: DepthOfFieldEffect;
  64442. /**
  64443. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64444. */
  64445. fxaa: FxaaPostProcess;
  64446. /**
  64447. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64448. */
  64449. imageProcessing: ImageProcessingPostProcess;
  64450. /**
  64451. * Chromatic aberration post process which will shift rgb colors in the image
  64452. */
  64453. chromaticAberration: ChromaticAberrationPostProcess;
  64454. private _chromaticAberrationEffect;
  64455. /**
  64456. * Grain post process which add noise to the image
  64457. */
  64458. grain: GrainPostProcess;
  64459. private _grainEffect;
  64460. /**
  64461. * Glow post process which adds a glow to emissive areas of the image
  64462. */
  64463. private _glowLayer;
  64464. /**
  64465. * Animations which can be used to tweak settings over a period of time
  64466. */
  64467. animations: Animation[];
  64468. private _imageProcessingConfigurationObserver;
  64469. private _sharpenEnabled;
  64470. private _bloomEnabled;
  64471. private _depthOfFieldEnabled;
  64472. private _depthOfFieldBlurLevel;
  64473. private _fxaaEnabled;
  64474. private _imageProcessingEnabled;
  64475. private _defaultPipelineTextureType;
  64476. private _bloomScale;
  64477. private _chromaticAberrationEnabled;
  64478. private _grainEnabled;
  64479. private _buildAllowed;
  64480. /**
  64481. * Gets active scene
  64482. */
  64483. readonly scene: Scene;
  64484. /**
  64485. * Enable or disable the sharpen process from the pipeline
  64486. */
  64487. sharpenEnabled: boolean;
  64488. private _resizeObserver;
  64489. private _hardwareScaleLevel;
  64490. private _bloomKernel;
  64491. /**
  64492. * Specifies the size of the bloom blur kernel, relative to the final output size
  64493. */
  64494. bloomKernel: number;
  64495. /**
  64496. * Specifies the weight of the bloom in the final rendering
  64497. */
  64498. private _bloomWeight;
  64499. /**
  64500. * Specifies the luma threshold for the area that will be blurred by the bloom
  64501. */
  64502. private _bloomThreshold;
  64503. private _hdr;
  64504. /**
  64505. * The strength of the bloom.
  64506. */
  64507. bloomWeight: number;
  64508. /**
  64509. * The strength of the bloom.
  64510. */
  64511. bloomThreshold: number;
  64512. /**
  64513. * The scale of the bloom, lower value will provide better performance.
  64514. */
  64515. bloomScale: number;
  64516. /**
  64517. * Enable or disable the bloom from the pipeline
  64518. */
  64519. bloomEnabled: boolean;
  64520. private _rebuildBloom;
  64521. /**
  64522. * If the depth of field is enabled.
  64523. */
  64524. depthOfFieldEnabled: boolean;
  64525. /**
  64526. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64527. */
  64528. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64529. /**
  64530. * If the anti aliasing is enabled.
  64531. */
  64532. fxaaEnabled: boolean;
  64533. private _samples;
  64534. /**
  64535. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64536. */
  64537. samples: number;
  64538. /**
  64539. * If image processing is enabled.
  64540. */
  64541. imageProcessingEnabled: boolean;
  64542. /**
  64543. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64544. */
  64545. glowLayerEnabled: boolean;
  64546. /**
  64547. * Gets the glow layer (or null if not defined)
  64548. */
  64549. readonly glowLayer: Nullable<GlowLayer>;
  64550. /**
  64551. * Enable or disable the chromaticAberration process from the pipeline
  64552. */
  64553. chromaticAberrationEnabled: boolean;
  64554. /**
  64555. * Enable or disable the grain process from the pipeline
  64556. */
  64557. grainEnabled: boolean;
  64558. /**
  64559. * @constructor
  64560. * @param name - The rendering pipeline name (default: "")
  64561. * @param hdr - If high dynamic range textures should be used (default: true)
  64562. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64563. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64564. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64565. */
  64566. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64567. /**
  64568. * Get the class name
  64569. * @returns "DefaultRenderingPipeline"
  64570. */
  64571. getClassName(): string;
  64572. /**
  64573. * Force the compilation of the entire pipeline.
  64574. */
  64575. prepare(): void;
  64576. private _hasCleared;
  64577. private _prevPostProcess;
  64578. private _prevPrevPostProcess;
  64579. private _setAutoClearAndTextureSharing;
  64580. private _depthOfFieldSceneObserver;
  64581. private _buildPipeline;
  64582. private _disposePostProcesses;
  64583. /**
  64584. * Adds a camera to the pipeline
  64585. * @param camera the camera to be added
  64586. */
  64587. addCamera(camera: Camera): void;
  64588. /**
  64589. * Removes a camera from the pipeline
  64590. * @param camera the camera to remove
  64591. */
  64592. removeCamera(camera: Camera): void;
  64593. /**
  64594. * Dispose of the pipeline and stop all post processes
  64595. */
  64596. dispose(): void;
  64597. /**
  64598. * Serialize the rendering pipeline (Used when exporting)
  64599. * @returns the serialized object
  64600. */
  64601. serialize(): any;
  64602. /**
  64603. * Parse the serialized pipeline
  64604. * @param source Source pipeline.
  64605. * @param scene The scene to load the pipeline to.
  64606. * @param rootUrl The URL of the serialized pipeline.
  64607. * @returns An instantiated pipeline from the serialized object.
  64608. */
  64609. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64610. }
  64611. }
  64612. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64613. /** @hidden */
  64614. export var lensHighlightsPixelShader: {
  64615. name: string;
  64616. shader: string;
  64617. };
  64618. }
  64619. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64620. /** @hidden */
  64621. export var depthOfFieldPixelShader: {
  64622. name: string;
  64623. shader: string;
  64624. };
  64625. }
  64626. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64627. import { Camera } from "babylonjs/Cameras/camera";
  64628. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64629. import { Scene } from "babylonjs/scene";
  64630. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64631. import "babylonjs/Shaders/chromaticAberration.fragment";
  64632. import "babylonjs/Shaders/lensHighlights.fragment";
  64633. import "babylonjs/Shaders/depthOfField.fragment";
  64634. /**
  64635. * BABYLON.JS Chromatic Aberration GLSL Shader
  64636. * Author: Olivier Guyot
  64637. * Separates very slightly R, G and B colors on the edges of the screen
  64638. * Inspired by Francois Tarlier & Martins Upitis
  64639. */
  64640. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64641. /**
  64642. * @ignore
  64643. * The chromatic aberration PostProcess id in the pipeline
  64644. */
  64645. LensChromaticAberrationEffect: string;
  64646. /**
  64647. * @ignore
  64648. * The highlights enhancing PostProcess id in the pipeline
  64649. */
  64650. HighlightsEnhancingEffect: string;
  64651. /**
  64652. * @ignore
  64653. * The depth-of-field PostProcess id in the pipeline
  64654. */
  64655. LensDepthOfFieldEffect: string;
  64656. private _scene;
  64657. private _depthTexture;
  64658. private _grainTexture;
  64659. private _chromaticAberrationPostProcess;
  64660. private _highlightsPostProcess;
  64661. private _depthOfFieldPostProcess;
  64662. private _edgeBlur;
  64663. private _grainAmount;
  64664. private _chromaticAberration;
  64665. private _distortion;
  64666. private _highlightsGain;
  64667. private _highlightsThreshold;
  64668. private _dofDistance;
  64669. private _dofAperture;
  64670. private _dofDarken;
  64671. private _dofPentagon;
  64672. private _blurNoise;
  64673. /**
  64674. * @constructor
  64675. *
  64676. * Effect parameters are as follow:
  64677. * {
  64678. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64679. * edge_blur: number; // from 0 to x (1 for realism)
  64680. * distortion: number; // from 0 to x (1 for realism)
  64681. * grain_amount: number; // from 0 to 1
  64682. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64683. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64684. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64685. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64686. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64687. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64688. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64689. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64690. * }
  64691. * Note: if an effect parameter is unset, effect is disabled
  64692. *
  64693. * @param name The rendering pipeline name
  64694. * @param parameters - An object containing all parameters (see above)
  64695. * @param scene The scene linked to this pipeline
  64696. * @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)
  64697. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64698. */
  64699. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64700. /**
  64701. * Get the class name
  64702. * @returns "LensRenderingPipeline"
  64703. */
  64704. getClassName(): string;
  64705. /**
  64706. * Gets associated scene
  64707. */
  64708. readonly scene: Scene;
  64709. /**
  64710. * Gets or sets the edge blur
  64711. */
  64712. edgeBlur: number;
  64713. /**
  64714. * Gets or sets the grain amount
  64715. */
  64716. grainAmount: number;
  64717. /**
  64718. * Gets or sets the chromatic aberration amount
  64719. */
  64720. chromaticAberration: number;
  64721. /**
  64722. * Gets or sets the depth of field aperture
  64723. */
  64724. dofAperture: number;
  64725. /**
  64726. * Gets or sets the edge distortion
  64727. */
  64728. edgeDistortion: number;
  64729. /**
  64730. * Gets or sets the depth of field distortion
  64731. */
  64732. dofDistortion: number;
  64733. /**
  64734. * Gets or sets the darken out of focus amount
  64735. */
  64736. darkenOutOfFocus: number;
  64737. /**
  64738. * Gets or sets a boolean indicating if blur noise is enabled
  64739. */
  64740. blurNoise: boolean;
  64741. /**
  64742. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64743. */
  64744. pentagonBokeh: boolean;
  64745. /**
  64746. * Gets or sets the highlight grain amount
  64747. */
  64748. highlightsGain: number;
  64749. /**
  64750. * Gets or sets the highlight threshold
  64751. */
  64752. highlightsThreshold: number;
  64753. /**
  64754. * Sets the amount of blur at the edges
  64755. * @param amount blur amount
  64756. */
  64757. setEdgeBlur(amount: number): void;
  64758. /**
  64759. * Sets edge blur to 0
  64760. */
  64761. disableEdgeBlur(): void;
  64762. /**
  64763. * Sets the amout of grain
  64764. * @param amount Amount of grain
  64765. */
  64766. setGrainAmount(amount: number): void;
  64767. /**
  64768. * Set grain amount to 0
  64769. */
  64770. disableGrain(): void;
  64771. /**
  64772. * Sets the chromatic aberration amount
  64773. * @param amount amount of chromatic aberration
  64774. */
  64775. setChromaticAberration(amount: number): void;
  64776. /**
  64777. * Sets chromatic aberration amount to 0
  64778. */
  64779. disableChromaticAberration(): void;
  64780. /**
  64781. * Sets the EdgeDistortion amount
  64782. * @param amount amount of EdgeDistortion
  64783. */
  64784. setEdgeDistortion(amount: number): void;
  64785. /**
  64786. * Sets edge distortion to 0
  64787. */
  64788. disableEdgeDistortion(): void;
  64789. /**
  64790. * Sets the FocusDistance amount
  64791. * @param amount amount of FocusDistance
  64792. */
  64793. setFocusDistance(amount: number): void;
  64794. /**
  64795. * Disables depth of field
  64796. */
  64797. disableDepthOfField(): void;
  64798. /**
  64799. * Sets the Aperture amount
  64800. * @param amount amount of Aperture
  64801. */
  64802. setAperture(amount: number): void;
  64803. /**
  64804. * Sets the DarkenOutOfFocus amount
  64805. * @param amount amount of DarkenOutOfFocus
  64806. */
  64807. setDarkenOutOfFocus(amount: number): void;
  64808. private _pentagonBokehIsEnabled;
  64809. /**
  64810. * Creates a pentagon bokeh effect
  64811. */
  64812. enablePentagonBokeh(): void;
  64813. /**
  64814. * Disables the pentagon bokeh effect
  64815. */
  64816. disablePentagonBokeh(): void;
  64817. /**
  64818. * Enables noise blur
  64819. */
  64820. enableNoiseBlur(): void;
  64821. /**
  64822. * Disables noise blur
  64823. */
  64824. disableNoiseBlur(): void;
  64825. /**
  64826. * Sets the HighlightsGain amount
  64827. * @param amount amount of HighlightsGain
  64828. */
  64829. setHighlightsGain(amount: number): void;
  64830. /**
  64831. * Sets the HighlightsThreshold amount
  64832. * @param amount amount of HighlightsThreshold
  64833. */
  64834. setHighlightsThreshold(amount: number): void;
  64835. /**
  64836. * Disables highlights
  64837. */
  64838. disableHighlights(): void;
  64839. /**
  64840. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64841. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64842. */
  64843. dispose(disableDepthRender?: boolean): void;
  64844. private _createChromaticAberrationPostProcess;
  64845. private _createHighlightsPostProcess;
  64846. private _createDepthOfFieldPostProcess;
  64847. private _createGrainTexture;
  64848. }
  64849. }
  64850. declare module "babylonjs/Shaders/ssao2.fragment" {
  64851. /** @hidden */
  64852. export var ssao2PixelShader: {
  64853. name: string;
  64854. shader: string;
  64855. };
  64856. }
  64857. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64858. /** @hidden */
  64859. export var ssaoCombinePixelShader: {
  64860. name: string;
  64861. shader: string;
  64862. };
  64863. }
  64864. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64865. import { Camera } from "babylonjs/Cameras/camera";
  64866. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64867. import { Scene } from "babylonjs/scene";
  64868. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64869. import "babylonjs/Shaders/ssao2.fragment";
  64870. import "babylonjs/Shaders/ssaoCombine.fragment";
  64871. /**
  64872. * Render pipeline to produce ssao effect
  64873. */
  64874. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64875. /**
  64876. * @ignore
  64877. * The PassPostProcess id in the pipeline that contains the original scene color
  64878. */
  64879. SSAOOriginalSceneColorEffect: string;
  64880. /**
  64881. * @ignore
  64882. * The SSAO PostProcess id in the pipeline
  64883. */
  64884. SSAORenderEffect: string;
  64885. /**
  64886. * @ignore
  64887. * The horizontal blur PostProcess id in the pipeline
  64888. */
  64889. SSAOBlurHRenderEffect: string;
  64890. /**
  64891. * @ignore
  64892. * The vertical blur PostProcess id in the pipeline
  64893. */
  64894. SSAOBlurVRenderEffect: string;
  64895. /**
  64896. * @ignore
  64897. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64898. */
  64899. SSAOCombineRenderEffect: string;
  64900. /**
  64901. * The output strength of the SSAO post-process. Default value is 1.0.
  64902. */
  64903. totalStrength: number;
  64904. /**
  64905. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64906. */
  64907. maxZ: number;
  64908. /**
  64909. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64910. */
  64911. minZAspect: number;
  64912. private _samples;
  64913. /**
  64914. * Number of samples used for the SSAO calculations. Default value is 8
  64915. */
  64916. samples: number;
  64917. private _textureSamples;
  64918. /**
  64919. * Number of samples to use for antialiasing
  64920. */
  64921. textureSamples: number;
  64922. /**
  64923. * Ratio object used for SSAO ratio and blur ratio
  64924. */
  64925. private _ratio;
  64926. /**
  64927. * Dynamically generated sphere sampler.
  64928. */
  64929. private _sampleSphere;
  64930. /**
  64931. * Blur filter offsets
  64932. */
  64933. private _samplerOffsets;
  64934. private _expensiveBlur;
  64935. /**
  64936. * If bilateral blur should be used
  64937. */
  64938. expensiveBlur: boolean;
  64939. /**
  64940. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64941. */
  64942. radius: number;
  64943. /**
  64944. * The base color of the SSAO post-process
  64945. * The final result is "base + ssao" between [0, 1]
  64946. */
  64947. base: number;
  64948. /**
  64949. * Support test.
  64950. */
  64951. static readonly IsSupported: boolean;
  64952. private _scene;
  64953. private _depthTexture;
  64954. private _normalTexture;
  64955. private _randomTexture;
  64956. private _originalColorPostProcess;
  64957. private _ssaoPostProcess;
  64958. private _blurHPostProcess;
  64959. private _blurVPostProcess;
  64960. private _ssaoCombinePostProcess;
  64961. private _firstUpdate;
  64962. /**
  64963. * Gets active scene
  64964. */
  64965. readonly scene: Scene;
  64966. /**
  64967. * @constructor
  64968. * @param name The rendering pipeline name
  64969. * @param scene The scene linked to this pipeline
  64970. * @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 }
  64971. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64972. */
  64973. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64974. /**
  64975. * Get the class name
  64976. * @returns "SSAO2RenderingPipeline"
  64977. */
  64978. getClassName(): string;
  64979. /**
  64980. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64981. */
  64982. dispose(disableGeometryBufferRenderer?: boolean): void;
  64983. private _createBlurPostProcess;
  64984. /** @hidden */
  64985. _rebuild(): void;
  64986. private _bits;
  64987. private _radicalInverse_VdC;
  64988. private _hammersley;
  64989. private _hemisphereSample_uniform;
  64990. private _generateHemisphere;
  64991. private _createSSAOPostProcess;
  64992. private _createSSAOCombinePostProcess;
  64993. private _createRandomTexture;
  64994. /**
  64995. * Serialize the rendering pipeline (Used when exporting)
  64996. * @returns the serialized object
  64997. */
  64998. serialize(): any;
  64999. /**
  65000. * Parse the serialized pipeline
  65001. * @param source Source pipeline.
  65002. * @param scene The scene to load the pipeline to.
  65003. * @param rootUrl The URL of the serialized pipeline.
  65004. * @returns An instantiated pipeline from the serialized object.
  65005. */
  65006. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65007. }
  65008. }
  65009. declare module "babylonjs/Shaders/ssao.fragment" {
  65010. /** @hidden */
  65011. export var ssaoPixelShader: {
  65012. name: string;
  65013. shader: string;
  65014. };
  65015. }
  65016. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65017. import { Camera } from "babylonjs/Cameras/camera";
  65018. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65019. import { Scene } from "babylonjs/scene";
  65020. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65021. import "babylonjs/Shaders/ssao.fragment";
  65022. import "babylonjs/Shaders/ssaoCombine.fragment";
  65023. /**
  65024. * Render pipeline to produce ssao effect
  65025. */
  65026. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65027. /**
  65028. * @ignore
  65029. * The PassPostProcess id in the pipeline that contains the original scene color
  65030. */
  65031. SSAOOriginalSceneColorEffect: string;
  65032. /**
  65033. * @ignore
  65034. * The SSAO PostProcess id in the pipeline
  65035. */
  65036. SSAORenderEffect: string;
  65037. /**
  65038. * @ignore
  65039. * The horizontal blur PostProcess id in the pipeline
  65040. */
  65041. SSAOBlurHRenderEffect: string;
  65042. /**
  65043. * @ignore
  65044. * The vertical blur PostProcess id in the pipeline
  65045. */
  65046. SSAOBlurVRenderEffect: string;
  65047. /**
  65048. * @ignore
  65049. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65050. */
  65051. SSAOCombineRenderEffect: string;
  65052. /**
  65053. * The output strength of the SSAO post-process. Default value is 1.0.
  65054. */
  65055. totalStrength: number;
  65056. /**
  65057. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65058. */
  65059. radius: number;
  65060. /**
  65061. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65062. * Must not be equal to fallOff and superior to fallOff.
  65063. * Default value is 0.0075
  65064. */
  65065. area: number;
  65066. /**
  65067. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65068. * Must not be equal to area and inferior to area.
  65069. * Default value is 0.000001
  65070. */
  65071. fallOff: number;
  65072. /**
  65073. * The base color of the SSAO post-process
  65074. * The final result is "base + ssao" between [0, 1]
  65075. */
  65076. base: number;
  65077. private _scene;
  65078. private _depthTexture;
  65079. private _randomTexture;
  65080. private _originalColorPostProcess;
  65081. private _ssaoPostProcess;
  65082. private _blurHPostProcess;
  65083. private _blurVPostProcess;
  65084. private _ssaoCombinePostProcess;
  65085. private _firstUpdate;
  65086. /**
  65087. * Gets active scene
  65088. */
  65089. readonly scene: Scene;
  65090. /**
  65091. * @constructor
  65092. * @param name - The rendering pipeline name
  65093. * @param scene - The scene linked to this pipeline
  65094. * @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 }
  65095. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65096. */
  65097. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65098. /**
  65099. * Get the class name
  65100. * @returns "SSAORenderingPipeline"
  65101. */
  65102. getClassName(): string;
  65103. /**
  65104. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65105. */
  65106. dispose(disableDepthRender?: boolean): void;
  65107. private _createBlurPostProcess;
  65108. /** @hidden */
  65109. _rebuild(): void;
  65110. private _createSSAOPostProcess;
  65111. private _createSSAOCombinePostProcess;
  65112. private _createRandomTexture;
  65113. }
  65114. }
  65115. declare module "babylonjs/Shaders/standard.fragment" {
  65116. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65117. /** @hidden */
  65118. export var standardPixelShader: {
  65119. name: string;
  65120. shader: string;
  65121. };
  65122. }
  65123. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65124. import { Nullable } from "babylonjs/types";
  65125. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65126. import { Camera } from "babylonjs/Cameras/camera";
  65127. import { Texture } from "babylonjs/Materials/Textures/texture";
  65128. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65129. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65130. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65131. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65132. import { IDisposable } from "babylonjs/scene";
  65133. import { SpotLight } from "babylonjs/Lights/spotLight";
  65134. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65135. import { Scene } from "babylonjs/scene";
  65136. import { Animation } from "babylonjs/Animations/animation";
  65137. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65138. import "babylonjs/Shaders/standard.fragment";
  65139. /**
  65140. * Standard rendering pipeline
  65141. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65142. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65143. */
  65144. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65145. /**
  65146. * Public members
  65147. */
  65148. /**
  65149. * Post-process which contains the original scene color before the pipeline applies all the effects
  65150. */
  65151. originalPostProcess: Nullable<PostProcess>;
  65152. /**
  65153. * Post-process used to down scale an image x4
  65154. */
  65155. downSampleX4PostProcess: Nullable<PostProcess>;
  65156. /**
  65157. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65158. */
  65159. brightPassPostProcess: Nullable<PostProcess>;
  65160. /**
  65161. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65162. */
  65163. blurHPostProcesses: PostProcess[];
  65164. /**
  65165. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65166. */
  65167. blurVPostProcesses: PostProcess[];
  65168. /**
  65169. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65170. */
  65171. textureAdderPostProcess: Nullable<PostProcess>;
  65172. /**
  65173. * Post-process used to create volumetric lighting effect
  65174. */
  65175. volumetricLightPostProcess: Nullable<PostProcess>;
  65176. /**
  65177. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65178. */
  65179. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65180. /**
  65181. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65182. */
  65183. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65184. /**
  65185. * Post-process used to merge the volumetric light effect and the real scene color
  65186. */
  65187. volumetricLightMergePostProces: Nullable<PostProcess>;
  65188. /**
  65189. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65190. */
  65191. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65192. /**
  65193. * Base post-process used to calculate the average luminance of the final image for HDR
  65194. */
  65195. luminancePostProcess: Nullable<PostProcess>;
  65196. /**
  65197. * Post-processes used to create down sample post-processes in order to get
  65198. * the average luminance of the final image for HDR
  65199. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65200. */
  65201. luminanceDownSamplePostProcesses: PostProcess[];
  65202. /**
  65203. * Post-process used to create a HDR effect (light adaptation)
  65204. */
  65205. hdrPostProcess: Nullable<PostProcess>;
  65206. /**
  65207. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65208. */
  65209. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65210. /**
  65211. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65212. */
  65213. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65214. /**
  65215. * Post-process used to merge the final HDR post-process and the real scene color
  65216. */
  65217. hdrFinalPostProcess: Nullable<PostProcess>;
  65218. /**
  65219. * Post-process used to create a lens flare effect
  65220. */
  65221. lensFlarePostProcess: Nullable<PostProcess>;
  65222. /**
  65223. * Post-process that merges the result of the lens flare post-process and the real scene color
  65224. */
  65225. lensFlareComposePostProcess: Nullable<PostProcess>;
  65226. /**
  65227. * Post-process used to create a motion blur effect
  65228. */
  65229. motionBlurPostProcess: Nullable<PostProcess>;
  65230. /**
  65231. * Post-process used to create a depth of field effect
  65232. */
  65233. depthOfFieldPostProcess: Nullable<PostProcess>;
  65234. /**
  65235. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65236. */
  65237. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65238. /**
  65239. * Represents the brightness threshold in order to configure the illuminated surfaces
  65240. */
  65241. brightThreshold: number;
  65242. /**
  65243. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65244. */
  65245. blurWidth: number;
  65246. /**
  65247. * Sets if the blur for highlighted surfaces must be only horizontal
  65248. */
  65249. horizontalBlur: boolean;
  65250. /**
  65251. * Gets the overall exposure used by the pipeline
  65252. */
  65253. /**
  65254. * Sets the overall exposure used by the pipeline
  65255. */
  65256. exposure: number;
  65257. /**
  65258. * Texture used typically to simulate "dirty" on camera lens
  65259. */
  65260. lensTexture: Nullable<Texture>;
  65261. /**
  65262. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65263. */
  65264. volumetricLightCoefficient: number;
  65265. /**
  65266. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65267. */
  65268. volumetricLightPower: number;
  65269. /**
  65270. * Used the set the blur intensity to smooth the volumetric lights
  65271. */
  65272. volumetricLightBlurScale: number;
  65273. /**
  65274. * Light (spot or directional) used to generate the volumetric lights rays
  65275. * The source light must have a shadow generate so the pipeline can get its
  65276. * depth map
  65277. */
  65278. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65279. /**
  65280. * For eye adaptation, represents the minimum luminance the eye can see
  65281. */
  65282. hdrMinimumLuminance: number;
  65283. /**
  65284. * For eye adaptation, represents the decrease luminance speed
  65285. */
  65286. hdrDecreaseRate: number;
  65287. /**
  65288. * For eye adaptation, represents the increase luminance speed
  65289. */
  65290. hdrIncreaseRate: number;
  65291. /**
  65292. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65293. */
  65294. /**
  65295. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65296. */
  65297. hdrAutoExposure: boolean;
  65298. /**
  65299. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65300. */
  65301. lensColorTexture: Nullable<Texture>;
  65302. /**
  65303. * The overall strengh for the lens flare effect
  65304. */
  65305. lensFlareStrength: number;
  65306. /**
  65307. * Dispersion coefficient for lens flare ghosts
  65308. */
  65309. lensFlareGhostDispersal: number;
  65310. /**
  65311. * Main lens flare halo width
  65312. */
  65313. lensFlareHaloWidth: number;
  65314. /**
  65315. * Based on the lens distortion effect, defines how much the lens flare result
  65316. * is distorted
  65317. */
  65318. lensFlareDistortionStrength: number;
  65319. /**
  65320. * Configures the blur intensity used for for lens flare (halo)
  65321. */
  65322. lensFlareBlurWidth: number;
  65323. /**
  65324. * Lens star texture must be used to simulate rays on the flares and is available
  65325. * in the documentation
  65326. */
  65327. lensStarTexture: Nullable<Texture>;
  65328. /**
  65329. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65330. * flare effect by taking account of the dirt texture
  65331. */
  65332. lensFlareDirtTexture: Nullable<Texture>;
  65333. /**
  65334. * Represents the focal length for the depth of field effect
  65335. */
  65336. depthOfFieldDistance: number;
  65337. /**
  65338. * Represents the blur intensity for the blurred part of the depth of field effect
  65339. */
  65340. depthOfFieldBlurWidth: number;
  65341. /**
  65342. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65343. */
  65344. /**
  65345. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65346. */
  65347. motionStrength: number;
  65348. /**
  65349. * Gets wether or not the motion blur post-process is object based or screen based.
  65350. */
  65351. /**
  65352. * Sets wether or not the motion blur post-process should be object based or screen based
  65353. */
  65354. objectBasedMotionBlur: boolean;
  65355. /**
  65356. * List of animations for the pipeline (IAnimatable implementation)
  65357. */
  65358. animations: Animation[];
  65359. /**
  65360. * Private members
  65361. */
  65362. private _scene;
  65363. private _currentDepthOfFieldSource;
  65364. private _basePostProcess;
  65365. private _fixedExposure;
  65366. private _currentExposure;
  65367. private _hdrAutoExposure;
  65368. private _hdrCurrentLuminance;
  65369. private _motionStrength;
  65370. private _isObjectBasedMotionBlur;
  65371. private _floatTextureType;
  65372. private _camerasToBeAttached;
  65373. private _ratio;
  65374. private _bloomEnabled;
  65375. private _depthOfFieldEnabled;
  65376. private _vlsEnabled;
  65377. private _lensFlareEnabled;
  65378. private _hdrEnabled;
  65379. private _motionBlurEnabled;
  65380. private _fxaaEnabled;
  65381. private _motionBlurSamples;
  65382. private _volumetricLightStepsCount;
  65383. private _samples;
  65384. /**
  65385. * @ignore
  65386. * Specifies if the bloom pipeline is enabled
  65387. */
  65388. BloomEnabled: boolean;
  65389. /**
  65390. * @ignore
  65391. * Specifies if the depth of field pipeline is enabed
  65392. */
  65393. DepthOfFieldEnabled: boolean;
  65394. /**
  65395. * @ignore
  65396. * Specifies if the lens flare pipeline is enabed
  65397. */
  65398. LensFlareEnabled: boolean;
  65399. /**
  65400. * @ignore
  65401. * Specifies if the HDR pipeline is enabled
  65402. */
  65403. HDREnabled: boolean;
  65404. /**
  65405. * @ignore
  65406. * Specifies if the volumetric lights scattering effect is enabled
  65407. */
  65408. VLSEnabled: boolean;
  65409. /**
  65410. * @ignore
  65411. * Specifies if the motion blur effect is enabled
  65412. */
  65413. MotionBlurEnabled: boolean;
  65414. /**
  65415. * Specifies if anti-aliasing is enabled
  65416. */
  65417. fxaaEnabled: boolean;
  65418. /**
  65419. * Specifies the number of steps used to calculate the volumetric lights
  65420. * Typically in interval [50, 200]
  65421. */
  65422. volumetricLightStepsCount: number;
  65423. /**
  65424. * Specifies the number of samples used for the motion blur effect
  65425. * Typically in interval [16, 64]
  65426. */
  65427. motionBlurSamples: number;
  65428. /**
  65429. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65430. */
  65431. samples: number;
  65432. /**
  65433. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65434. * @constructor
  65435. * @param name The rendering pipeline name
  65436. * @param scene The scene linked to this pipeline
  65437. * @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)
  65438. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65439. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65440. */
  65441. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65442. private _buildPipeline;
  65443. private _createDownSampleX4PostProcess;
  65444. private _createBrightPassPostProcess;
  65445. private _createBlurPostProcesses;
  65446. private _createTextureAdderPostProcess;
  65447. private _createVolumetricLightPostProcess;
  65448. private _createLuminancePostProcesses;
  65449. private _createHdrPostProcess;
  65450. private _createLensFlarePostProcess;
  65451. private _createDepthOfFieldPostProcess;
  65452. private _createMotionBlurPostProcess;
  65453. private _getDepthTexture;
  65454. private _disposePostProcesses;
  65455. /**
  65456. * Dispose of the pipeline and stop all post processes
  65457. */
  65458. dispose(): void;
  65459. /**
  65460. * Serialize the rendering pipeline (Used when exporting)
  65461. * @returns the serialized object
  65462. */
  65463. serialize(): any;
  65464. /**
  65465. * Parse the serialized pipeline
  65466. * @param source Source pipeline.
  65467. * @param scene The scene to load the pipeline to.
  65468. * @param rootUrl The URL of the serialized pipeline.
  65469. * @returns An instantiated pipeline from the serialized object.
  65470. */
  65471. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65472. /**
  65473. * Luminance steps
  65474. */
  65475. static LuminanceSteps: number;
  65476. }
  65477. }
  65478. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65479. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65480. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65481. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65482. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65483. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65484. }
  65485. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65486. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65487. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65488. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65489. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65490. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65491. }
  65492. declare module "babylonjs/Shaders/tonemap.fragment" {
  65493. /** @hidden */
  65494. export var tonemapPixelShader: {
  65495. name: string;
  65496. shader: string;
  65497. };
  65498. }
  65499. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65500. import { Camera } from "babylonjs/Cameras/camera";
  65501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65502. import "babylonjs/Shaders/tonemap.fragment";
  65503. import { Engine } from "babylonjs/Engines/engine";
  65504. /** Defines operator used for tonemapping */
  65505. export enum TonemappingOperator {
  65506. /** Hable */
  65507. Hable = 0,
  65508. /** Reinhard */
  65509. Reinhard = 1,
  65510. /** HejiDawson */
  65511. HejiDawson = 2,
  65512. /** Photographic */
  65513. Photographic = 3
  65514. }
  65515. /**
  65516. * Defines a post process to apply tone mapping
  65517. */
  65518. export class TonemapPostProcess extends PostProcess {
  65519. private _operator;
  65520. /** Defines the required exposure adjustement */
  65521. exposureAdjustment: number;
  65522. /**
  65523. * Creates a new TonemapPostProcess
  65524. * @param name defines the name of the postprocess
  65525. * @param _operator defines the operator to use
  65526. * @param exposureAdjustment defines the required exposure adjustement
  65527. * @param camera defines the camera to use (can be null)
  65528. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65529. * @param engine defines the hosting engine (can be ignore if camera is set)
  65530. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65531. */
  65532. constructor(name: string, _operator: TonemappingOperator,
  65533. /** Defines the required exposure adjustement */
  65534. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65535. }
  65536. }
  65537. declare module "babylonjs/Shaders/depth.vertex" {
  65538. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65541. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65543. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65544. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65545. /** @hidden */
  65546. export var depthVertexShader: {
  65547. name: string;
  65548. shader: string;
  65549. };
  65550. }
  65551. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65552. /** @hidden */
  65553. export var volumetricLightScatteringPixelShader: {
  65554. name: string;
  65555. shader: string;
  65556. };
  65557. }
  65558. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65559. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65561. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65562. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65564. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65565. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65566. /** @hidden */
  65567. export var volumetricLightScatteringPassVertexShader: {
  65568. name: string;
  65569. shader: string;
  65570. };
  65571. }
  65572. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65573. /** @hidden */
  65574. export var volumetricLightScatteringPassPixelShader: {
  65575. name: string;
  65576. shader: string;
  65577. };
  65578. }
  65579. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65580. import { Vector3 } from "babylonjs/Maths/math.vector";
  65581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65582. import { Mesh } from "babylonjs/Meshes/mesh";
  65583. import { Camera } from "babylonjs/Cameras/camera";
  65584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65585. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65586. import { Scene } from "babylonjs/scene";
  65587. import "babylonjs/Meshes/Builders/planeBuilder";
  65588. import "babylonjs/Shaders/depth.vertex";
  65589. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65590. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65591. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65592. import { Engine } from "babylonjs/Engines/engine";
  65593. /**
  65594. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65595. */
  65596. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65597. private _volumetricLightScatteringPass;
  65598. private _volumetricLightScatteringRTT;
  65599. private _viewPort;
  65600. private _screenCoordinates;
  65601. private _cachedDefines;
  65602. /**
  65603. * If not undefined, the mesh position is computed from the attached node position
  65604. */
  65605. attachedNode: {
  65606. position: Vector3;
  65607. };
  65608. /**
  65609. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65610. */
  65611. customMeshPosition: Vector3;
  65612. /**
  65613. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65614. */
  65615. useCustomMeshPosition: boolean;
  65616. /**
  65617. * If the post-process should inverse the light scattering direction
  65618. */
  65619. invert: boolean;
  65620. /**
  65621. * The internal mesh used by the post-process
  65622. */
  65623. mesh: Mesh;
  65624. /**
  65625. * @hidden
  65626. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65627. */
  65628. useDiffuseColor: boolean;
  65629. /**
  65630. * Array containing the excluded meshes not rendered in the internal pass
  65631. */
  65632. excludedMeshes: AbstractMesh[];
  65633. /**
  65634. * Controls the overall intensity of the post-process
  65635. */
  65636. exposure: number;
  65637. /**
  65638. * Dissipates each sample's contribution in range [0, 1]
  65639. */
  65640. decay: number;
  65641. /**
  65642. * Controls the overall intensity of each sample
  65643. */
  65644. weight: number;
  65645. /**
  65646. * Controls the density of each sample
  65647. */
  65648. density: number;
  65649. /**
  65650. * @constructor
  65651. * @param name The post-process name
  65652. * @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)
  65653. * @param camera The camera that the post-process will be attached to
  65654. * @param mesh The mesh used to create the light scattering
  65655. * @param samples The post-process quality, default 100
  65656. * @param samplingModeThe post-process filtering mode
  65657. * @param engine The babylon engine
  65658. * @param reusable If the post-process is reusable
  65659. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65660. */
  65661. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65662. /**
  65663. * Returns the string "VolumetricLightScatteringPostProcess"
  65664. * @returns "VolumetricLightScatteringPostProcess"
  65665. */
  65666. getClassName(): string;
  65667. private _isReady;
  65668. /**
  65669. * Sets the new light position for light scattering effect
  65670. * @param position The new custom light position
  65671. */
  65672. setCustomMeshPosition(position: Vector3): void;
  65673. /**
  65674. * Returns the light position for light scattering effect
  65675. * @return Vector3 The custom light position
  65676. */
  65677. getCustomMeshPosition(): Vector3;
  65678. /**
  65679. * Disposes the internal assets and detaches the post-process from the camera
  65680. */
  65681. dispose(camera: Camera): void;
  65682. /**
  65683. * Returns the render target texture used by the post-process
  65684. * @return the render target texture used by the post-process
  65685. */
  65686. getPass(): RenderTargetTexture;
  65687. private _meshExcluded;
  65688. private _createPass;
  65689. private _updateMeshScreenCoordinates;
  65690. /**
  65691. * Creates a default mesh for the Volumeric Light Scattering post-process
  65692. * @param name The mesh name
  65693. * @param scene The scene where to create the mesh
  65694. * @return the default mesh
  65695. */
  65696. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65697. }
  65698. }
  65699. declare module "babylonjs/PostProcesses/index" {
  65700. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65701. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65702. export * from "babylonjs/PostProcesses/bloomEffect";
  65703. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65704. export * from "babylonjs/PostProcesses/blurPostProcess";
  65705. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65706. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65707. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65708. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65709. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65710. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65711. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65712. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65713. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65714. export * from "babylonjs/PostProcesses/filterPostProcess";
  65715. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65716. export * from "babylonjs/PostProcesses/grainPostProcess";
  65717. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65718. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65719. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65720. export * from "babylonjs/PostProcesses/passPostProcess";
  65721. export * from "babylonjs/PostProcesses/postProcess";
  65722. export * from "babylonjs/PostProcesses/postProcessManager";
  65723. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65724. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65725. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65726. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65727. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65728. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65729. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65730. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65731. }
  65732. declare module "babylonjs/Probes/index" {
  65733. export * from "babylonjs/Probes/reflectionProbe";
  65734. }
  65735. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65736. import { Scene } from "babylonjs/scene";
  65737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65738. import { SmartArray } from "babylonjs/Misc/smartArray";
  65739. import { ISceneComponent } from "babylonjs/sceneComponent";
  65740. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65741. import "babylonjs/Meshes/Builders/boxBuilder";
  65742. import "babylonjs/Shaders/color.fragment";
  65743. import "babylonjs/Shaders/color.vertex";
  65744. import { Color3 } from "babylonjs/Maths/math.color";
  65745. module "babylonjs/scene" {
  65746. interface Scene {
  65747. /** @hidden (Backing field) */
  65748. _boundingBoxRenderer: BoundingBoxRenderer;
  65749. /** @hidden (Backing field) */
  65750. _forceShowBoundingBoxes: boolean;
  65751. /**
  65752. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65753. */
  65754. forceShowBoundingBoxes: boolean;
  65755. /**
  65756. * Gets the bounding box renderer associated with the scene
  65757. * @returns a BoundingBoxRenderer
  65758. */
  65759. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65760. }
  65761. }
  65762. module "babylonjs/Meshes/abstractMesh" {
  65763. interface AbstractMesh {
  65764. /** @hidden (Backing field) */
  65765. _showBoundingBox: boolean;
  65766. /**
  65767. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65768. */
  65769. showBoundingBox: boolean;
  65770. }
  65771. }
  65772. /**
  65773. * Component responsible of rendering the bounding box of the meshes in a scene.
  65774. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65775. */
  65776. export class BoundingBoxRenderer implements ISceneComponent {
  65777. /**
  65778. * The component name helpfull to identify the component in the list of scene components.
  65779. */
  65780. readonly name: string;
  65781. /**
  65782. * The scene the component belongs to.
  65783. */
  65784. scene: Scene;
  65785. /**
  65786. * Color of the bounding box lines placed in front of an object
  65787. */
  65788. frontColor: Color3;
  65789. /**
  65790. * Color of the bounding box lines placed behind an object
  65791. */
  65792. backColor: Color3;
  65793. /**
  65794. * Defines if the renderer should show the back lines or not
  65795. */
  65796. showBackLines: boolean;
  65797. /**
  65798. * @hidden
  65799. */
  65800. renderList: SmartArray<BoundingBox>;
  65801. private _colorShader;
  65802. private _vertexBuffers;
  65803. private _indexBuffer;
  65804. private _fillIndexBuffer;
  65805. private _fillIndexData;
  65806. /**
  65807. * Instantiates a new bounding box renderer in a scene.
  65808. * @param scene the scene the renderer renders in
  65809. */
  65810. constructor(scene: Scene);
  65811. /**
  65812. * Registers the component in a given scene
  65813. */
  65814. register(): void;
  65815. private _evaluateSubMesh;
  65816. private _activeMesh;
  65817. private _prepareRessources;
  65818. private _createIndexBuffer;
  65819. /**
  65820. * Rebuilds the elements related to this component in case of
  65821. * context lost for instance.
  65822. */
  65823. rebuild(): void;
  65824. /**
  65825. * @hidden
  65826. */
  65827. reset(): void;
  65828. /**
  65829. * Render the bounding boxes of a specific rendering group
  65830. * @param renderingGroupId defines the rendering group to render
  65831. */
  65832. render(renderingGroupId: number): void;
  65833. /**
  65834. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65835. * @param mesh Define the mesh to render the occlusion bounding box for
  65836. */
  65837. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65838. /**
  65839. * Dispose and release the resources attached to this renderer.
  65840. */
  65841. dispose(): void;
  65842. }
  65843. }
  65844. declare module "babylonjs/Shaders/depth.fragment" {
  65845. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65846. /** @hidden */
  65847. export var depthPixelShader: {
  65848. name: string;
  65849. shader: string;
  65850. };
  65851. }
  65852. declare module "babylonjs/Rendering/depthRenderer" {
  65853. import { Nullable } from "babylonjs/types";
  65854. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65855. import { Scene } from "babylonjs/scene";
  65856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65857. import { Camera } from "babylonjs/Cameras/camera";
  65858. import "babylonjs/Shaders/depth.fragment";
  65859. import "babylonjs/Shaders/depth.vertex";
  65860. /**
  65861. * This represents a depth renderer in Babylon.
  65862. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65863. */
  65864. export class DepthRenderer {
  65865. private _scene;
  65866. private _depthMap;
  65867. private _effect;
  65868. private readonly _storeNonLinearDepth;
  65869. private readonly _clearColor;
  65870. /** Get if the depth renderer is using packed depth or not */
  65871. readonly isPacked: boolean;
  65872. private _cachedDefines;
  65873. private _camera;
  65874. /**
  65875. * Specifiess that the depth renderer will only be used within
  65876. * the camera it is created for.
  65877. * This can help forcing its rendering during the camera processing.
  65878. */
  65879. useOnlyInActiveCamera: boolean;
  65880. /** @hidden */
  65881. static _SceneComponentInitialization: (scene: Scene) => void;
  65882. /**
  65883. * Instantiates a depth renderer
  65884. * @param scene The scene the renderer belongs to
  65885. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65886. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65887. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65888. */
  65889. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65890. /**
  65891. * Creates the depth rendering effect and checks if the effect is ready.
  65892. * @param subMesh The submesh to be used to render the depth map of
  65893. * @param useInstances If multiple world instances should be used
  65894. * @returns if the depth renderer is ready to render the depth map
  65895. */
  65896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65897. /**
  65898. * Gets the texture which the depth map will be written to.
  65899. * @returns The depth map texture
  65900. */
  65901. getDepthMap(): RenderTargetTexture;
  65902. /**
  65903. * Disposes of the depth renderer.
  65904. */
  65905. dispose(): void;
  65906. }
  65907. }
  65908. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65909. import { Nullable } from "babylonjs/types";
  65910. import { Scene } from "babylonjs/scene";
  65911. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65912. import { Camera } from "babylonjs/Cameras/camera";
  65913. import { ISceneComponent } from "babylonjs/sceneComponent";
  65914. module "babylonjs/scene" {
  65915. interface Scene {
  65916. /** @hidden (Backing field) */
  65917. _depthRenderer: {
  65918. [id: string]: DepthRenderer;
  65919. };
  65920. /**
  65921. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65922. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65923. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65924. * @returns the created depth renderer
  65925. */
  65926. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65927. /**
  65928. * Disables a depth renderer for a given camera
  65929. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65930. */
  65931. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65932. }
  65933. }
  65934. /**
  65935. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65936. * in several rendering techniques.
  65937. */
  65938. export class DepthRendererSceneComponent implements ISceneComponent {
  65939. /**
  65940. * The component name helpfull to identify the component in the list of scene components.
  65941. */
  65942. readonly name: string;
  65943. /**
  65944. * The scene the component belongs to.
  65945. */
  65946. scene: Scene;
  65947. /**
  65948. * Creates a new instance of the component for the given scene
  65949. * @param scene Defines the scene to register the component in
  65950. */
  65951. constructor(scene: Scene);
  65952. /**
  65953. * Registers the component in a given scene
  65954. */
  65955. register(): void;
  65956. /**
  65957. * Rebuilds the elements related to this component in case of
  65958. * context lost for instance.
  65959. */
  65960. rebuild(): void;
  65961. /**
  65962. * Disposes the component and the associated ressources
  65963. */
  65964. dispose(): void;
  65965. private _gatherRenderTargets;
  65966. private _gatherActiveCameraRenderTargets;
  65967. }
  65968. }
  65969. declare module "babylonjs/Shaders/outline.fragment" {
  65970. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65971. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65972. /** @hidden */
  65973. export var outlinePixelShader: {
  65974. name: string;
  65975. shader: string;
  65976. };
  65977. }
  65978. declare module "babylonjs/Shaders/outline.vertex" {
  65979. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65982. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65983. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65984. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65985. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65986. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65987. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65988. /** @hidden */
  65989. export var outlineVertexShader: {
  65990. name: string;
  65991. shader: string;
  65992. };
  65993. }
  65994. declare module "babylonjs/Rendering/outlineRenderer" {
  65995. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65996. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65997. import { Scene } from "babylonjs/scene";
  65998. import { ISceneComponent } from "babylonjs/sceneComponent";
  65999. import "babylonjs/Shaders/outline.fragment";
  66000. import "babylonjs/Shaders/outline.vertex";
  66001. module "babylonjs/scene" {
  66002. interface Scene {
  66003. /** @hidden */
  66004. _outlineRenderer: OutlineRenderer;
  66005. /**
  66006. * Gets the outline renderer associated with the scene
  66007. * @returns a OutlineRenderer
  66008. */
  66009. getOutlineRenderer(): OutlineRenderer;
  66010. }
  66011. }
  66012. module "babylonjs/Meshes/abstractMesh" {
  66013. interface AbstractMesh {
  66014. /** @hidden (Backing field) */
  66015. _renderOutline: boolean;
  66016. /**
  66017. * Gets or sets a boolean indicating if the outline must be rendered as well
  66018. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66019. */
  66020. renderOutline: boolean;
  66021. /** @hidden (Backing field) */
  66022. _renderOverlay: boolean;
  66023. /**
  66024. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66025. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66026. */
  66027. renderOverlay: boolean;
  66028. }
  66029. }
  66030. /**
  66031. * This class is responsible to draw bothe outline/overlay of meshes.
  66032. * It should not be used directly but through the available method on mesh.
  66033. */
  66034. export class OutlineRenderer implements ISceneComponent {
  66035. /**
  66036. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66037. */
  66038. private static _StencilReference;
  66039. /**
  66040. * The name of the component. Each component must have a unique name.
  66041. */
  66042. name: string;
  66043. /**
  66044. * The scene the component belongs to.
  66045. */
  66046. scene: Scene;
  66047. /**
  66048. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66049. */
  66050. zOffset: number;
  66051. private _engine;
  66052. private _effect;
  66053. private _cachedDefines;
  66054. private _savedDepthWrite;
  66055. /**
  66056. * Instantiates a new outline renderer. (There could be only one per scene).
  66057. * @param scene Defines the scene it belongs to
  66058. */
  66059. constructor(scene: Scene);
  66060. /**
  66061. * Register the component to one instance of a scene.
  66062. */
  66063. register(): void;
  66064. /**
  66065. * Rebuilds the elements related to this component in case of
  66066. * context lost for instance.
  66067. */
  66068. rebuild(): void;
  66069. /**
  66070. * Disposes the component and the associated ressources.
  66071. */
  66072. dispose(): void;
  66073. /**
  66074. * Renders the outline in the canvas.
  66075. * @param subMesh Defines the sumesh to render
  66076. * @param batch Defines the batch of meshes in case of instances
  66077. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66078. */
  66079. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66080. /**
  66081. * Returns whether or not the outline renderer is ready for a given submesh.
  66082. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66083. * @param subMesh Defines the submesh to check readyness for
  66084. * @param useInstances Defines wheter wee are trying to render instances or not
  66085. * @returns true if ready otherwise false
  66086. */
  66087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66088. private _beforeRenderingMesh;
  66089. private _afterRenderingMesh;
  66090. }
  66091. }
  66092. declare module "babylonjs/Rendering/index" {
  66093. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66094. export * from "babylonjs/Rendering/depthRenderer";
  66095. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66096. export * from "babylonjs/Rendering/edgesRenderer";
  66097. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66098. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66099. export * from "babylonjs/Rendering/outlineRenderer";
  66100. export * from "babylonjs/Rendering/renderingGroup";
  66101. export * from "babylonjs/Rendering/renderingManager";
  66102. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66103. }
  66104. declare module "babylonjs/Sprites/spritePackedManager" {
  66105. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66106. import { Scene } from "babylonjs/scene";
  66107. /**
  66108. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66109. * @see http://doc.babylonjs.com/babylon101/sprites
  66110. */
  66111. export class SpritePackedManager extends SpriteManager {
  66112. /** defines the packed manager's name */
  66113. name: string;
  66114. /**
  66115. * Creates a new sprite manager from a packed sprite sheet
  66116. * @param name defines the manager's name
  66117. * @param imgUrl defines the sprite sheet url
  66118. * @param capacity defines the maximum allowed number of sprites
  66119. * @param scene defines the hosting scene
  66120. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66121. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66122. * @param samplingMode defines the smapling mode to use with spritesheet
  66123. * @param fromPacked set to true; do not alter
  66124. */
  66125. constructor(
  66126. /** defines the packed manager's name */
  66127. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66128. }
  66129. }
  66130. declare module "babylonjs/Sprites/index" {
  66131. export * from "babylonjs/Sprites/sprite";
  66132. export * from "babylonjs/Sprites/spriteManager";
  66133. export * from "babylonjs/Sprites/spritePackedManager";
  66134. export * from "babylonjs/Sprites/spriteSceneComponent";
  66135. }
  66136. declare module "babylonjs/States/index" {
  66137. export * from "babylonjs/States/alphaCullingState";
  66138. export * from "babylonjs/States/depthCullingState";
  66139. export * from "babylonjs/States/stencilState";
  66140. }
  66141. declare module "babylonjs/Misc/assetsManager" {
  66142. import { Scene } from "babylonjs/scene";
  66143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66144. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66145. import { Skeleton } from "babylonjs/Bones/skeleton";
  66146. import { Observable } from "babylonjs/Misc/observable";
  66147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66148. import { Texture } from "babylonjs/Materials/Textures/texture";
  66149. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66150. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66151. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66152. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66153. /**
  66154. * Defines the list of states available for a task inside a AssetsManager
  66155. */
  66156. export enum AssetTaskState {
  66157. /**
  66158. * Initialization
  66159. */
  66160. INIT = 0,
  66161. /**
  66162. * Running
  66163. */
  66164. RUNNING = 1,
  66165. /**
  66166. * Done
  66167. */
  66168. DONE = 2,
  66169. /**
  66170. * Error
  66171. */
  66172. ERROR = 3
  66173. }
  66174. /**
  66175. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66176. */
  66177. export abstract class AbstractAssetTask {
  66178. /**
  66179. * Task name
  66180. */ name: string;
  66181. /**
  66182. * Callback called when the task is successful
  66183. */
  66184. onSuccess: (task: any) => void;
  66185. /**
  66186. * Callback called when the task is not successful
  66187. */
  66188. onError: (task: any, message?: string, exception?: any) => void;
  66189. /**
  66190. * Creates a new AssetsManager
  66191. * @param name defines the name of the task
  66192. */
  66193. constructor(
  66194. /**
  66195. * Task name
  66196. */ name: string);
  66197. private _isCompleted;
  66198. private _taskState;
  66199. private _errorObject;
  66200. /**
  66201. * Get if the task is completed
  66202. */
  66203. readonly isCompleted: boolean;
  66204. /**
  66205. * Gets the current state of the task
  66206. */
  66207. readonly taskState: AssetTaskState;
  66208. /**
  66209. * Gets the current error object (if task is in error)
  66210. */
  66211. readonly errorObject: {
  66212. message?: string;
  66213. exception?: any;
  66214. };
  66215. /**
  66216. * Internal only
  66217. * @hidden
  66218. */
  66219. _setErrorObject(message?: string, exception?: any): void;
  66220. /**
  66221. * Execute the current task
  66222. * @param scene defines the scene where you want your assets to be loaded
  66223. * @param onSuccess is a callback called when the task is successfully executed
  66224. * @param onError is a callback called if an error occurs
  66225. */
  66226. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66227. /**
  66228. * Execute the current task
  66229. * @param scene defines the scene where you want your assets to be loaded
  66230. * @param onSuccess is a callback called when the task is successfully executed
  66231. * @param onError is a callback called if an error occurs
  66232. */
  66233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66234. /**
  66235. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66236. * This can be used with failed tasks that have the reason for failure fixed.
  66237. */
  66238. reset(): void;
  66239. private onErrorCallback;
  66240. private onDoneCallback;
  66241. }
  66242. /**
  66243. * Define the interface used by progress events raised during assets loading
  66244. */
  66245. export interface IAssetsProgressEvent {
  66246. /**
  66247. * Defines the number of remaining tasks to process
  66248. */
  66249. remainingCount: number;
  66250. /**
  66251. * Defines the total number of tasks
  66252. */
  66253. totalCount: number;
  66254. /**
  66255. * Defines the task that was just processed
  66256. */
  66257. task: AbstractAssetTask;
  66258. }
  66259. /**
  66260. * Class used to share progress information about assets loading
  66261. */
  66262. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66263. /**
  66264. * Defines the number of remaining tasks to process
  66265. */
  66266. remainingCount: number;
  66267. /**
  66268. * Defines the total number of tasks
  66269. */
  66270. totalCount: number;
  66271. /**
  66272. * Defines the task that was just processed
  66273. */
  66274. task: AbstractAssetTask;
  66275. /**
  66276. * Creates a AssetsProgressEvent
  66277. * @param remainingCount defines the number of remaining tasks to process
  66278. * @param totalCount defines the total number of tasks
  66279. * @param task defines the task that was just processed
  66280. */
  66281. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66282. }
  66283. /**
  66284. * Define a task used by AssetsManager to load meshes
  66285. */
  66286. export class MeshAssetTask extends AbstractAssetTask {
  66287. /**
  66288. * Defines the name of the task
  66289. */
  66290. name: string;
  66291. /**
  66292. * Defines the list of mesh's names you want to load
  66293. */
  66294. meshesNames: any;
  66295. /**
  66296. * Defines the root url to use as a base to load your meshes and associated resources
  66297. */
  66298. rootUrl: string;
  66299. /**
  66300. * Defines the filename of the scene to load from
  66301. */
  66302. sceneFilename: string;
  66303. /**
  66304. * Gets the list of loaded meshes
  66305. */
  66306. loadedMeshes: Array<AbstractMesh>;
  66307. /**
  66308. * Gets the list of loaded particle systems
  66309. */
  66310. loadedParticleSystems: Array<IParticleSystem>;
  66311. /**
  66312. * Gets the list of loaded skeletons
  66313. */
  66314. loadedSkeletons: Array<Skeleton>;
  66315. /**
  66316. * Gets the list of loaded animation groups
  66317. */
  66318. loadedAnimationGroups: Array<AnimationGroup>;
  66319. /**
  66320. * Callback called when the task is successful
  66321. */
  66322. onSuccess: (task: MeshAssetTask) => void;
  66323. /**
  66324. * Callback called when the task is successful
  66325. */
  66326. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66327. /**
  66328. * Creates a new MeshAssetTask
  66329. * @param name defines the name of the task
  66330. * @param meshesNames defines the list of mesh's names you want to load
  66331. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66332. * @param sceneFilename defines the filename of the scene to load from
  66333. */
  66334. constructor(
  66335. /**
  66336. * Defines the name of the task
  66337. */
  66338. name: string,
  66339. /**
  66340. * Defines the list of mesh's names you want to load
  66341. */
  66342. meshesNames: any,
  66343. /**
  66344. * Defines the root url to use as a base to load your meshes and associated resources
  66345. */
  66346. rootUrl: string,
  66347. /**
  66348. * Defines the filename of the scene to load from
  66349. */
  66350. sceneFilename: string);
  66351. /**
  66352. * Execute the current task
  66353. * @param scene defines the scene where you want your assets to be loaded
  66354. * @param onSuccess is a callback called when the task is successfully executed
  66355. * @param onError is a callback called if an error occurs
  66356. */
  66357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66358. }
  66359. /**
  66360. * Define a task used by AssetsManager to load text content
  66361. */
  66362. export class TextFileAssetTask extends AbstractAssetTask {
  66363. /**
  66364. * Defines the name of the task
  66365. */
  66366. name: string;
  66367. /**
  66368. * Defines the location of the file to load
  66369. */
  66370. url: string;
  66371. /**
  66372. * Gets the loaded text string
  66373. */
  66374. text: string;
  66375. /**
  66376. * Callback called when the task is successful
  66377. */
  66378. onSuccess: (task: TextFileAssetTask) => void;
  66379. /**
  66380. * Callback called when the task is successful
  66381. */
  66382. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66383. /**
  66384. * Creates a new TextFileAssetTask object
  66385. * @param name defines the name of the task
  66386. * @param url defines the location of the file to load
  66387. */
  66388. constructor(
  66389. /**
  66390. * Defines the name of the task
  66391. */
  66392. name: string,
  66393. /**
  66394. * Defines the location of the file to load
  66395. */
  66396. url: string);
  66397. /**
  66398. * Execute the current task
  66399. * @param scene defines the scene where you want your assets to be loaded
  66400. * @param onSuccess is a callback called when the task is successfully executed
  66401. * @param onError is a callback called if an error occurs
  66402. */
  66403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66404. }
  66405. /**
  66406. * Define a task used by AssetsManager to load binary data
  66407. */
  66408. export class BinaryFileAssetTask extends AbstractAssetTask {
  66409. /**
  66410. * Defines the name of the task
  66411. */
  66412. name: string;
  66413. /**
  66414. * Defines the location of the file to load
  66415. */
  66416. url: string;
  66417. /**
  66418. * Gets the lodaded data (as an array buffer)
  66419. */
  66420. data: ArrayBuffer;
  66421. /**
  66422. * Callback called when the task is successful
  66423. */
  66424. onSuccess: (task: BinaryFileAssetTask) => void;
  66425. /**
  66426. * Callback called when the task is successful
  66427. */
  66428. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66429. /**
  66430. * Creates a new BinaryFileAssetTask object
  66431. * @param name defines the name of the new task
  66432. * @param url defines the location of the file to load
  66433. */
  66434. constructor(
  66435. /**
  66436. * Defines the name of the task
  66437. */
  66438. name: string,
  66439. /**
  66440. * Defines the location of the file to load
  66441. */
  66442. url: string);
  66443. /**
  66444. * Execute the current task
  66445. * @param scene defines the scene where you want your assets to be loaded
  66446. * @param onSuccess is a callback called when the task is successfully executed
  66447. * @param onError is a callback called if an error occurs
  66448. */
  66449. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66450. }
  66451. /**
  66452. * Define a task used by AssetsManager to load images
  66453. */
  66454. export class ImageAssetTask extends AbstractAssetTask {
  66455. /**
  66456. * Defines the name of the task
  66457. */
  66458. name: string;
  66459. /**
  66460. * Defines the location of the image to load
  66461. */
  66462. url: string;
  66463. /**
  66464. * Gets the loaded images
  66465. */
  66466. image: HTMLImageElement;
  66467. /**
  66468. * Callback called when the task is successful
  66469. */
  66470. onSuccess: (task: ImageAssetTask) => void;
  66471. /**
  66472. * Callback called when the task is successful
  66473. */
  66474. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66475. /**
  66476. * Creates a new ImageAssetTask
  66477. * @param name defines the name of the task
  66478. * @param url defines the location of the image to load
  66479. */
  66480. constructor(
  66481. /**
  66482. * Defines the name of the task
  66483. */
  66484. name: string,
  66485. /**
  66486. * Defines the location of the image to load
  66487. */
  66488. url: string);
  66489. /**
  66490. * Execute the current task
  66491. * @param scene defines the scene where you want your assets to be loaded
  66492. * @param onSuccess is a callback called when the task is successfully executed
  66493. * @param onError is a callback called if an error occurs
  66494. */
  66495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66496. }
  66497. /**
  66498. * Defines the interface used by texture loading tasks
  66499. */
  66500. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66501. /**
  66502. * Gets the loaded texture
  66503. */
  66504. texture: TEX;
  66505. }
  66506. /**
  66507. * Define a task used by AssetsManager to load 2D textures
  66508. */
  66509. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66510. /**
  66511. * Defines the name of the task
  66512. */
  66513. name: string;
  66514. /**
  66515. * Defines the location of the file to load
  66516. */
  66517. url: string;
  66518. /**
  66519. * Defines if mipmap should not be generated (default is false)
  66520. */
  66521. noMipmap?: boolean | undefined;
  66522. /**
  66523. * Defines if texture must be inverted on Y axis (default is false)
  66524. */
  66525. invertY?: boolean | undefined;
  66526. /**
  66527. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66528. */
  66529. samplingMode: number;
  66530. /**
  66531. * Gets the loaded texture
  66532. */
  66533. texture: Texture;
  66534. /**
  66535. * Callback called when the task is successful
  66536. */
  66537. onSuccess: (task: TextureAssetTask) => void;
  66538. /**
  66539. * Callback called when the task is successful
  66540. */
  66541. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66542. /**
  66543. * Creates a new TextureAssetTask object
  66544. * @param name defines the name of the task
  66545. * @param url defines the location of the file to load
  66546. * @param noMipmap defines if mipmap should not be generated (default is false)
  66547. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66548. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66549. */
  66550. constructor(
  66551. /**
  66552. * Defines the name of the task
  66553. */
  66554. name: string,
  66555. /**
  66556. * Defines the location of the file to load
  66557. */
  66558. url: string,
  66559. /**
  66560. * Defines if mipmap should not be generated (default is false)
  66561. */
  66562. noMipmap?: boolean | undefined,
  66563. /**
  66564. * Defines if texture must be inverted on Y axis (default is false)
  66565. */
  66566. invertY?: boolean | undefined,
  66567. /**
  66568. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66569. */
  66570. samplingMode?: number);
  66571. /**
  66572. * Execute the current task
  66573. * @param scene defines the scene where you want your assets to be loaded
  66574. * @param onSuccess is a callback called when the task is successfully executed
  66575. * @param onError is a callback called if an error occurs
  66576. */
  66577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66578. }
  66579. /**
  66580. * Define a task used by AssetsManager to load cube textures
  66581. */
  66582. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66583. /**
  66584. * Defines the name of the task
  66585. */
  66586. name: string;
  66587. /**
  66588. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66589. */
  66590. url: string;
  66591. /**
  66592. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66593. */
  66594. extensions?: string[] | undefined;
  66595. /**
  66596. * Defines if mipmaps should not be generated (default is false)
  66597. */
  66598. noMipmap?: boolean | undefined;
  66599. /**
  66600. * Defines the explicit list of files (undefined by default)
  66601. */
  66602. files?: string[] | undefined;
  66603. /**
  66604. * Gets the loaded texture
  66605. */
  66606. texture: CubeTexture;
  66607. /**
  66608. * Callback called when the task is successful
  66609. */
  66610. onSuccess: (task: CubeTextureAssetTask) => void;
  66611. /**
  66612. * Callback called when the task is successful
  66613. */
  66614. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66615. /**
  66616. * Creates a new CubeTextureAssetTask
  66617. * @param name defines the name of the task
  66618. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66619. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66620. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66621. * @param files defines the explicit list of files (undefined by default)
  66622. */
  66623. constructor(
  66624. /**
  66625. * Defines the name of the task
  66626. */
  66627. name: string,
  66628. /**
  66629. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66630. */
  66631. url: string,
  66632. /**
  66633. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66634. */
  66635. extensions?: string[] | undefined,
  66636. /**
  66637. * Defines if mipmaps should not be generated (default is false)
  66638. */
  66639. noMipmap?: boolean | undefined,
  66640. /**
  66641. * Defines the explicit list of files (undefined by default)
  66642. */
  66643. files?: string[] | undefined);
  66644. /**
  66645. * Execute the current task
  66646. * @param scene defines the scene where you want your assets to be loaded
  66647. * @param onSuccess is a callback called when the task is successfully executed
  66648. * @param onError is a callback called if an error occurs
  66649. */
  66650. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66651. }
  66652. /**
  66653. * Define a task used by AssetsManager to load HDR cube textures
  66654. */
  66655. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66656. /**
  66657. * Defines the name of the task
  66658. */
  66659. name: string;
  66660. /**
  66661. * Defines the location of the file to load
  66662. */
  66663. url: string;
  66664. /**
  66665. * Defines the desired size (the more it increases the longer the generation will be)
  66666. */
  66667. size: number;
  66668. /**
  66669. * Defines if mipmaps should not be generated (default is false)
  66670. */
  66671. noMipmap: boolean;
  66672. /**
  66673. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66674. */
  66675. generateHarmonics: boolean;
  66676. /**
  66677. * 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)
  66678. */
  66679. gammaSpace: boolean;
  66680. /**
  66681. * Internal Use Only
  66682. */
  66683. reserved: boolean;
  66684. /**
  66685. * Gets the loaded texture
  66686. */
  66687. texture: HDRCubeTexture;
  66688. /**
  66689. * Callback called when the task is successful
  66690. */
  66691. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66692. /**
  66693. * Callback called when the task is successful
  66694. */
  66695. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66696. /**
  66697. * Creates a new HDRCubeTextureAssetTask object
  66698. * @param name defines the name of the task
  66699. * @param url defines the location of the file to load
  66700. * @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.
  66701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66702. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66703. * @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)
  66704. * @param reserved Internal use only
  66705. */
  66706. constructor(
  66707. /**
  66708. * Defines the name of the task
  66709. */
  66710. name: string,
  66711. /**
  66712. * Defines the location of the file to load
  66713. */
  66714. url: string,
  66715. /**
  66716. * Defines the desired size (the more it increases the longer the generation will be)
  66717. */
  66718. size: number,
  66719. /**
  66720. * Defines if mipmaps should not be generated (default is false)
  66721. */
  66722. noMipmap?: boolean,
  66723. /**
  66724. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66725. */
  66726. generateHarmonics?: boolean,
  66727. /**
  66728. * 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)
  66729. */
  66730. gammaSpace?: boolean,
  66731. /**
  66732. * Internal Use Only
  66733. */
  66734. reserved?: boolean);
  66735. /**
  66736. * Execute the current task
  66737. * @param scene defines the scene where you want your assets to be loaded
  66738. * @param onSuccess is a callback called when the task is successfully executed
  66739. * @param onError is a callback called if an error occurs
  66740. */
  66741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66742. }
  66743. /**
  66744. * Define a task used by AssetsManager to load Equirectangular cube textures
  66745. */
  66746. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66747. /**
  66748. * Defines the name of the task
  66749. */
  66750. name: string;
  66751. /**
  66752. * Defines the location of the file to load
  66753. */
  66754. url: string;
  66755. /**
  66756. * Defines the desired size (the more it increases the longer the generation will be)
  66757. */
  66758. size: number;
  66759. /**
  66760. * Defines if mipmaps should not be generated (default is false)
  66761. */
  66762. noMipmap: boolean;
  66763. /**
  66764. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66765. * but the standard material would require them in Gamma space) (default is true)
  66766. */
  66767. gammaSpace: boolean;
  66768. /**
  66769. * Gets the loaded texture
  66770. */
  66771. texture: EquiRectangularCubeTexture;
  66772. /**
  66773. * Callback called when the task is successful
  66774. */
  66775. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66776. /**
  66777. * Callback called when the task is successful
  66778. */
  66779. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66780. /**
  66781. * Creates a new EquiRectangularCubeTextureAssetTask object
  66782. * @param name defines the name of the task
  66783. * @param url defines the location of the file to load
  66784. * @param size defines the desired size (the more it increases the longer the generation will be)
  66785. * If the size is omitted this implies you are using a preprocessed cubemap.
  66786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66787. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66788. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66789. * (default is true)
  66790. */
  66791. constructor(
  66792. /**
  66793. * Defines the name of the task
  66794. */
  66795. name: string,
  66796. /**
  66797. * Defines the location of the file to load
  66798. */
  66799. url: string,
  66800. /**
  66801. * Defines the desired size (the more it increases the longer the generation will be)
  66802. */
  66803. size: number,
  66804. /**
  66805. * Defines if mipmaps should not be generated (default is false)
  66806. */
  66807. noMipmap?: boolean,
  66808. /**
  66809. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66810. * but the standard material would require them in Gamma space) (default is true)
  66811. */
  66812. gammaSpace?: boolean);
  66813. /**
  66814. * Execute the current task
  66815. * @param scene defines the scene where you want your assets to be loaded
  66816. * @param onSuccess is a callback called when the task is successfully executed
  66817. * @param onError is a callback called if an error occurs
  66818. */
  66819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66820. }
  66821. /**
  66822. * This class can be used to easily import assets into a scene
  66823. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66824. */
  66825. export class AssetsManager {
  66826. private _scene;
  66827. private _isLoading;
  66828. protected _tasks: AbstractAssetTask[];
  66829. protected _waitingTasksCount: number;
  66830. protected _totalTasksCount: number;
  66831. /**
  66832. * Callback called when all tasks are processed
  66833. */
  66834. onFinish: (tasks: AbstractAssetTask[]) => void;
  66835. /**
  66836. * Callback called when a task is successful
  66837. */
  66838. onTaskSuccess: (task: AbstractAssetTask) => void;
  66839. /**
  66840. * Callback called when a task had an error
  66841. */
  66842. onTaskError: (task: AbstractAssetTask) => void;
  66843. /**
  66844. * Callback called when a task is done (whatever the result is)
  66845. */
  66846. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66847. /**
  66848. * Observable called when all tasks are processed
  66849. */
  66850. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66851. /**
  66852. * Observable called when a task had an error
  66853. */
  66854. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66855. /**
  66856. * Observable called when all tasks were executed
  66857. */
  66858. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66859. /**
  66860. * Observable called when a task is done (whatever the result is)
  66861. */
  66862. onProgressObservable: Observable<IAssetsProgressEvent>;
  66863. /**
  66864. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66866. */
  66867. useDefaultLoadingScreen: boolean;
  66868. /**
  66869. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66870. * when all assets have been downloaded.
  66871. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66872. */
  66873. autoHideLoadingUI: boolean;
  66874. /**
  66875. * Creates a new AssetsManager
  66876. * @param scene defines the scene to work on
  66877. */
  66878. constructor(scene: Scene);
  66879. /**
  66880. * Add a MeshAssetTask to the list of active tasks
  66881. * @param taskName defines the name of the new task
  66882. * @param meshesNames defines the name of meshes to load
  66883. * @param rootUrl defines the root url to use to locate files
  66884. * @param sceneFilename defines the filename of the scene file
  66885. * @returns a new MeshAssetTask object
  66886. */
  66887. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66888. /**
  66889. * Add a TextFileAssetTask to the list of active tasks
  66890. * @param taskName defines the name of the new task
  66891. * @param url defines the url of the file to load
  66892. * @returns a new TextFileAssetTask object
  66893. */
  66894. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66895. /**
  66896. * Add a BinaryFileAssetTask to the list of active tasks
  66897. * @param taskName defines the name of the new task
  66898. * @param url defines the url of the file to load
  66899. * @returns a new BinaryFileAssetTask object
  66900. */
  66901. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66902. /**
  66903. * Add a ImageAssetTask to the list of active tasks
  66904. * @param taskName defines the name of the new task
  66905. * @param url defines the url of the file to load
  66906. * @returns a new ImageAssetTask object
  66907. */
  66908. addImageTask(taskName: string, url: string): ImageAssetTask;
  66909. /**
  66910. * Add a TextureAssetTask to the list of active tasks
  66911. * @param taskName defines the name of the new task
  66912. * @param url defines the url of the file to load
  66913. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66914. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66915. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66916. * @returns a new TextureAssetTask object
  66917. */
  66918. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66919. /**
  66920. * Add a CubeTextureAssetTask to the list of active tasks
  66921. * @param taskName defines the name of the new task
  66922. * @param url defines the url of the file to load
  66923. * @param extensions defines the extension to use to load the cube map (can be null)
  66924. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66925. * @param files defines the list of files to load (can be null)
  66926. * @returns a new CubeTextureAssetTask object
  66927. */
  66928. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66929. /**
  66930. *
  66931. * Add a HDRCubeTextureAssetTask 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. * @param size defines the size you want for the cubemap (can be null)
  66935. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66936. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66937. * @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)
  66938. * @param reserved Internal use only
  66939. * @returns a new HDRCubeTextureAssetTask object
  66940. */
  66941. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66942. /**
  66943. *
  66944. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66945. * @param taskName defines the name of the new task
  66946. * @param url defines the url of the file to load
  66947. * @param size defines the size you want for the cubemap (can be null)
  66948. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66949. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66950. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66951. * @returns a new EquiRectangularCubeTextureAssetTask object
  66952. */
  66953. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66954. /**
  66955. * Remove a task from the assets manager.
  66956. * @param task the task to remove
  66957. */
  66958. removeTask(task: AbstractAssetTask): void;
  66959. private _decreaseWaitingTasksCount;
  66960. private _runTask;
  66961. /**
  66962. * Reset the AssetsManager and remove all tasks
  66963. * @return the current instance of the AssetsManager
  66964. */
  66965. reset(): AssetsManager;
  66966. /**
  66967. * Start the loading process
  66968. * @return the current instance of the AssetsManager
  66969. */
  66970. load(): AssetsManager;
  66971. /**
  66972. * Start the loading process as an async operation
  66973. * @return a promise returning the list of failed tasks
  66974. */
  66975. loadAsync(): Promise<void>;
  66976. }
  66977. }
  66978. declare module "babylonjs/Misc/deferred" {
  66979. /**
  66980. * Wrapper class for promise with external resolve and reject.
  66981. */
  66982. export class Deferred<T> {
  66983. /**
  66984. * The promise associated with this deferred object.
  66985. */
  66986. readonly promise: Promise<T>;
  66987. private _resolve;
  66988. private _reject;
  66989. /**
  66990. * The resolve method of the promise associated with this deferred object.
  66991. */
  66992. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66993. /**
  66994. * The reject method of the promise associated with this deferred object.
  66995. */
  66996. readonly reject: (reason?: any) => void;
  66997. /**
  66998. * Constructor for this deferred object.
  66999. */
  67000. constructor();
  67001. }
  67002. }
  67003. declare module "babylonjs/Misc/meshExploder" {
  67004. import { Mesh } from "babylonjs/Meshes/mesh";
  67005. /**
  67006. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67007. */
  67008. export class MeshExploder {
  67009. private _centerMesh;
  67010. private _meshes;
  67011. private _meshesOrigins;
  67012. private _toCenterVectors;
  67013. private _scaledDirection;
  67014. private _newPosition;
  67015. private _centerPosition;
  67016. /**
  67017. * Explodes meshes from a center mesh.
  67018. * @param meshes The meshes to explode.
  67019. * @param centerMesh The mesh to be center of explosion.
  67020. */
  67021. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67022. private _setCenterMesh;
  67023. /**
  67024. * Get class name
  67025. * @returns "MeshExploder"
  67026. */
  67027. getClassName(): string;
  67028. /**
  67029. * "Exploded meshes"
  67030. * @returns Array of meshes with the centerMesh at index 0.
  67031. */
  67032. getMeshes(): Array<Mesh>;
  67033. /**
  67034. * Explodes meshes giving a specific direction
  67035. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67036. */
  67037. explode(direction?: number): void;
  67038. }
  67039. }
  67040. declare module "babylonjs/Misc/filesInput" {
  67041. import { Engine } from "babylonjs/Engines/engine";
  67042. import { Scene } from "babylonjs/scene";
  67043. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67044. /**
  67045. * Class used to help managing file picking and drag'n'drop
  67046. */
  67047. export class FilesInput {
  67048. /**
  67049. * List of files ready to be loaded
  67050. */
  67051. static readonly FilesToLoad: {
  67052. [key: string]: File;
  67053. };
  67054. /**
  67055. * Callback called when a file is processed
  67056. */
  67057. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67058. private _engine;
  67059. private _currentScene;
  67060. private _sceneLoadedCallback;
  67061. private _progressCallback;
  67062. private _additionalRenderLoopLogicCallback;
  67063. private _textureLoadingCallback;
  67064. private _startingProcessingFilesCallback;
  67065. private _onReloadCallback;
  67066. private _errorCallback;
  67067. private _elementToMonitor;
  67068. private _sceneFileToLoad;
  67069. private _filesToLoad;
  67070. /**
  67071. * Creates a new FilesInput
  67072. * @param engine defines the rendering engine
  67073. * @param scene defines the hosting scene
  67074. * @param sceneLoadedCallback callback called when scene is loaded
  67075. * @param progressCallback callback called to track progress
  67076. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67077. * @param textureLoadingCallback callback called when a texture is loading
  67078. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67079. * @param onReloadCallback callback called when a reload is requested
  67080. * @param errorCallback callback call if an error occurs
  67081. */
  67082. 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);
  67083. private _dragEnterHandler;
  67084. private _dragOverHandler;
  67085. private _dropHandler;
  67086. /**
  67087. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67088. * @param elementToMonitor defines the DOM element to track
  67089. */
  67090. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67091. /**
  67092. * Release all associated resources
  67093. */
  67094. dispose(): void;
  67095. private renderFunction;
  67096. private drag;
  67097. private drop;
  67098. private _traverseFolder;
  67099. private _processFiles;
  67100. /**
  67101. * Load files from a drop event
  67102. * @param event defines the drop event to use as source
  67103. */
  67104. loadFiles(event: any): void;
  67105. private _processReload;
  67106. /**
  67107. * Reload the current scene from the loaded files
  67108. */
  67109. reload(): void;
  67110. }
  67111. }
  67112. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67113. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67114. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67115. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67116. }
  67117. declare module "babylonjs/Misc/sceneOptimizer" {
  67118. import { Scene, IDisposable } from "babylonjs/scene";
  67119. import { Observable } from "babylonjs/Misc/observable";
  67120. /**
  67121. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67123. */
  67124. export class SceneOptimization {
  67125. /**
  67126. * Defines the priority of this optimization (0 by default which means first in the list)
  67127. */
  67128. priority: number;
  67129. /**
  67130. * Gets a string describing the action executed by the current optimization
  67131. * @returns description string
  67132. */
  67133. getDescription(): string;
  67134. /**
  67135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67136. * @param scene defines the current scene where to apply this optimization
  67137. * @param optimizer defines the current optimizer
  67138. * @returns true if everything that can be done was applied
  67139. */
  67140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67141. /**
  67142. * Creates the SceneOptimization object
  67143. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67144. * @param desc defines the description associated with the optimization
  67145. */
  67146. constructor(
  67147. /**
  67148. * Defines the priority of this optimization (0 by default which means first in the list)
  67149. */
  67150. priority?: number);
  67151. }
  67152. /**
  67153. * Defines an optimization used to reduce the size of render target textures
  67154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67155. */
  67156. export class TextureOptimization extends SceneOptimization {
  67157. /**
  67158. * Defines the priority of this optimization (0 by default which means first in the list)
  67159. */
  67160. priority: number;
  67161. /**
  67162. * 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
  67163. */
  67164. maximumSize: number;
  67165. /**
  67166. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67167. */
  67168. step: number;
  67169. /**
  67170. * Gets a string describing the action executed by the current optimization
  67171. * @returns description string
  67172. */
  67173. getDescription(): string;
  67174. /**
  67175. * Creates the TextureOptimization object
  67176. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67177. * @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
  67178. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67179. */
  67180. constructor(
  67181. /**
  67182. * Defines the priority of this optimization (0 by default which means first in the list)
  67183. */
  67184. priority?: number,
  67185. /**
  67186. * 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
  67187. */
  67188. maximumSize?: number,
  67189. /**
  67190. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67191. */
  67192. step?: number);
  67193. /**
  67194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67195. * @param scene defines the current scene where to apply this optimization
  67196. * @param optimizer defines the current optimizer
  67197. * @returns true if everything that can be done was applied
  67198. */
  67199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67200. }
  67201. /**
  67202. * Defines an optimization used to increase or decrease the rendering resolution
  67203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67204. */
  67205. export class HardwareScalingOptimization extends SceneOptimization {
  67206. /**
  67207. * Defines the priority of this optimization (0 by default which means first in the list)
  67208. */
  67209. priority: number;
  67210. /**
  67211. * Defines the maximum scale to use (2 by default)
  67212. */
  67213. maximumScale: number;
  67214. /**
  67215. * Defines the step to use between two passes (0.5 by default)
  67216. */
  67217. step: number;
  67218. private _currentScale;
  67219. private _directionOffset;
  67220. /**
  67221. * Gets a string describing the action executed by the current optimization
  67222. * @return description string
  67223. */
  67224. getDescription(): string;
  67225. /**
  67226. * Creates the HardwareScalingOptimization object
  67227. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67228. * @param maximumScale defines the maximum scale to use (2 by default)
  67229. * @param step defines the step to use between two passes (0.5 by default)
  67230. */
  67231. constructor(
  67232. /**
  67233. * Defines the priority of this optimization (0 by default which means first in the list)
  67234. */
  67235. priority?: number,
  67236. /**
  67237. * Defines the maximum scale to use (2 by default)
  67238. */
  67239. maximumScale?: number,
  67240. /**
  67241. * Defines the step to use between two passes (0.5 by default)
  67242. */
  67243. step?: number);
  67244. /**
  67245. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67246. * @param scene defines the current scene where to apply this optimization
  67247. * @param optimizer defines the current optimizer
  67248. * @returns true if everything that can be done was applied
  67249. */
  67250. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67251. }
  67252. /**
  67253. * Defines an optimization used to remove shadows
  67254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67255. */
  67256. export class ShadowsOptimization extends SceneOptimization {
  67257. /**
  67258. * Gets a string describing the action executed by the current optimization
  67259. * @return description string
  67260. */
  67261. getDescription(): string;
  67262. /**
  67263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67264. * @param scene defines the current scene where to apply this optimization
  67265. * @param optimizer defines the current optimizer
  67266. * @returns true if everything that can be done was applied
  67267. */
  67268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67269. }
  67270. /**
  67271. * Defines an optimization used to turn post-processes off
  67272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67273. */
  67274. export class PostProcessesOptimization extends SceneOptimization {
  67275. /**
  67276. * Gets a string describing the action executed by the current optimization
  67277. * @return description string
  67278. */
  67279. getDescription(): string;
  67280. /**
  67281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67282. * @param scene defines the current scene where to apply this optimization
  67283. * @param optimizer defines the current optimizer
  67284. * @returns true if everything that can be done was applied
  67285. */
  67286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67287. }
  67288. /**
  67289. * Defines an optimization used to turn lens flares off
  67290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67291. */
  67292. export class LensFlaresOptimization extends SceneOptimization {
  67293. /**
  67294. * Gets a string describing the action executed by the current optimization
  67295. * @return description string
  67296. */
  67297. getDescription(): string;
  67298. /**
  67299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67300. * @param scene defines the current scene where to apply this optimization
  67301. * @param optimizer defines the current optimizer
  67302. * @returns true if everything that can be done was applied
  67303. */
  67304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67305. }
  67306. /**
  67307. * Defines an optimization based on user defined callback.
  67308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67309. */
  67310. export class CustomOptimization extends SceneOptimization {
  67311. /**
  67312. * Callback called to apply the custom optimization.
  67313. */
  67314. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67315. /**
  67316. * Callback called to get custom description
  67317. */
  67318. onGetDescription: () => string;
  67319. /**
  67320. * Gets a string describing the action executed by the current optimization
  67321. * @returns description string
  67322. */
  67323. getDescription(): string;
  67324. /**
  67325. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67326. * @param scene defines the current scene where to apply this optimization
  67327. * @param optimizer defines the current optimizer
  67328. * @returns true if everything that can be done was applied
  67329. */
  67330. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67331. }
  67332. /**
  67333. * Defines an optimization used to turn particles off
  67334. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67335. */
  67336. export class ParticlesOptimization extends SceneOptimization {
  67337. /**
  67338. * Gets a string describing the action executed by the current optimization
  67339. * @return description string
  67340. */
  67341. getDescription(): string;
  67342. /**
  67343. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67344. * @param scene defines the current scene where to apply this optimization
  67345. * @param optimizer defines the current optimizer
  67346. * @returns true if everything that can be done was applied
  67347. */
  67348. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67349. }
  67350. /**
  67351. * Defines an optimization used to turn render targets off
  67352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67353. */
  67354. export class RenderTargetsOptimization extends SceneOptimization {
  67355. /**
  67356. * Gets a string describing the action executed by the current optimization
  67357. * @return description string
  67358. */
  67359. getDescription(): string;
  67360. /**
  67361. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67362. * @param scene defines the current scene where to apply this optimization
  67363. * @param optimizer defines the current optimizer
  67364. * @returns true if everything that can be done was applied
  67365. */
  67366. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67367. }
  67368. /**
  67369. * Defines an optimization used to merge meshes with compatible materials
  67370. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67371. */
  67372. export class MergeMeshesOptimization extends SceneOptimization {
  67373. private static _UpdateSelectionTree;
  67374. /**
  67375. * Gets or sets a boolean which defines if optimization octree has to be updated
  67376. */
  67377. /**
  67378. * Gets or sets a boolean which defines if optimization octree has to be updated
  67379. */
  67380. static UpdateSelectionTree: boolean;
  67381. /**
  67382. * Gets a string describing the action executed by the current optimization
  67383. * @return description string
  67384. */
  67385. getDescription(): string;
  67386. private _canBeMerged;
  67387. /**
  67388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67389. * @param scene defines the current scene where to apply this optimization
  67390. * @param optimizer defines the current optimizer
  67391. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67392. * @returns true if everything that can be done was applied
  67393. */
  67394. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67395. }
  67396. /**
  67397. * Defines a list of options used by SceneOptimizer
  67398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67399. */
  67400. export class SceneOptimizerOptions {
  67401. /**
  67402. * Defines the target frame rate to reach (60 by default)
  67403. */
  67404. targetFrameRate: number;
  67405. /**
  67406. * Defines the interval between two checkes (2000ms by default)
  67407. */
  67408. trackerDuration: number;
  67409. /**
  67410. * Gets the list of optimizations to apply
  67411. */
  67412. optimizations: SceneOptimization[];
  67413. /**
  67414. * Creates a new list of options used by SceneOptimizer
  67415. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67416. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67417. */
  67418. constructor(
  67419. /**
  67420. * Defines the target frame rate to reach (60 by default)
  67421. */
  67422. targetFrameRate?: number,
  67423. /**
  67424. * Defines the interval between two checkes (2000ms by default)
  67425. */
  67426. trackerDuration?: number);
  67427. /**
  67428. * Add a new optimization
  67429. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67430. * @returns the current SceneOptimizerOptions
  67431. */
  67432. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67433. /**
  67434. * Add a new custom optimization
  67435. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67436. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67437. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67438. * @returns the current SceneOptimizerOptions
  67439. */
  67440. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67441. /**
  67442. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67443. * @param targetFrameRate defines the target frame rate (60 by default)
  67444. * @returns a SceneOptimizerOptions object
  67445. */
  67446. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67447. /**
  67448. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67449. * @param targetFrameRate defines the target frame rate (60 by default)
  67450. * @returns a SceneOptimizerOptions object
  67451. */
  67452. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67453. /**
  67454. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67455. * @param targetFrameRate defines the target frame rate (60 by default)
  67456. * @returns a SceneOptimizerOptions object
  67457. */
  67458. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67459. }
  67460. /**
  67461. * Class used to run optimizations in order to reach a target frame rate
  67462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67463. */
  67464. export class SceneOptimizer implements IDisposable {
  67465. private _isRunning;
  67466. private _options;
  67467. private _scene;
  67468. private _currentPriorityLevel;
  67469. private _targetFrameRate;
  67470. private _trackerDuration;
  67471. private _currentFrameRate;
  67472. private _sceneDisposeObserver;
  67473. private _improvementMode;
  67474. /**
  67475. * Defines an observable called when the optimizer reaches the target frame rate
  67476. */
  67477. onSuccessObservable: Observable<SceneOptimizer>;
  67478. /**
  67479. * Defines an observable called when the optimizer enables an optimization
  67480. */
  67481. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67482. /**
  67483. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67484. */
  67485. onFailureObservable: Observable<SceneOptimizer>;
  67486. /**
  67487. * Gets a boolean indicating if the optimizer is in improvement mode
  67488. */
  67489. readonly isInImprovementMode: boolean;
  67490. /**
  67491. * Gets the current priority level (0 at start)
  67492. */
  67493. readonly currentPriorityLevel: number;
  67494. /**
  67495. * Gets the current frame rate checked by the SceneOptimizer
  67496. */
  67497. readonly currentFrameRate: number;
  67498. /**
  67499. * Gets or sets the current target frame rate (60 by default)
  67500. */
  67501. /**
  67502. * Gets or sets the current target frame rate (60 by default)
  67503. */
  67504. targetFrameRate: number;
  67505. /**
  67506. * Gets or sets the current interval between two checks (every 2000ms by default)
  67507. */
  67508. /**
  67509. * Gets or sets the current interval between two checks (every 2000ms by default)
  67510. */
  67511. trackerDuration: number;
  67512. /**
  67513. * Gets the list of active optimizations
  67514. */
  67515. readonly optimizations: SceneOptimization[];
  67516. /**
  67517. * Creates a new SceneOptimizer
  67518. * @param scene defines the scene to work on
  67519. * @param options defines the options to use with the SceneOptimizer
  67520. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67521. * @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)
  67522. */
  67523. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67524. /**
  67525. * Stops the current optimizer
  67526. */
  67527. stop(): void;
  67528. /**
  67529. * Reset the optimizer to initial step (current priority level = 0)
  67530. */
  67531. reset(): void;
  67532. /**
  67533. * Start the optimizer. By default it will try to reach a specific framerate
  67534. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67535. */
  67536. start(): void;
  67537. private _checkCurrentState;
  67538. /**
  67539. * Release all resources
  67540. */
  67541. dispose(): void;
  67542. /**
  67543. * Helper function to create a SceneOptimizer with one single line of code
  67544. * @param scene defines the scene to work on
  67545. * @param options defines the options to use with the SceneOptimizer
  67546. * @param onSuccess defines a callback to call on success
  67547. * @param onFailure defines a callback to call on failure
  67548. * @returns the new SceneOptimizer object
  67549. */
  67550. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67551. }
  67552. }
  67553. declare module "babylonjs/Misc/sceneSerializer" {
  67554. import { Scene } from "babylonjs/scene";
  67555. /**
  67556. * Class used to serialize a scene into a string
  67557. */
  67558. export class SceneSerializer {
  67559. /**
  67560. * Clear cache used by a previous serialization
  67561. */
  67562. static ClearCache(): void;
  67563. /**
  67564. * Serialize a scene into a JSON compatible object
  67565. * @param scene defines the scene to serialize
  67566. * @returns a JSON compatible object
  67567. */
  67568. static Serialize(scene: Scene): any;
  67569. /**
  67570. * Serialize a mesh into a JSON compatible object
  67571. * @param toSerialize defines the mesh to serialize
  67572. * @param withParents defines if parents must be serialized as well
  67573. * @param withChildren defines if children must be serialized as well
  67574. * @returns a JSON compatible object
  67575. */
  67576. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67577. }
  67578. }
  67579. declare module "babylonjs/Misc/textureTools" {
  67580. import { Texture } from "babylonjs/Materials/Textures/texture";
  67581. /**
  67582. * Class used to host texture specific utilities
  67583. */
  67584. export class TextureTools {
  67585. /**
  67586. * Uses the GPU to create a copy texture rescaled at a given size
  67587. * @param texture Texture to copy from
  67588. * @param width defines the desired width
  67589. * @param height defines the desired height
  67590. * @param useBilinearMode defines if bilinear mode has to be used
  67591. * @return the generated texture
  67592. */
  67593. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67594. }
  67595. }
  67596. declare module "babylonjs/Misc/videoRecorder" {
  67597. import { Nullable } from "babylonjs/types";
  67598. import { Engine } from "babylonjs/Engines/engine";
  67599. /**
  67600. * This represents the different options available for the video capture.
  67601. */
  67602. export interface VideoRecorderOptions {
  67603. /** Defines the mime type of the video. */
  67604. mimeType: string;
  67605. /** Defines the FPS the video should be recorded at. */
  67606. fps: number;
  67607. /** Defines the chunk size for the recording data. */
  67608. recordChunckSize: number;
  67609. /** The audio tracks to attach to the recording. */
  67610. audioTracks?: MediaStreamTrack[];
  67611. }
  67612. /**
  67613. * This can help with recording videos from BabylonJS.
  67614. * This is based on the available WebRTC functionalities of the browser.
  67615. *
  67616. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67617. */
  67618. export class VideoRecorder {
  67619. private static readonly _defaultOptions;
  67620. /**
  67621. * Returns whether or not the VideoRecorder is available in your browser.
  67622. * @param engine Defines the Babylon Engine.
  67623. * @returns true if supported otherwise false.
  67624. */
  67625. static IsSupported(engine: Engine): boolean;
  67626. private readonly _options;
  67627. private _canvas;
  67628. private _mediaRecorder;
  67629. private _recordedChunks;
  67630. private _fileName;
  67631. private _resolve;
  67632. private _reject;
  67633. /**
  67634. * True when a recording is already in progress.
  67635. */
  67636. readonly isRecording: boolean;
  67637. /**
  67638. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67639. * @param engine Defines the BabylonJS Engine you wish to record.
  67640. * @param options Defines options that can be used to customize the capture.
  67641. */
  67642. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67643. /**
  67644. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67645. */
  67646. stopRecording(): void;
  67647. /**
  67648. * Starts recording the canvas for a max duration specified in parameters.
  67649. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67650. * If null no automatic download will start and you can rely on the promise to get the data back.
  67651. * @param maxDuration Defines the maximum recording time in seconds.
  67652. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67653. * @return A promise callback at the end of the recording with the video data in Blob.
  67654. */
  67655. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67656. /**
  67657. * Releases internal resources used during the recording.
  67658. */
  67659. dispose(): void;
  67660. private _handleDataAvailable;
  67661. private _handleError;
  67662. private _handleStop;
  67663. }
  67664. }
  67665. declare module "babylonjs/Misc/screenshotTools" {
  67666. import { Camera } from "babylonjs/Cameras/camera";
  67667. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67668. import { Engine } from "babylonjs/Engines/engine";
  67669. /**
  67670. * Class containing a set of static utilities functions for screenshots
  67671. */
  67672. export class ScreenshotTools {
  67673. /**
  67674. * Captures a screenshot of the current rendering
  67675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67676. * @param engine defines the rendering engine
  67677. * @param camera defines the source camera
  67678. * @param size This parameter can be set to a single number or to an object with the
  67679. * following (optional) properties: precision, width, height. If a single number is passed,
  67680. * it will be used for both width and height. If an object is passed, the screenshot size
  67681. * will be derived from the parameters. The precision property is a multiplier allowing
  67682. * rendering at a higher or lower resolution
  67683. * @param successCallback defines the callback receives a single parameter which contains the
  67684. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67685. * src parameter of an <img> to display it
  67686. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67687. * Check your browser for supported MIME types
  67688. */
  67689. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67690. /**
  67691. * Captures a screenshot of the current rendering
  67692. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67693. * @param engine defines the rendering engine
  67694. * @param camera defines the source camera
  67695. * @param size This parameter can be set to a single number or to an object with the
  67696. * following (optional) properties: precision, width, height. If a single number is passed,
  67697. * it will be used for both width and height. If an object is passed, the screenshot size
  67698. * will be derived from the parameters. The precision property is a multiplier allowing
  67699. * rendering at a higher or lower resolution
  67700. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67701. * Check your browser for supported MIME types
  67702. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67703. * to the src parameter of an <img> to display it
  67704. */
  67705. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67706. /**
  67707. * Generates an image screenshot from the specified camera.
  67708. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67709. * @param engine The engine to use for rendering
  67710. * @param camera The camera to use for rendering
  67711. * @param size This parameter can be set to a single number or to an object with the
  67712. * following (optional) properties: precision, width, height. If a single number is passed,
  67713. * it will be used for both width and height. If an object is passed, the screenshot size
  67714. * will be derived from the parameters. The precision property is a multiplier allowing
  67715. * rendering at a higher or lower resolution
  67716. * @param successCallback The callback receives a single parameter which contains the
  67717. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67718. * src parameter of an <img> to display it
  67719. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67720. * Check your browser for supported MIME types
  67721. * @param samples Texture samples (default: 1)
  67722. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67723. * @param fileName A name for for the downloaded file.
  67724. */
  67725. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67726. /**
  67727. * Generates an image screenshot from the specified camera.
  67728. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67729. * @param engine The engine to use for rendering
  67730. * @param camera The camera to use for rendering
  67731. * @param size This parameter can be set to a single number or to an object with the
  67732. * following (optional) properties: precision, width, height. If a single number is passed,
  67733. * it will be used for both width and height. If an object is passed, the screenshot size
  67734. * will be derived from the parameters. The precision property is a multiplier allowing
  67735. * rendering at a higher or lower resolution
  67736. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67737. * Check your browser for supported MIME types
  67738. * @param samples Texture samples (default: 1)
  67739. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67740. * @param fileName A name for for the downloaded file.
  67741. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67742. * to the src parameter of an <img> to display it
  67743. */
  67744. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67745. /**
  67746. * Gets height and width for screenshot size
  67747. * @private
  67748. */
  67749. private static _getScreenshotSize;
  67750. }
  67751. }
  67752. declare module "babylonjs/Misc/dataReader" {
  67753. /**
  67754. * Interface for a data buffer
  67755. */
  67756. export interface IDataBuffer {
  67757. /**
  67758. * Reads bytes from the data buffer.
  67759. * @param byteOffset The byte offset to read
  67760. * @param byteLength The byte length to read
  67761. * @returns A promise that resolves when the bytes are read
  67762. */
  67763. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67764. /**
  67765. * The byte length of the buffer.
  67766. */
  67767. readonly byteLength: number;
  67768. }
  67769. /**
  67770. * Utility class for reading from a data buffer
  67771. */
  67772. export class DataReader {
  67773. /**
  67774. * The data buffer associated with this data reader.
  67775. */
  67776. readonly buffer: IDataBuffer;
  67777. /**
  67778. * The current byte offset from the beginning of the data buffer.
  67779. */
  67780. byteOffset: number;
  67781. private _dataView;
  67782. private _dataByteOffset;
  67783. /**
  67784. * Constructor
  67785. * @param buffer The buffer to read
  67786. */
  67787. constructor(buffer: IDataBuffer);
  67788. /**
  67789. * Loads the given byte length.
  67790. * @param byteLength The byte length to load
  67791. * @returns A promise that resolves when the load is complete
  67792. */
  67793. loadAsync(byteLength: number): Promise<void>;
  67794. /**
  67795. * Read a unsigned 32-bit integer from the currently loaded data range.
  67796. * @returns The 32-bit integer read
  67797. */
  67798. readUint32(): number;
  67799. /**
  67800. * Read a byte array from the currently loaded data range.
  67801. * @param byteLength The byte length to read
  67802. * @returns The byte array read
  67803. */
  67804. readUint8Array(byteLength: number): Uint8Array;
  67805. /**
  67806. * Read a string from the currently loaded data range.
  67807. * @param byteLength The byte length to read
  67808. * @returns The string read
  67809. */
  67810. readString(byteLength: number): string;
  67811. /**
  67812. * Skips the given byte length the currently loaded data range.
  67813. * @param byteLength The byte length to skip
  67814. */
  67815. skipBytes(byteLength: number): void;
  67816. }
  67817. }
  67818. declare module "babylonjs/Misc/index" {
  67819. export * from "babylonjs/Misc/andOrNotEvaluator";
  67820. export * from "babylonjs/Misc/assetsManager";
  67821. export * from "babylonjs/Misc/dds";
  67822. export * from "babylonjs/Misc/decorators";
  67823. export * from "babylonjs/Misc/deferred";
  67824. export * from "babylonjs/Misc/environmentTextureTools";
  67825. export * from "babylonjs/Misc/meshExploder";
  67826. export * from "babylonjs/Misc/filesInput";
  67827. export * from "babylonjs/Misc/HighDynamicRange/index";
  67828. export * from "babylonjs/Misc/khronosTextureContainer";
  67829. export * from "babylonjs/Misc/observable";
  67830. export * from "babylonjs/Misc/performanceMonitor";
  67831. export * from "babylonjs/Misc/promise";
  67832. export * from "babylonjs/Misc/sceneOptimizer";
  67833. export * from "babylonjs/Misc/sceneSerializer";
  67834. export * from "babylonjs/Misc/smartArray";
  67835. export * from "babylonjs/Misc/stringDictionary";
  67836. export * from "babylonjs/Misc/tags";
  67837. export * from "babylonjs/Misc/textureTools";
  67838. export * from "babylonjs/Misc/tga";
  67839. export * from "babylonjs/Misc/tools";
  67840. export * from "babylonjs/Misc/videoRecorder";
  67841. export * from "babylonjs/Misc/virtualJoystick";
  67842. export * from "babylonjs/Misc/workerPool";
  67843. export * from "babylonjs/Misc/logger";
  67844. export * from "babylonjs/Misc/typeStore";
  67845. export * from "babylonjs/Misc/filesInputStore";
  67846. export * from "babylonjs/Misc/deepCopier";
  67847. export * from "babylonjs/Misc/pivotTools";
  67848. export * from "babylonjs/Misc/precisionDate";
  67849. export * from "babylonjs/Misc/screenshotTools";
  67850. export * from "babylonjs/Misc/typeStore";
  67851. export * from "babylonjs/Misc/webRequest";
  67852. export * from "babylonjs/Misc/iInspectable";
  67853. export * from "babylonjs/Misc/brdfTextureTools";
  67854. export * from "babylonjs/Misc/rgbdTextureTools";
  67855. export * from "babylonjs/Misc/gradients";
  67856. export * from "babylonjs/Misc/perfCounter";
  67857. export * from "babylonjs/Misc/fileRequest";
  67858. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67859. export * from "babylonjs/Misc/retryStrategy";
  67860. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67861. export * from "babylonjs/Misc/canvasGenerator";
  67862. export * from "babylonjs/Misc/fileTools";
  67863. export * from "babylonjs/Misc/stringTools";
  67864. export * from "babylonjs/Misc/dataReader";
  67865. }
  67866. declare module "babylonjs/index" {
  67867. export * from "babylonjs/abstractScene";
  67868. export * from "babylonjs/Actions/index";
  67869. export * from "babylonjs/Animations/index";
  67870. export * from "babylonjs/assetContainer";
  67871. export * from "babylonjs/Audio/index";
  67872. export * from "babylonjs/Behaviors/index";
  67873. export * from "babylonjs/Bones/index";
  67874. export * from "babylonjs/Cameras/index";
  67875. export * from "babylonjs/Collisions/index";
  67876. export * from "babylonjs/Culling/index";
  67877. export * from "babylonjs/Debug/index";
  67878. export * from "babylonjs/Engines/index";
  67879. export * from "babylonjs/Events/index";
  67880. export * from "babylonjs/Gamepads/index";
  67881. export * from "babylonjs/Gizmos/index";
  67882. export * from "babylonjs/Helpers/index";
  67883. export * from "babylonjs/Instrumentation/index";
  67884. export * from "babylonjs/Layers/index";
  67885. export * from "babylonjs/LensFlares/index";
  67886. export * from "babylonjs/Lights/index";
  67887. export * from "babylonjs/Loading/index";
  67888. export * from "babylonjs/Materials/index";
  67889. export * from "babylonjs/Maths/index";
  67890. export * from "babylonjs/Meshes/index";
  67891. export * from "babylonjs/Morph/index";
  67892. export * from "babylonjs/Navigation/index";
  67893. export * from "babylonjs/node";
  67894. export * from "babylonjs/Offline/index";
  67895. export * from "babylonjs/Particles/index";
  67896. export * from "babylonjs/Physics/index";
  67897. export * from "babylonjs/PostProcesses/index";
  67898. export * from "babylonjs/Probes/index";
  67899. export * from "babylonjs/Rendering/index";
  67900. export * from "babylonjs/scene";
  67901. export * from "babylonjs/sceneComponent";
  67902. export * from "babylonjs/Sprites/index";
  67903. export * from "babylonjs/States/index";
  67904. export * from "babylonjs/Misc/index";
  67905. export * from "babylonjs/types";
  67906. }
  67907. declare module "babylonjs/Animations/pathCursor" {
  67908. import { Vector3 } from "babylonjs/Maths/math.vector";
  67909. import { Path2 } from "babylonjs/Maths/math.path";
  67910. /**
  67911. * A cursor which tracks a point on a path
  67912. */
  67913. export class PathCursor {
  67914. private path;
  67915. /**
  67916. * Stores path cursor callbacks for when an onchange event is triggered
  67917. */
  67918. private _onchange;
  67919. /**
  67920. * The value of the path cursor
  67921. */
  67922. value: number;
  67923. /**
  67924. * The animation array of the path cursor
  67925. */
  67926. animations: Animation[];
  67927. /**
  67928. * Initializes the path cursor
  67929. * @param path The path to track
  67930. */
  67931. constructor(path: Path2);
  67932. /**
  67933. * Gets the cursor point on the path
  67934. * @returns A point on the path cursor at the cursor location
  67935. */
  67936. getPoint(): Vector3;
  67937. /**
  67938. * Moves the cursor ahead by the step amount
  67939. * @param step The amount to move the cursor forward
  67940. * @returns This path cursor
  67941. */
  67942. moveAhead(step?: number): PathCursor;
  67943. /**
  67944. * Moves the cursor behind by the step amount
  67945. * @param step The amount to move the cursor back
  67946. * @returns This path cursor
  67947. */
  67948. moveBack(step?: number): PathCursor;
  67949. /**
  67950. * Moves the cursor by the step amount
  67951. * If the step amount is greater than one, an exception is thrown
  67952. * @param step The amount to move the cursor
  67953. * @returns This path cursor
  67954. */
  67955. move(step: number): PathCursor;
  67956. /**
  67957. * Ensures that the value is limited between zero and one
  67958. * @returns This path cursor
  67959. */
  67960. private ensureLimits;
  67961. /**
  67962. * Runs onchange callbacks on change (used by the animation engine)
  67963. * @returns This path cursor
  67964. */
  67965. private raiseOnChange;
  67966. /**
  67967. * Executes a function on change
  67968. * @param f A path cursor onchange callback
  67969. * @returns This path cursor
  67970. */
  67971. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67972. }
  67973. }
  67974. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67975. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67976. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67977. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67978. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67979. }
  67980. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67981. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67982. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67983. }
  67984. declare module "babylonjs/Engines/Processors/index" {
  67985. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67986. export * from "babylonjs/Engines/Processors/Expressions/index";
  67987. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67988. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67989. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67990. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67991. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67992. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67993. }
  67994. declare module "babylonjs/Legacy/legacy" {
  67995. import * as Babylon from "babylonjs/index";
  67996. export * from "babylonjs/index";
  67997. }
  67998. declare module "babylonjs/Shaders/blur.fragment" {
  67999. /** @hidden */
  68000. export var blurPixelShader: {
  68001. name: string;
  68002. shader: string;
  68003. };
  68004. }
  68005. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68006. /** @hidden */
  68007. export var pointCloudVertexDeclaration: {
  68008. name: string;
  68009. shader: string;
  68010. };
  68011. }
  68012. declare module "babylonjs" {
  68013. export * from "babylonjs/Legacy/legacy";
  68014. }
  68015. declare module BABYLON {
  68016. /** Alias type for value that can be null */
  68017. export type Nullable<T> = T | null;
  68018. /**
  68019. * Alias type for number that are floats
  68020. * @ignorenaming
  68021. */
  68022. export type float = number;
  68023. /**
  68024. * Alias type for number that are doubles.
  68025. * @ignorenaming
  68026. */
  68027. export type double = number;
  68028. /**
  68029. * Alias type for number that are integer
  68030. * @ignorenaming
  68031. */
  68032. export type int = number;
  68033. /** Alias type for number array or Float32Array */
  68034. export type FloatArray = number[] | Float32Array;
  68035. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68036. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68037. /**
  68038. * Alias for types that can be used by a Buffer or VertexBuffer.
  68039. */
  68040. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68041. /**
  68042. * Alias type for primitive types
  68043. * @ignorenaming
  68044. */
  68045. type Primitive = undefined | null | boolean | string | number | Function;
  68046. /**
  68047. * Type modifier to make all the properties of an object Readonly
  68048. */
  68049. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68050. /**
  68051. * Type modifier to make all the properties of an object Readonly recursively
  68052. */
  68053. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68054. /**
  68055. * Type modifier to make object properties readonly.
  68056. */
  68057. export type DeepImmutableObject<T> = {
  68058. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68059. };
  68060. /** @hidden */
  68061. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /**
  68066. * A class serves as a medium between the observable and its observers
  68067. */
  68068. export class EventState {
  68069. /**
  68070. * Create a new EventState
  68071. * @param mask defines the mask associated with this state
  68072. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68073. * @param target defines the original target of the state
  68074. * @param currentTarget defines the current target of the state
  68075. */
  68076. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68077. /**
  68078. * Initialize the current event state
  68079. * @param mask defines the mask associated with this state
  68080. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68081. * @param target defines the original target of the state
  68082. * @param currentTarget defines the current target of the state
  68083. * @returns the current event state
  68084. */
  68085. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68086. /**
  68087. * An Observer can set this property to true to prevent subsequent observers of being notified
  68088. */
  68089. skipNextObservers: boolean;
  68090. /**
  68091. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68092. */
  68093. mask: number;
  68094. /**
  68095. * The object that originally notified the event
  68096. */
  68097. target?: any;
  68098. /**
  68099. * The current object in the bubbling phase
  68100. */
  68101. currentTarget?: any;
  68102. /**
  68103. * This will be populated with the return value of the last function that was executed.
  68104. * If it is the first function in the callback chain it will be the event data.
  68105. */
  68106. lastReturnValue?: any;
  68107. }
  68108. /**
  68109. * Represent an Observer registered to a given Observable object.
  68110. */
  68111. export class Observer<T> {
  68112. /**
  68113. * Defines the callback to call when the observer is notified
  68114. */
  68115. callback: (eventData: T, eventState: EventState) => void;
  68116. /**
  68117. * Defines the mask of the observer (used to filter notifications)
  68118. */
  68119. mask: number;
  68120. /**
  68121. * Defines the current scope used to restore the JS context
  68122. */
  68123. scope: any;
  68124. /** @hidden */
  68125. _willBeUnregistered: boolean;
  68126. /**
  68127. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68128. */
  68129. unregisterOnNextCall: boolean;
  68130. /**
  68131. * Creates a new observer
  68132. * @param callback defines the callback to call when the observer is notified
  68133. * @param mask defines the mask of the observer (used to filter notifications)
  68134. * @param scope defines the current scope used to restore the JS context
  68135. */
  68136. constructor(
  68137. /**
  68138. * Defines the callback to call when the observer is notified
  68139. */
  68140. callback: (eventData: T, eventState: EventState) => void,
  68141. /**
  68142. * Defines the mask of the observer (used to filter notifications)
  68143. */
  68144. mask: number,
  68145. /**
  68146. * Defines the current scope used to restore the JS context
  68147. */
  68148. scope?: any);
  68149. }
  68150. /**
  68151. * Represent a list of observers registered to multiple Observables object.
  68152. */
  68153. export class MultiObserver<T> {
  68154. private _observers;
  68155. private _observables;
  68156. /**
  68157. * Release associated resources
  68158. */
  68159. dispose(): void;
  68160. /**
  68161. * Raise a callback when one of the observable will notify
  68162. * @param observables defines a list of observables to watch
  68163. * @param callback defines the callback to call on notification
  68164. * @param mask defines the mask used to filter notifications
  68165. * @param scope defines the current scope used to restore the JS context
  68166. * @returns the new MultiObserver
  68167. */
  68168. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68169. }
  68170. /**
  68171. * The Observable class is a simple implementation of the Observable pattern.
  68172. *
  68173. * 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.
  68174. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68175. * 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).
  68176. * 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.
  68177. */
  68178. export class Observable<T> {
  68179. private _observers;
  68180. private _eventState;
  68181. private _onObserverAdded;
  68182. /**
  68183. * Gets the list of observers
  68184. */
  68185. readonly observers: Array<Observer<T>>;
  68186. /**
  68187. * Creates a new observable
  68188. * @param onObserverAdded defines a callback to call when a new observer is added
  68189. */
  68190. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68191. /**
  68192. * Create a new Observer with the specified callback
  68193. * @param callback the callback that will be executed for that Observer
  68194. * @param mask the mask used to filter observers
  68195. * @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.
  68196. * @param scope optional scope for the callback to be called from
  68197. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68198. * @returns the new observer created for the callback
  68199. */
  68200. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68201. /**
  68202. * Create a new Observer with the specified callback and unregisters after the next notification
  68203. * @param callback the callback that will be executed for that Observer
  68204. * @returns the new observer created for the callback
  68205. */
  68206. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68207. /**
  68208. * Remove an Observer from the Observable object
  68209. * @param observer the instance of the Observer to remove
  68210. * @returns false if it doesn't belong to this Observable
  68211. */
  68212. remove(observer: Nullable<Observer<T>>): boolean;
  68213. /**
  68214. * Remove a callback from the Observable object
  68215. * @param callback the callback to remove
  68216. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68217. * @returns false if it doesn't belong to this Observable
  68218. */
  68219. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68220. private _deferUnregister;
  68221. private _remove;
  68222. /**
  68223. * Moves the observable to the top of the observer list making it get called first when notified
  68224. * @param observer the observer to move
  68225. */
  68226. makeObserverTopPriority(observer: Observer<T>): void;
  68227. /**
  68228. * Moves the observable to the bottom of the observer list making it get called last when notified
  68229. * @param observer the observer to move
  68230. */
  68231. makeObserverBottomPriority(observer: Observer<T>): void;
  68232. /**
  68233. * Notify all Observers by calling their respective callback with the given data
  68234. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68235. * @param eventData defines the data to send to all observers
  68236. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68237. * @param target defines the original target of the state
  68238. * @param currentTarget defines the current target of the state
  68239. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68240. */
  68241. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68242. /**
  68243. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68244. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68245. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68246. * and it is crucial that all callbacks will be executed.
  68247. * The order of the callbacks is kept, callbacks are not executed parallel.
  68248. *
  68249. * @param eventData The data to be sent to each callback
  68250. * @param mask is used to filter observers defaults to -1
  68251. * @param target defines the callback target (see EventState)
  68252. * @param currentTarget defines he current object in the bubbling phase
  68253. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68254. */
  68255. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68256. /**
  68257. * Notify a specific observer
  68258. * @param observer defines the observer to notify
  68259. * @param eventData defines the data to be sent to each callback
  68260. * @param mask is used to filter observers defaults to -1
  68261. */
  68262. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68263. /**
  68264. * Gets a boolean indicating if the observable has at least one observer
  68265. * @returns true is the Observable has at least one Observer registered
  68266. */
  68267. hasObservers(): boolean;
  68268. /**
  68269. * Clear the list of observers
  68270. */
  68271. clear(): void;
  68272. /**
  68273. * Clone the current observable
  68274. * @returns a new observable
  68275. */
  68276. clone(): Observable<T>;
  68277. /**
  68278. * Does this observable handles observer registered with a given mask
  68279. * @param mask defines the mask to be tested
  68280. * @return whether or not one observer registered with the given mask is handeled
  68281. **/
  68282. hasSpecificMask(mask?: number): boolean;
  68283. }
  68284. }
  68285. declare module BABYLON {
  68286. /**
  68287. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68288. * Babylon.js
  68289. */
  68290. export class DomManagement {
  68291. /**
  68292. * Checks if the window object exists
  68293. * @returns true if the window object exists
  68294. */
  68295. static IsWindowObjectExist(): boolean;
  68296. /**
  68297. * Checks if the navigator object exists
  68298. * @returns true if the navigator object exists
  68299. */
  68300. static IsNavigatorAvailable(): boolean;
  68301. /**
  68302. * Extracts text content from a DOM element hierarchy
  68303. * @param element defines the root element
  68304. * @returns a string
  68305. */
  68306. static GetDOMTextContent(element: HTMLElement): string;
  68307. }
  68308. }
  68309. declare module BABYLON {
  68310. /**
  68311. * Logger used througouht the application to allow configuration of
  68312. * the log level required for the messages.
  68313. */
  68314. export class Logger {
  68315. /**
  68316. * No log
  68317. */
  68318. static readonly NoneLogLevel: number;
  68319. /**
  68320. * Only message logs
  68321. */
  68322. static readonly MessageLogLevel: number;
  68323. /**
  68324. * Only warning logs
  68325. */
  68326. static readonly WarningLogLevel: number;
  68327. /**
  68328. * Only error logs
  68329. */
  68330. static readonly ErrorLogLevel: number;
  68331. /**
  68332. * All logs
  68333. */
  68334. static readonly AllLogLevel: number;
  68335. private static _LogCache;
  68336. /**
  68337. * Gets a value indicating the number of loading errors
  68338. * @ignorenaming
  68339. */
  68340. static errorsCount: number;
  68341. /**
  68342. * Callback called when a new log is added
  68343. */
  68344. static OnNewCacheEntry: (entry: string) => void;
  68345. private static _AddLogEntry;
  68346. private static _FormatMessage;
  68347. private static _LogDisabled;
  68348. private static _LogEnabled;
  68349. private static _WarnDisabled;
  68350. private static _WarnEnabled;
  68351. private static _ErrorDisabled;
  68352. private static _ErrorEnabled;
  68353. /**
  68354. * Log a message to the console
  68355. */
  68356. static Log: (message: string) => void;
  68357. /**
  68358. * Write a warning message to the console
  68359. */
  68360. static Warn: (message: string) => void;
  68361. /**
  68362. * Write an error message to the console
  68363. */
  68364. static Error: (message: string) => void;
  68365. /**
  68366. * Gets current log cache (list of logs)
  68367. */
  68368. static readonly LogCache: string;
  68369. /**
  68370. * Clears the log cache
  68371. */
  68372. static ClearLogCache(): void;
  68373. /**
  68374. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68375. */
  68376. static LogLevels: number;
  68377. }
  68378. }
  68379. declare module BABYLON {
  68380. /** @hidden */
  68381. export class _TypeStore {
  68382. /** @hidden */
  68383. static RegisteredTypes: {
  68384. [key: string]: Object;
  68385. };
  68386. /** @hidden */
  68387. static GetClass(fqdn: string): any;
  68388. }
  68389. }
  68390. declare module BABYLON {
  68391. /**
  68392. * Helper to manipulate strings
  68393. */
  68394. export class StringTools {
  68395. /**
  68396. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68397. * @param str Source string
  68398. * @param suffix Suffix to search for in the source string
  68399. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68400. */
  68401. static EndsWith(str: string, suffix: string): boolean;
  68402. /**
  68403. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68404. * @param str Source string
  68405. * @param suffix Suffix to search for in the source string
  68406. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68407. */
  68408. static StartsWith(str: string, suffix: string): boolean;
  68409. /**
  68410. * Decodes a buffer into a string
  68411. * @param buffer The buffer to decode
  68412. * @returns The decoded string
  68413. */
  68414. static Decode(buffer: Uint8Array | Uint16Array): string;
  68415. /**
  68416. * Encode a buffer to a base64 string
  68417. * @param buffer defines the buffer to encode
  68418. * @returns the encoded string
  68419. */
  68420. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68421. }
  68422. }
  68423. declare module BABYLON {
  68424. /**
  68425. * Class containing a set of static utilities functions for deep copy.
  68426. */
  68427. export class DeepCopier {
  68428. /**
  68429. * Tries to copy an object by duplicating every property
  68430. * @param source defines the source object
  68431. * @param destination defines the target object
  68432. * @param doNotCopyList defines a list of properties to avoid
  68433. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68434. */
  68435. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68436. }
  68437. }
  68438. declare module BABYLON {
  68439. /**
  68440. * Class containing a set of static utilities functions for precision date
  68441. */
  68442. export class PrecisionDate {
  68443. /**
  68444. * Gets either window.performance.now() if supported or Date.now() else
  68445. */
  68446. static readonly Now: number;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /** @hidden */
  68451. export class _DevTools {
  68452. static WarnImport(name: string): string;
  68453. }
  68454. }
  68455. declare module BABYLON {
  68456. /**
  68457. * Interface used to define the mechanism to get data from the network
  68458. */
  68459. export interface IWebRequest {
  68460. /**
  68461. * Returns client's response url
  68462. */
  68463. responseURL: string;
  68464. /**
  68465. * Returns client's status
  68466. */
  68467. status: number;
  68468. /**
  68469. * Returns client's status as a text
  68470. */
  68471. statusText: string;
  68472. }
  68473. }
  68474. declare module BABYLON {
  68475. /**
  68476. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68477. */
  68478. export class WebRequest implements IWebRequest {
  68479. private _xhr;
  68480. /**
  68481. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68482. * i.e. when loading files, where the server/service expects an Authorization header
  68483. */
  68484. static CustomRequestHeaders: {
  68485. [key: string]: string;
  68486. };
  68487. /**
  68488. * Add callback functions in this array to update all the requests before they get sent to the network
  68489. */
  68490. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68491. private _injectCustomRequestHeaders;
  68492. /**
  68493. * Gets or sets a function to be called when loading progress changes
  68494. */
  68495. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68496. /**
  68497. * Returns client's state
  68498. */
  68499. readonly readyState: number;
  68500. /**
  68501. * Returns client's status
  68502. */
  68503. readonly status: number;
  68504. /**
  68505. * Returns client's status as a text
  68506. */
  68507. readonly statusText: string;
  68508. /**
  68509. * Returns client's response
  68510. */
  68511. readonly response: any;
  68512. /**
  68513. * Returns client's response url
  68514. */
  68515. readonly responseURL: string;
  68516. /**
  68517. * Returns client's response as text
  68518. */
  68519. readonly responseText: string;
  68520. /**
  68521. * Gets or sets the expected response type
  68522. */
  68523. responseType: XMLHttpRequestResponseType;
  68524. /** @hidden */
  68525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68526. /** @hidden */
  68527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68528. /**
  68529. * Cancels any network activity
  68530. */
  68531. abort(): void;
  68532. /**
  68533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68534. * @param body defines an optional request body
  68535. */
  68536. send(body?: Document | BodyInit | null): void;
  68537. /**
  68538. * Sets the request method, request URL
  68539. * @param method defines the method to use (GET, POST, etc..)
  68540. * @param url defines the url to connect with
  68541. */
  68542. open(method: string, url: string): void;
  68543. /**
  68544. * Sets the value of a request header.
  68545. * @param name The name of the header whose value is to be set
  68546. * @param value The value to set as the body of the header
  68547. */
  68548. setRequestHeader(name: string, value: string): void;
  68549. /**
  68550. * Get the string containing the text of a particular header's value.
  68551. * @param name The name of the header
  68552. * @returns The string containing the text of the given header name
  68553. */
  68554. getResponseHeader(name: string): Nullable<string>;
  68555. }
  68556. }
  68557. declare module BABYLON {
  68558. /**
  68559. * File request interface
  68560. */
  68561. export interface IFileRequest {
  68562. /**
  68563. * Raised when the request is complete (success or error).
  68564. */
  68565. onCompleteObservable: Observable<IFileRequest>;
  68566. /**
  68567. * Aborts the request for a file.
  68568. */
  68569. abort: () => void;
  68570. }
  68571. }
  68572. declare module BABYLON {
  68573. /**
  68574. * Define options used to create a render target texture
  68575. */
  68576. export class RenderTargetCreationOptions {
  68577. /**
  68578. * Specifies is mipmaps must be generated
  68579. */
  68580. generateMipMaps?: boolean;
  68581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68582. generateDepthBuffer?: boolean;
  68583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68584. generateStencilBuffer?: boolean;
  68585. /** Defines texture type (int by default) */
  68586. type?: number;
  68587. /** Defines sampling mode (trilinear by default) */
  68588. samplingMode?: number;
  68589. /** Defines format (RGBA by default) */
  68590. format?: number;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * @hidden
  68596. **/
  68597. export class _TimeToken {
  68598. _startTimeQuery: Nullable<WebGLQuery>;
  68599. _endTimeQuery: Nullable<WebGLQuery>;
  68600. _timeElapsedQuery: Nullable<WebGLQuery>;
  68601. _timeElapsedQueryEnded: boolean;
  68602. }
  68603. }
  68604. declare module BABYLON {
  68605. /** Defines the cross module used constants to avoid circular dependncies */
  68606. export class Constants {
  68607. /** Defines that alpha blending is disabled */
  68608. static readonly ALPHA_DISABLE: number;
  68609. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68610. static readonly ALPHA_ADD: number;
  68611. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68612. static readonly ALPHA_COMBINE: number;
  68613. /** Defines that alpha blending to DEST - SRC * DEST */
  68614. static readonly ALPHA_SUBTRACT: number;
  68615. /** Defines that alpha blending to SRC * DEST */
  68616. static readonly ALPHA_MULTIPLY: number;
  68617. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68618. static readonly ALPHA_MAXIMIZED: number;
  68619. /** Defines that alpha blending to SRC + DEST */
  68620. static readonly ALPHA_ONEONE: number;
  68621. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68622. static readonly ALPHA_PREMULTIPLIED: number;
  68623. /**
  68624. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68625. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68626. */
  68627. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68628. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68629. static readonly ALPHA_INTERPOLATE: number;
  68630. /**
  68631. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68632. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68633. */
  68634. static readonly ALPHA_SCREENMODE: number;
  68635. /**
  68636. * Defines that alpha blending to SRC + DST
  68637. * Alpha will be set to SRC ALPHA + DST ALPHA
  68638. */
  68639. static readonly ALPHA_ONEONE_ONEONE: number;
  68640. /**
  68641. * Defines that alpha blending to SRC * DST ALPHA + DST
  68642. * Alpha will be set to 0
  68643. */
  68644. static readonly ALPHA_ALPHATOCOLOR: number;
  68645. /**
  68646. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68647. */
  68648. static readonly ALPHA_REVERSEONEMINUS: number;
  68649. /**
  68650. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68651. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68652. */
  68653. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68654. /**
  68655. * Defines that alpha blending to SRC + DST
  68656. * Alpha will be set to SRC ALPHA
  68657. */
  68658. static readonly ALPHA_ONEONE_ONEZERO: number;
  68659. /** Defines that alpha blending equation a SUM */
  68660. static readonly ALPHA_EQUATION_ADD: number;
  68661. /** Defines that alpha blending equation a SUBSTRACTION */
  68662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68665. /** Defines that alpha blending equation a MAX operation */
  68666. static readonly ALPHA_EQUATION_MAX: number;
  68667. /** Defines that alpha blending equation a MIN operation */
  68668. static readonly ALPHA_EQUATION_MIN: number;
  68669. /**
  68670. * Defines that alpha blending equation a DARKEN operation:
  68671. * It takes the min of the src and sums the alpha channels.
  68672. */
  68673. static readonly ALPHA_EQUATION_DARKEN: number;
  68674. /** Defines that the ressource is not delayed*/
  68675. static readonly DELAYLOADSTATE_NONE: number;
  68676. /** Defines that the ressource was successfully delay loaded */
  68677. static readonly DELAYLOADSTATE_LOADED: number;
  68678. /** Defines that the ressource is currently delay loading */
  68679. static readonly DELAYLOADSTATE_LOADING: number;
  68680. /** Defines that the ressource is delayed and has not started loading */
  68681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68683. static readonly NEVER: number;
  68684. /** 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 */
  68685. static readonly ALWAYS: number;
  68686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68687. static readonly LESS: number;
  68688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68689. static readonly EQUAL: number;
  68690. /** 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 */
  68691. static readonly LEQUAL: number;
  68692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68693. static readonly GREATER: number;
  68694. /** 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 */
  68695. static readonly GEQUAL: number;
  68696. /** 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 */
  68697. static readonly NOTEQUAL: number;
  68698. /** Passed to stencilOperation to specify that stencil value must be kept */
  68699. static readonly KEEP: number;
  68700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68701. static readonly REPLACE: number;
  68702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68703. static readonly INCR: number;
  68704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68705. static readonly DECR: number;
  68706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68707. static readonly INVERT: number;
  68708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68709. static readonly INCR_WRAP: number;
  68710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68711. static readonly DECR_WRAP: number;
  68712. /** Texture is not repeating outside of 0..1 UVs */
  68713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68714. /** Texture is repeating outside of 0..1 UVs */
  68715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68716. /** Texture is repeating and mirrored */
  68717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68718. /** ALPHA */
  68719. static readonly TEXTUREFORMAT_ALPHA: number;
  68720. /** LUMINANCE */
  68721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68722. /** LUMINANCE_ALPHA */
  68723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68724. /** RGB */
  68725. static readonly TEXTUREFORMAT_RGB: number;
  68726. /** RGBA */
  68727. static readonly TEXTUREFORMAT_RGBA: number;
  68728. /** RED */
  68729. static readonly TEXTUREFORMAT_RED: number;
  68730. /** RED (2nd reference) */
  68731. static readonly TEXTUREFORMAT_R: number;
  68732. /** RG */
  68733. static readonly TEXTUREFORMAT_RG: number;
  68734. /** RED_INTEGER */
  68735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68736. /** RED_INTEGER (2nd reference) */
  68737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68738. /** RG_INTEGER */
  68739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68740. /** RGB_INTEGER */
  68741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68742. /** RGBA_INTEGER */
  68743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68744. /** UNSIGNED_BYTE */
  68745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68746. /** UNSIGNED_BYTE (2nd reference) */
  68747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68748. /** FLOAT */
  68749. static readonly TEXTURETYPE_FLOAT: number;
  68750. /** HALF_FLOAT */
  68751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68752. /** BYTE */
  68753. static readonly TEXTURETYPE_BYTE: number;
  68754. /** SHORT */
  68755. static readonly TEXTURETYPE_SHORT: number;
  68756. /** UNSIGNED_SHORT */
  68757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68758. /** INT */
  68759. static readonly TEXTURETYPE_INT: number;
  68760. /** UNSIGNED_INT */
  68761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68762. /** UNSIGNED_SHORT_4_4_4_4 */
  68763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68764. /** UNSIGNED_SHORT_5_5_5_1 */
  68765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68766. /** UNSIGNED_SHORT_5_6_5 */
  68767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68768. /** UNSIGNED_INT_2_10_10_10_REV */
  68769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68770. /** UNSIGNED_INT_24_8 */
  68771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68772. /** UNSIGNED_INT_10F_11F_11F_REV */
  68773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68774. /** UNSIGNED_INT_5_9_9_9_REV */
  68775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68778. /** nearest is mag = nearest and min = nearest and mip = linear */
  68779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68780. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68782. /** Trilinear is mag = linear and min = linear and mip = linear */
  68783. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68784. /** nearest is mag = nearest and min = nearest and mip = linear */
  68785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68788. /** Trilinear is mag = linear and min = linear and mip = linear */
  68789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68790. /** mag = nearest and min = nearest and mip = nearest */
  68791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68792. /** mag = nearest and min = linear and mip = nearest */
  68793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68794. /** mag = nearest and min = linear and mip = linear */
  68795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68796. /** mag = nearest and min = linear and mip = none */
  68797. static readonly TEXTURE_NEAREST_LINEAR: number;
  68798. /** mag = nearest and min = nearest and mip = none */
  68799. static readonly TEXTURE_NEAREST_NEAREST: number;
  68800. /** mag = linear and min = nearest and mip = nearest */
  68801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68802. /** mag = linear and min = nearest and mip = linear */
  68803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68804. /** mag = linear and min = linear and mip = none */
  68805. static readonly TEXTURE_LINEAR_LINEAR: number;
  68806. /** mag = linear and min = nearest and mip = none */
  68807. static readonly TEXTURE_LINEAR_NEAREST: number;
  68808. /** Explicit coordinates mode */
  68809. static readonly TEXTURE_EXPLICIT_MODE: number;
  68810. /** Spherical coordinates mode */
  68811. static readonly TEXTURE_SPHERICAL_MODE: number;
  68812. /** Planar coordinates mode */
  68813. static readonly TEXTURE_PLANAR_MODE: number;
  68814. /** Cubic coordinates mode */
  68815. static readonly TEXTURE_CUBIC_MODE: number;
  68816. /** Projection coordinates mode */
  68817. static readonly TEXTURE_PROJECTION_MODE: number;
  68818. /** Skybox coordinates mode */
  68819. static readonly TEXTURE_SKYBOX_MODE: number;
  68820. /** Inverse Cubic coordinates mode */
  68821. static readonly TEXTURE_INVCUBIC_MODE: number;
  68822. /** Equirectangular coordinates mode */
  68823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68824. /** Equirectangular Fixed coordinates mode */
  68825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68826. /** Equirectangular Fixed Mirrored coordinates mode */
  68827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68828. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68829. static readonly SCALEMODE_FLOOR: number;
  68830. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68831. static readonly SCALEMODE_NEAREST: number;
  68832. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68833. static readonly SCALEMODE_CEILING: number;
  68834. /**
  68835. * The dirty texture flag value
  68836. */
  68837. static readonly MATERIAL_TextureDirtyFlag: number;
  68838. /**
  68839. * The dirty light flag value
  68840. */
  68841. static readonly MATERIAL_LightDirtyFlag: number;
  68842. /**
  68843. * The dirty fresnel flag value
  68844. */
  68845. static readonly MATERIAL_FresnelDirtyFlag: number;
  68846. /**
  68847. * The dirty attribute flag value
  68848. */
  68849. static readonly MATERIAL_AttributesDirtyFlag: number;
  68850. /**
  68851. * The dirty misc flag value
  68852. */
  68853. static readonly MATERIAL_MiscDirtyFlag: number;
  68854. /**
  68855. * The all dirty flag value
  68856. */
  68857. static readonly MATERIAL_AllDirtyFlag: number;
  68858. /**
  68859. * Returns the triangle fill mode
  68860. */
  68861. static readonly MATERIAL_TriangleFillMode: number;
  68862. /**
  68863. * Returns the wireframe mode
  68864. */
  68865. static readonly MATERIAL_WireFrameFillMode: number;
  68866. /**
  68867. * Returns the point fill mode
  68868. */
  68869. static readonly MATERIAL_PointFillMode: number;
  68870. /**
  68871. * Returns the point list draw mode
  68872. */
  68873. static readonly MATERIAL_PointListDrawMode: number;
  68874. /**
  68875. * Returns the line list draw mode
  68876. */
  68877. static readonly MATERIAL_LineListDrawMode: number;
  68878. /**
  68879. * Returns the line loop draw mode
  68880. */
  68881. static readonly MATERIAL_LineLoopDrawMode: number;
  68882. /**
  68883. * Returns the line strip draw mode
  68884. */
  68885. static readonly MATERIAL_LineStripDrawMode: number;
  68886. /**
  68887. * Returns the triangle strip draw mode
  68888. */
  68889. static readonly MATERIAL_TriangleStripDrawMode: number;
  68890. /**
  68891. * Returns the triangle fan draw mode
  68892. */
  68893. static readonly MATERIAL_TriangleFanDrawMode: number;
  68894. /**
  68895. * Stores the clock-wise side orientation
  68896. */
  68897. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68898. /**
  68899. * Stores the counter clock-wise side orientation
  68900. */
  68901. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68902. /**
  68903. * Nothing
  68904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68905. */
  68906. static readonly ACTION_NothingTrigger: number;
  68907. /**
  68908. * On pick
  68909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68910. */
  68911. static readonly ACTION_OnPickTrigger: number;
  68912. /**
  68913. * On left pick
  68914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68915. */
  68916. static readonly ACTION_OnLeftPickTrigger: number;
  68917. /**
  68918. * On right pick
  68919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68920. */
  68921. static readonly ACTION_OnRightPickTrigger: number;
  68922. /**
  68923. * On center pick
  68924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68925. */
  68926. static readonly ACTION_OnCenterPickTrigger: number;
  68927. /**
  68928. * On pick down
  68929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68930. */
  68931. static readonly ACTION_OnPickDownTrigger: number;
  68932. /**
  68933. * On double pick
  68934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68935. */
  68936. static readonly ACTION_OnDoublePickTrigger: number;
  68937. /**
  68938. * On pick up
  68939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68940. */
  68941. static readonly ACTION_OnPickUpTrigger: number;
  68942. /**
  68943. * On pick out.
  68944. * This trigger will only be raised if you also declared a OnPickDown
  68945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68946. */
  68947. static readonly ACTION_OnPickOutTrigger: number;
  68948. /**
  68949. * On long press
  68950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68951. */
  68952. static readonly ACTION_OnLongPressTrigger: number;
  68953. /**
  68954. * On pointer over
  68955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68956. */
  68957. static readonly ACTION_OnPointerOverTrigger: number;
  68958. /**
  68959. * On pointer out
  68960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68961. */
  68962. static readonly ACTION_OnPointerOutTrigger: number;
  68963. /**
  68964. * On every frame
  68965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68966. */
  68967. static readonly ACTION_OnEveryFrameTrigger: number;
  68968. /**
  68969. * On intersection enter
  68970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68971. */
  68972. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68973. /**
  68974. * On intersection exit
  68975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68976. */
  68977. static readonly ACTION_OnIntersectionExitTrigger: number;
  68978. /**
  68979. * On key down
  68980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68981. */
  68982. static readonly ACTION_OnKeyDownTrigger: number;
  68983. /**
  68984. * On key up
  68985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68986. */
  68987. static readonly ACTION_OnKeyUpTrigger: number;
  68988. /**
  68989. * Billboard mode will only apply to Y axis
  68990. */
  68991. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68992. /**
  68993. * Billboard mode will apply to all axes
  68994. */
  68995. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68996. /**
  68997. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68998. */
  68999. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69000. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69001. * Test order :
  69002. * Is the bounding sphere outside the frustum ?
  69003. * If not, are the bounding box vertices outside the frustum ?
  69004. * It not, then the cullable object is in the frustum.
  69005. */
  69006. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69007. /** Culling strategy : Bounding Sphere Only.
  69008. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69009. * It's also less accurate than the standard because some not visible objects can still be selected.
  69010. * Test : is the bounding sphere outside the frustum ?
  69011. * If not, then the cullable object is in the frustum.
  69012. */
  69013. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69014. /** Culling strategy : Optimistic Inclusion.
  69015. * This in an inclusion test first, then the standard exclusion test.
  69016. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69017. * 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.
  69018. * Anyway, it's as accurate as the standard strategy.
  69019. * Test :
  69020. * Is the cullable object bounding sphere center in the frustum ?
  69021. * If not, apply the default culling strategy.
  69022. */
  69023. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69024. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69025. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69026. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69027. * 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.
  69028. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69029. * Test :
  69030. * Is the cullable object bounding sphere center in the frustum ?
  69031. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69032. */
  69033. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69034. /**
  69035. * No logging while loading
  69036. */
  69037. static readonly SCENELOADER_NO_LOGGING: number;
  69038. /**
  69039. * Minimal logging while loading
  69040. */
  69041. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69042. /**
  69043. * Summary logging while loading
  69044. */
  69045. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69046. /**
  69047. * Detailled logging while loading
  69048. */
  69049. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69050. }
  69051. }
  69052. declare module BABYLON {
  69053. /**
  69054. * This represents the required contract to create a new type of texture loader.
  69055. */
  69056. export interface IInternalTextureLoader {
  69057. /**
  69058. * Defines wether the loader supports cascade loading the different faces.
  69059. */
  69060. supportCascades: boolean;
  69061. /**
  69062. * This returns if the loader support the current file information.
  69063. * @param extension defines the file extension of the file being loaded
  69064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69065. * @param fallback defines the fallback internal texture if any
  69066. * @param isBase64 defines whether the texture is encoded as a base64
  69067. * @param isBuffer defines whether the texture data are stored as a buffer
  69068. * @returns true if the loader can load the specified file
  69069. */
  69070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69071. /**
  69072. * Transform the url before loading if required.
  69073. * @param rootUrl the url of the texture
  69074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69075. * @returns the transformed texture
  69076. */
  69077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69078. /**
  69079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69080. * @param rootUrl the url of the texture
  69081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69082. * @returns the fallback texture
  69083. */
  69084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69085. /**
  69086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69087. * @param data contains the texture data
  69088. * @param texture defines the BabylonJS internal texture
  69089. * @param createPolynomials will be true if polynomials have been requested
  69090. * @param onLoad defines the callback to trigger once the texture is ready
  69091. * @param onError defines the callback to trigger in case of error
  69092. */
  69093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69094. /**
  69095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69096. * @param data contains the texture data
  69097. * @param texture defines the BabylonJS internal texture
  69098. * @param callback defines the method to call once ready to upload
  69099. */
  69100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69101. }
  69102. }
  69103. declare module BABYLON {
  69104. /**
  69105. * Class used to store and describe the pipeline context associated with an effect
  69106. */
  69107. export interface IPipelineContext {
  69108. /**
  69109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69110. */
  69111. isAsync: boolean;
  69112. /**
  69113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69114. */
  69115. isReady: boolean;
  69116. /** @hidden */
  69117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69118. }
  69119. }
  69120. declare module BABYLON {
  69121. /**
  69122. * Class used to store gfx data (like WebGLBuffer)
  69123. */
  69124. export class DataBuffer {
  69125. /**
  69126. * Gets or sets the number of objects referencing this buffer
  69127. */
  69128. references: number;
  69129. /** Gets or sets the size of the underlying buffer */
  69130. capacity: number;
  69131. /**
  69132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69133. */
  69134. is32Bits: boolean;
  69135. /**
  69136. * Gets the underlying buffer
  69137. */
  69138. readonly underlyingResource: any;
  69139. }
  69140. }
  69141. declare module BABYLON {
  69142. /** @hidden */
  69143. export interface IShaderProcessor {
  69144. attributeProcessor?: (attribute: string) => string;
  69145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69149. lineProcessor?: (line: string, isFragment: boolean) => string;
  69150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69152. }
  69153. }
  69154. declare module BABYLON {
  69155. /** @hidden */
  69156. export interface ProcessingOptions {
  69157. defines: string[];
  69158. indexParameters: any;
  69159. isFragment: boolean;
  69160. shouldUseHighPrecisionShader: boolean;
  69161. supportsUniformBuffers: boolean;
  69162. shadersRepository: string;
  69163. includesShadersStore: {
  69164. [key: string]: string;
  69165. };
  69166. processor?: IShaderProcessor;
  69167. version: string;
  69168. platformName: string;
  69169. lookForClosingBracketForUniformBuffer?: boolean;
  69170. }
  69171. }
  69172. declare module BABYLON {
  69173. /** @hidden */
  69174. export class ShaderCodeNode {
  69175. line: string;
  69176. children: ShaderCodeNode[];
  69177. additionalDefineKey?: string;
  69178. additionalDefineValue?: string;
  69179. isValid(preprocessors: {
  69180. [key: string]: string;
  69181. }): boolean;
  69182. process(preprocessors: {
  69183. [key: string]: string;
  69184. }, options: ProcessingOptions): string;
  69185. }
  69186. }
  69187. declare module BABYLON {
  69188. /** @hidden */
  69189. export class ShaderCodeCursor {
  69190. private _lines;
  69191. lineIndex: number;
  69192. readonly currentLine: string;
  69193. readonly canRead: boolean;
  69194. lines: string[];
  69195. }
  69196. }
  69197. declare module BABYLON {
  69198. /** @hidden */
  69199. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69200. process(preprocessors: {
  69201. [key: string]: string;
  69202. }, options: ProcessingOptions): string;
  69203. }
  69204. }
  69205. declare module BABYLON {
  69206. /** @hidden */
  69207. export class ShaderDefineExpression {
  69208. isTrue(preprocessors: {
  69209. [key: string]: string;
  69210. }): boolean;
  69211. }
  69212. }
  69213. declare module BABYLON {
  69214. /** @hidden */
  69215. export class ShaderCodeTestNode extends ShaderCodeNode {
  69216. testExpression: ShaderDefineExpression;
  69217. isValid(preprocessors: {
  69218. [key: string]: string;
  69219. }): boolean;
  69220. }
  69221. }
  69222. declare module BABYLON {
  69223. /** @hidden */
  69224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69225. define: string;
  69226. not: boolean;
  69227. constructor(define: string, not?: boolean);
  69228. isTrue(preprocessors: {
  69229. [key: string]: string;
  69230. }): boolean;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /** @hidden */
  69235. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69236. leftOperand: ShaderDefineExpression;
  69237. rightOperand: ShaderDefineExpression;
  69238. isTrue(preprocessors: {
  69239. [key: string]: string;
  69240. }): boolean;
  69241. }
  69242. }
  69243. declare module BABYLON {
  69244. /** @hidden */
  69245. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69246. leftOperand: ShaderDefineExpression;
  69247. rightOperand: ShaderDefineExpression;
  69248. isTrue(preprocessors: {
  69249. [key: string]: string;
  69250. }): boolean;
  69251. }
  69252. }
  69253. declare module BABYLON {
  69254. /** @hidden */
  69255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69256. define: string;
  69257. operand: string;
  69258. testValue: string;
  69259. constructor(define: string, operand: string, testValue: string);
  69260. isTrue(preprocessors: {
  69261. [key: string]: string;
  69262. }): boolean;
  69263. }
  69264. }
  69265. declare module BABYLON {
  69266. /**
  69267. * Class used to enable access to offline support
  69268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69269. */
  69270. export interface IOfflineProvider {
  69271. /**
  69272. * Gets a boolean indicating if scene must be saved in the database
  69273. */
  69274. enableSceneOffline: boolean;
  69275. /**
  69276. * Gets a boolean indicating if textures must be saved in the database
  69277. */
  69278. enableTexturesOffline: boolean;
  69279. /**
  69280. * Open the offline support and make it available
  69281. * @param successCallback defines the callback to call on success
  69282. * @param errorCallback defines the callback to call on error
  69283. */
  69284. open(successCallback: () => void, errorCallback: () => void): void;
  69285. /**
  69286. * Loads an image from the offline support
  69287. * @param url defines the url to load from
  69288. * @param image defines the target DOM image
  69289. */
  69290. loadImage(url: string, image: HTMLImageElement): void;
  69291. /**
  69292. * Loads a file from offline support
  69293. * @param url defines the URL to load from
  69294. * @param sceneLoaded defines a callback to call on success
  69295. * @param progressCallBack defines a callback to call when progress changed
  69296. * @param errorCallback defines a callback to call on error
  69297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69298. */
  69299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69300. }
  69301. }
  69302. declare module BABYLON {
  69303. /**
  69304. * Class used to help managing file picking and drag'n'drop
  69305. * File Storage
  69306. */
  69307. export class FilesInputStore {
  69308. /**
  69309. * List of files ready to be loaded
  69310. */
  69311. static FilesToLoad: {
  69312. [key: string]: File;
  69313. };
  69314. }
  69315. }
  69316. declare module BABYLON {
  69317. /**
  69318. * Class used to define a retry strategy when error happens while loading assets
  69319. */
  69320. export class RetryStrategy {
  69321. /**
  69322. * Function used to defines an exponential back off strategy
  69323. * @param maxRetries defines the maximum number of retries (3 by default)
  69324. * @param baseInterval defines the interval between retries
  69325. * @returns the strategy function to use
  69326. */
  69327. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69328. }
  69329. }
  69330. declare module BABYLON {
  69331. /**
  69332. * @ignore
  69333. * Application error to support additional information when loading a file
  69334. */
  69335. export abstract class BaseError extends Error {
  69336. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69337. }
  69338. }
  69339. declare module BABYLON {
  69340. /** @ignore */
  69341. export class LoadFileError extends BaseError {
  69342. request?: WebRequest;
  69343. file?: File;
  69344. /**
  69345. * Creates a new LoadFileError
  69346. * @param message defines the message of the error
  69347. * @param request defines the optional web request
  69348. * @param file defines the optional file
  69349. */
  69350. constructor(message: string, object?: WebRequest | File);
  69351. }
  69352. /** @ignore */
  69353. export class RequestFileError extends BaseError {
  69354. request: WebRequest;
  69355. /**
  69356. * Creates a new LoadFileError
  69357. * @param message defines the message of the error
  69358. * @param request defines the optional web request
  69359. */
  69360. constructor(message: string, request: WebRequest);
  69361. }
  69362. /** @ignore */
  69363. export class ReadFileError extends BaseError {
  69364. file: File;
  69365. /**
  69366. * Creates a new ReadFileError
  69367. * @param message defines the message of the error
  69368. * @param file defines the optional file
  69369. */
  69370. constructor(message: string, file: File);
  69371. }
  69372. /**
  69373. * @hidden
  69374. */
  69375. export class FileTools {
  69376. /**
  69377. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69378. */
  69379. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69380. /**
  69381. * Gets or sets the base URL to use to load assets
  69382. */
  69383. static BaseUrl: string;
  69384. /**
  69385. * Default behaviour for cors in the application.
  69386. * It can be a string if the expected behavior is identical in the entire app.
  69387. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69388. */
  69389. static CorsBehavior: string | ((url: string | string[]) => string);
  69390. /**
  69391. * Gets or sets a function used to pre-process url before using them to load assets
  69392. */
  69393. static PreprocessUrl: (url: string) => string;
  69394. /**
  69395. * Removes unwanted characters from an url
  69396. * @param url defines the url to clean
  69397. * @returns the cleaned url
  69398. */
  69399. private static _CleanUrl;
  69400. /**
  69401. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69402. * @param url define the url we are trying
  69403. * @param element define the dom element where to configure the cors policy
  69404. */
  69405. static SetCorsBehavior(url: string | string[], element: {
  69406. crossOrigin: string | null;
  69407. }): void;
  69408. /**
  69409. * Loads an image as an HTMLImageElement.
  69410. * @param input url string, ArrayBuffer, or Blob to load
  69411. * @param onLoad callback called when the image successfully loads
  69412. * @param onError callback called when the image fails to load
  69413. * @param offlineProvider offline provider for caching
  69414. * @param mimeType optional mime type
  69415. * @returns the HTMLImageElement of the loaded image
  69416. */
  69417. 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>;
  69418. /**
  69419. * Reads a file from a File object
  69420. * @param file defines the file to load
  69421. * @param onSuccess defines the callback to call when data is loaded
  69422. * @param onProgress defines the callback to call during loading process
  69423. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69424. * @param onError defines the callback to call when an error occurs
  69425. * @returns a file request object
  69426. */
  69427. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69428. /**
  69429. * Loads a file from a url
  69430. * @param url url to load
  69431. * @param onSuccess callback called when the file successfully loads
  69432. * @param onProgress callback called while file is loading (if the server supports this mode)
  69433. * @param offlineProvider defines the offline provider for caching
  69434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69435. * @param onError callback called when the file fails to load
  69436. * @returns a file request object
  69437. */
  69438. 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;
  69439. /**
  69440. * Loads a file
  69441. * @param url url to load
  69442. * @param onSuccess callback called when the file successfully loads
  69443. * @param onProgress callback called while file is loading (if the server supports this mode)
  69444. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69445. * @param onError callback called when the file fails to load
  69446. * @param onOpened callback called when the web request is opened
  69447. * @returns a file request object
  69448. */
  69449. 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;
  69450. /**
  69451. * Checks if the loaded document was accessed via `file:`-Protocol.
  69452. * @returns boolean
  69453. */
  69454. static IsFileURL(): boolean;
  69455. }
  69456. }
  69457. declare module BABYLON {
  69458. /** @hidden */
  69459. export class ShaderProcessor {
  69460. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69461. private static _ProcessPrecision;
  69462. private static _ExtractOperation;
  69463. private static _BuildSubExpression;
  69464. private static _BuildExpression;
  69465. private static _MoveCursorWithinIf;
  69466. private static _MoveCursor;
  69467. private static _EvaluatePreProcessors;
  69468. private static _PreparePreProcessors;
  69469. private static _ProcessShaderConversion;
  69470. private static _ProcessIncludes;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. /**
  69475. * @hidden
  69476. */
  69477. export interface IColor4Like {
  69478. r: float;
  69479. g: float;
  69480. b: float;
  69481. a: float;
  69482. }
  69483. /**
  69484. * @hidden
  69485. */
  69486. export interface IColor3Like {
  69487. r: float;
  69488. g: float;
  69489. b: float;
  69490. }
  69491. /**
  69492. * @hidden
  69493. */
  69494. export interface IVector4Like {
  69495. x: float;
  69496. y: float;
  69497. z: float;
  69498. w: float;
  69499. }
  69500. /**
  69501. * @hidden
  69502. */
  69503. export interface IVector3Like {
  69504. x: float;
  69505. y: float;
  69506. z: float;
  69507. }
  69508. /**
  69509. * @hidden
  69510. */
  69511. export interface IVector2Like {
  69512. x: float;
  69513. y: float;
  69514. }
  69515. /**
  69516. * @hidden
  69517. */
  69518. export interface IMatrixLike {
  69519. toArray(): DeepImmutable<Float32Array>;
  69520. updateFlag: int;
  69521. }
  69522. /**
  69523. * @hidden
  69524. */
  69525. export interface IViewportLike {
  69526. x: float;
  69527. y: float;
  69528. width: float;
  69529. height: float;
  69530. }
  69531. /**
  69532. * @hidden
  69533. */
  69534. export interface IPlaneLike {
  69535. normal: IVector3Like;
  69536. d: float;
  69537. normalize(): void;
  69538. }
  69539. }
  69540. declare module BABYLON {
  69541. /**
  69542. * Interface used to define common properties for effect fallbacks
  69543. */
  69544. export interface IEffectFallbacks {
  69545. /**
  69546. * Removes the defines that should be removed when falling back.
  69547. * @param currentDefines defines the current define statements for the shader.
  69548. * @param effect defines the current effect we try to compile
  69549. * @returns The resulting defines with defines of the current rank removed.
  69550. */
  69551. reduce(currentDefines: string, effect: Effect): string;
  69552. /**
  69553. * Removes the fallback from the bound mesh.
  69554. */
  69555. unBindMesh(): void;
  69556. /**
  69557. * Checks to see if more fallbacks are still availible.
  69558. */
  69559. hasMoreFallbacks: boolean;
  69560. }
  69561. }
  69562. declare module BABYLON {
  69563. /**
  69564. * Class used to evalaute queries containing `and` and `or` operators
  69565. */
  69566. export class AndOrNotEvaluator {
  69567. /**
  69568. * Evaluate a query
  69569. * @param query defines the query to evaluate
  69570. * @param evaluateCallback defines the callback used to filter result
  69571. * @returns true if the query matches
  69572. */
  69573. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69574. private static _HandleParenthesisContent;
  69575. private static _SimplifyNegation;
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /**
  69580. * Class used to store custom tags
  69581. */
  69582. export class Tags {
  69583. /**
  69584. * Adds support for tags on the given object
  69585. * @param obj defines the object to use
  69586. */
  69587. static EnableFor(obj: any): void;
  69588. /**
  69589. * Removes tags support
  69590. * @param obj defines the object to use
  69591. */
  69592. static DisableFor(obj: any): void;
  69593. /**
  69594. * Gets a boolean indicating if the given object has tags
  69595. * @param obj defines the object to use
  69596. * @returns a boolean
  69597. */
  69598. static HasTags(obj: any): boolean;
  69599. /**
  69600. * Gets the tags available on a given object
  69601. * @param obj defines the object to use
  69602. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69603. * @returns the tags
  69604. */
  69605. static GetTags(obj: any, asString?: boolean): any;
  69606. /**
  69607. * Adds tags to an object
  69608. * @param obj defines the object to use
  69609. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69610. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69611. */
  69612. static AddTagsTo(obj: any, tagsString: string): void;
  69613. /**
  69614. * @hidden
  69615. */
  69616. static _AddTagTo(obj: any, tag: string): void;
  69617. /**
  69618. * Removes specific tags from a specific object
  69619. * @param obj defines the object to use
  69620. * @param tagsString defines the tags to remove
  69621. */
  69622. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69623. /**
  69624. * @hidden
  69625. */
  69626. static _RemoveTagFrom(obj: any, tag: string): void;
  69627. /**
  69628. * Defines if tags hosted on an object match a given query
  69629. * @param obj defines the object to use
  69630. * @param tagsQuery defines the tag query
  69631. * @returns a boolean
  69632. */
  69633. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69634. }
  69635. }
  69636. declare module BABYLON {
  69637. /**
  69638. * Scalar computation library
  69639. */
  69640. export class Scalar {
  69641. /**
  69642. * Two pi constants convenient for computation.
  69643. */
  69644. static TwoPi: number;
  69645. /**
  69646. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69647. * @param a number
  69648. * @param b number
  69649. * @param epsilon (default = 1.401298E-45)
  69650. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69651. */
  69652. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69653. /**
  69654. * Returns a string : the upper case translation of the number i to hexadecimal.
  69655. * @param i number
  69656. * @returns the upper case translation of the number i to hexadecimal.
  69657. */
  69658. static ToHex(i: number): string;
  69659. /**
  69660. * Returns -1 if value is negative and +1 is value is positive.
  69661. * @param value the value
  69662. * @returns the value itself if it's equal to zero.
  69663. */
  69664. static Sign(value: number): number;
  69665. /**
  69666. * Returns the value itself if it's between min and max.
  69667. * Returns min if the value is lower than min.
  69668. * Returns max if the value is greater than max.
  69669. * @param value the value to clmap
  69670. * @param min the min value to clamp to (default: 0)
  69671. * @param max the max value to clamp to (default: 1)
  69672. * @returns the clamped value
  69673. */
  69674. static Clamp(value: number, min?: number, max?: number): number;
  69675. /**
  69676. * the log2 of value.
  69677. * @param value the value to compute log2 of
  69678. * @returns the log2 of value.
  69679. */
  69680. static Log2(value: number): number;
  69681. /**
  69682. * Loops the value, so that it is never larger than length and never smaller than 0.
  69683. *
  69684. * This is similar to the modulo operator but it works with floating point numbers.
  69685. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69686. * With t = 5 and length = 2.5, the result would be 0.0.
  69687. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69688. * @param value the value
  69689. * @param length the length
  69690. * @returns the looped value
  69691. */
  69692. static Repeat(value: number, length: number): number;
  69693. /**
  69694. * Normalize the value between 0.0 and 1.0 using min and max values
  69695. * @param value value to normalize
  69696. * @param min max to normalize between
  69697. * @param max min to normalize between
  69698. * @returns the normalized value
  69699. */
  69700. static Normalize(value: number, min: number, max: number): number;
  69701. /**
  69702. * Denormalize the value from 0.0 and 1.0 using min and max values
  69703. * @param normalized value to denormalize
  69704. * @param min max to denormalize between
  69705. * @param max min to denormalize between
  69706. * @returns the denormalized value
  69707. */
  69708. static Denormalize(normalized: number, min: number, max: number): number;
  69709. /**
  69710. * Calculates the shortest difference between two given angles given in degrees.
  69711. * @param current current angle in degrees
  69712. * @param target target angle in degrees
  69713. * @returns the delta
  69714. */
  69715. static DeltaAngle(current: number, target: number): number;
  69716. /**
  69717. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69718. * @param tx value
  69719. * @param length length
  69720. * @returns The returned value will move back and forth between 0 and length
  69721. */
  69722. static PingPong(tx: number, length: number): number;
  69723. /**
  69724. * Interpolates between min and max with smoothing at the limits.
  69725. *
  69726. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69727. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69728. * @param from from
  69729. * @param to to
  69730. * @param tx value
  69731. * @returns the smooth stepped value
  69732. */
  69733. static SmoothStep(from: number, to: number, tx: number): number;
  69734. /**
  69735. * Moves a value current towards target.
  69736. *
  69737. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69738. * Negative values of maxDelta pushes the value away from target.
  69739. * @param current current value
  69740. * @param target target value
  69741. * @param maxDelta max distance to move
  69742. * @returns resulting value
  69743. */
  69744. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69745. /**
  69746. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69747. *
  69748. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69749. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69750. * @param current current value
  69751. * @param target target value
  69752. * @param maxDelta max distance to move
  69753. * @returns resulting angle
  69754. */
  69755. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69756. /**
  69757. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69758. * @param start start value
  69759. * @param end target value
  69760. * @param amount amount to lerp between
  69761. * @returns the lerped value
  69762. */
  69763. static Lerp(start: number, end: number, amount: number): number;
  69764. /**
  69765. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69766. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69767. * @param start start value
  69768. * @param end target value
  69769. * @param amount amount to lerp between
  69770. * @returns the lerped value
  69771. */
  69772. static LerpAngle(start: number, end: number, amount: number): number;
  69773. /**
  69774. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69775. * @param a start value
  69776. * @param b target value
  69777. * @param value value between a and b
  69778. * @returns the inverseLerp value
  69779. */
  69780. static InverseLerp(a: number, b: number, value: number): number;
  69781. /**
  69782. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69783. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69784. * @param value1 spline value
  69785. * @param tangent1 spline value
  69786. * @param value2 spline value
  69787. * @param tangent2 spline value
  69788. * @param amount input value
  69789. * @returns hermite result
  69790. */
  69791. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69792. /**
  69793. * Returns a random float number between and min and max values
  69794. * @param min min value of random
  69795. * @param max max value of random
  69796. * @returns random value
  69797. */
  69798. static RandomRange(min: number, max: number): number;
  69799. /**
  69800. * This function returns percentage of a number in a given range.
  69801. *
  69802. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69803. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69804. * @param number to convert to percentage
  69805. * @param min min range
  69806. * @param max max range
  69807. * @returns the percentage
  69808. */
  69809. static RangeToPercent(number: number, min: number, max: number): number;
  69810. /**
  69811. * This function returns number that corresponds to the percentage in a given range.
  69812. *
  69813. * PercentToRange(0.34,0,100) will return 34.
  69814. * @param percent to convert to number
  69815. * @param min min range
  69816. * @param max max range
  69817. * @returns the number
  69818. */
  69819. static PercentToRange(percent: number, min: number, max: number): number;
  69820. /**
  69821. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69822. * @param angle The angle to normalize in radian.
  69823. * @return The converted angle.
  69824. */
  69825. static NormalizeRadians(angle: number): number;
  69826. }
  69827. }
  69828. declare module BABYLON {
  69829. /**
  69830. * Constant used to convert a value to gamma space
  69831. * @ignorenaming
  69832. */
  69833. export const ToGammaSpace: number;
  69834. /**
  69835. * Constant used to convert a value to linear space
  69836. * @ignorenaming
  69837. */
  69838. export const ToLinearSpace = 2.2;
  69839. /**
  69840. * Constant used to define the minimal number value in Babylon.js
  69841. * @ignorenaming
  69842. */
  69843. let Epsilon: number;
  69844. }
  69845. declare module BABYLON {
  69846. /**
  69847. * Class used to represent a viewport on screen
  69848. */
  69849. export class Viewport {
  69850. /** viewport left coordinate */
  69851. x: number;
  69852. /** viewport top coordinate */
  69853. y: number;
  69854. /**viewport width */
  69855. width: number;
  69856. /** viewport height */
  69857. height: number;
  69858. /**
  69859. * Creates a Viewport object located at (x, y) and sized (width, height)
  69860. * @param x defines viewport left coordinate
  69861. * @param y defines viewport top coordinate
  69862. * @param width defines the viewport width
  69863. * @param height defines the viewport height
  69864. */
  69865. constructor(
  69866. /** viewport left coordinate */
  69867. x: number,
  69868. /** viewport top coordinate */
  69869. y: number,
  69870. /**viewport width */
  69871. width: number,
  69872. /** viewport height */
  69873. height: number);
  69874. /**
  69875. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69876. * @param renderWidth defines the rendering width
  69877. * @param renderHeight defines the rendering height
  69878. * @returns a new Viewport
  69879. */
  69880. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69881. /**
  69882. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69883. * @param renderWidth defines the rendering width
  69884. * @param renderHeight defines the rendering height
  69885. * @param ref defines the target viewport
  69886. * @returns the current viewport
  69887. */
  69888. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69889. /**
  69890. * Returns a new Viewport copied from the current one
  69891. * @returns a new Viewport
  69892. */
  69893. clone(): Viewport;
  69894. }
  69895. }
  69896. declare module BABYLON {
  69897. /**
  69898. * Class containing a set of static utilities functions for arrays.
  69899. */
  69900. export class ArrayTools {
  69901. /**
  69902. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69903. * @param size the number of element to construct and put in the array
  69904. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69905. * @returns a new array filled with new objects
  69906. */
  69907. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69908. }
  69909. }
  69910. declare module BABYLON {
  69911. /**
  69912. * Class representing a vector containing 2 coordinates
  69913. */
  69914. export class Vector2 {
  69915. /** defines the first coordinate */
  69916. x: number;
  69917. /** defines the second coordinate */
  69918. y: number;
  69919. /**
  69920. * Creates a new Vector2 from the given x and y coordinates
  69921. * @param x defines the first coordinate
  69922. * @param y defines the second coordinate
  69923. */
  69924. constructor(
  69925. /** defines the first coordinate */
  69926. x?: number,
  69927. /** defines the second coordinate */
  69928. y?: number);
  69929. /**
  69930. * Gets a string with the Vector2 coordinates
  69931. * @returns a string with the Vector2 coordinates
  69932. */
  69933. toString(): string;
  69934. /**
  69935. * Gets class name
  69936. * @returns the string "Vector2"
  69937. */
  69938. getClassName(): string;
  69939. /**
  69940. * Gets current vector hash code
  69941. * @returns the Vector2 hash code as a number
  69942. */
  69943. getHashCode(): number;
  69944. /**
  69945. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69946. * @param array defines the source array
  69947. * @param index defines the offset in source array
  69948. * @returns the current Vector2
  69949. */
  69950. toArray(array: FloatArray, index?: number): Vector2;
  69951. /**
  69952. * Copy the current vector to an array
  69953. * @returns a new array with 2 elements: the Vector2 coordinates.
  69954. */
  69955. asArray(): number[];
  69956. /**
  69957. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69958. * @param source defines the source Vector2
  69959. * @returns the current updated Vector2
  69960. */
  69961. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69962. /**
  69963. * Sets the Vector2 coordinates with the given floats
  69964. * @param x defines the first coordinate
  69965. * @param y defines the second coordinate
  69966. * @returns the current updated Vector2
  69967. */
  69968. copyFromFloats(x: number, y: number): Vector2;
  69969. /**
  69970. * Sets the Vector2 coordinates with the given floats
  69971. * @param x defines the first coordinate
  69972. * @param y defines the second coordinate
  69973. * @returns the current updated Vector2
  69974. */
  69975. set(x: number, y: number): Vector2;
  69976. /**
  69977. * Add another vector with the current one
  69978. * @param otherVector defines the other vector
  69979. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69980. */
  69981. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69982. /**
  69983. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69984. * @param otherVector defines the other vector
  69985. * @param result defines the target vector
  69986. * @returns the unmodified current Vector2
  69987. */
  69988. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69989. /**
  69990. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69991. * @param otherVector defines the other vector
  69992. * @returns the current updated Vector2
  69993. */
  69994. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69995. /**
  69996. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69997. * @param otherVector defines the other vector
  69998. * @returns a new Vector2
  69999. */
  70000. addVector3(otherVector: Vector3): Vector2;
  70001. /**
  70002. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70003. * @param otherVector defines the other vector
  70004. * @returns a new Vector2
  70005. */
  70006. subtract(otherVector: Vector2): Vector2;
  70007. /**
  70008. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70009. * @param otherVector defines the other vector
  70010. * @param result defines the target vector
  70011. * @returns the unmodified current Vector2
  70012. */
  70013. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70014. /**
  70015. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70016. * @param otherVector defines the other vector
  70017. * @returns the current updated Vector2
  70018. */
  70019. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70020. /**
  70021. * Multiplies in place the current Vector2 coordinates by the given ones
  70022. * @param otherVector defines the other vector
  70023. * @returns the current updated Vector2
  70024. */
  70025. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70026. /**
  70027. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70028. * @param otherVector defines the other vector
  70029. * @returns a new Vector2
  70030. */
  70031. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70032. /**
  70033. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70034. * @param otherVector defines the other vector
  70035. * @param result defines the target vector
  70036. * @returns the unmodified current Vector2
  70037. */
  70038. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70039. /**
  70040. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70041. * @param x defines the first coordinate
  70042. * @param y defines the second coordinate
  70043. * @returns a new Vector2
  70044. */
  70045. multiplyByFloats(x: number, y: number): Vector2;
  70046. /**
  70047. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70048. * @param otherVector defines the other vector
  70049. * @returns a new Vector2
  70050. */
  70051. divide(otherVector: Vector2): Vector2;
  70052. /**
  70053. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70054. * @param otherVector defines the other vector
  70055. * @param result defines the target vector
  70056. * @returns the unmodified current Vector2
  70057. */
  70058. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70059. /**
  70060. * Divides the current Vector2 coordinates by the given ones
  70061. * @param otherVector defines the other vector
  70062. * @returns the current updated Vector2
  70063. */
  70064. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70065. /**
  70066. * Gets a new Vector2 with current Vector2 negated coordinates
  70067. * @returns a new Vector2
  70068. */
  70069. negate(): Vector2;
  70070. /**
  70071. * Multiply the Vector2 coordinates by scale
  70072. * @param scale defines the scaling factor
  70073. * @returns the current updated Vector2
  70074. */
  70075. scaleInPlace(scale: number): Vector2;
  70076. /**
  70077. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70078. * @param scale defines the scaling factor
  70079. * @returns a new Vector2
  70080. */
  70081. scale(scale: number): Vector2;
  70082. /**
  70083. * Scale the current Vector2 values by a factor to a given Vector2
  70084. * @param scale defines the scale factor
  70085. * @param result defines the Vector2 object where to store the result
  70086. * @returns the unmodified current Vector2
  70087. */
  70088. scaleToRef(scale: number, result: Vector2): Vector2;
  70089. /**
  70090. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70091. * @param scale defines the scale factor
  70092. * @param result defines the Vector2 object where to store the result
  70093. * @returns the unmodified current Vector2
  70094. */
  70095. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70096. /**
  70097. * Gets a boolean if two vectors are equals
  70098. * @param otherVector defines the other vector
  70099. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70100. */
  70101. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70102. /**
  70103. * Gets a boolean if two vectors are equals (using an epsilon value)
  70104. * @param otherVector defines the other vector
  70105. * @param epsilon defines the minimal distance to consider equality
  70106. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70107. */
  70108. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70109. /**
  70110. * Gets a new Vector2 from current Vector2 floored values
  70111. * @returns a new Vector2
  70112. */
  70113. floor(): Vector2;
  70114. /**
  70115. * Gets a new Vector2 from current Vector2 floored values
  70116. * @returns a new Vector2
  70117. */
  70118. fract(): Vector2;
  70119. /**
  70120. * Gets the length of the vector
  70121. * @returns the vector length (float)
  70122. */
  70123. length(): number;
  70124. /**
  70125. * Gets the vector squared length
  70126. * @returns the vector squared length (float)
  70127. */
  70128. lengthSquared(): number;
  70129. /**
  70130. * Normalize the vector
  70131. * @returns the current updated Vector2
  70132. */
  70133. normalize(): Vector2;
  70134. /**
  70135. * Gets a new Vector2 copied from the Vector2
  70136. * @returns a new Vector2
  70137. */
  70138. clone(): Vector2;
  70139. /**
  70140. * Gets a new Vector2(0, 0)
  70141. * @returns a new Vector2
  70142. */
  70143. static Zero(): Vector2;
  70144. /**
  70145. * Gets a new Vector2(1, 1)
  70146. * @returns a new Vector2
  70147. */
  70148. static One(): Vector2;
  70149. /**
  70150. * Gets a new Vector2 set from the given index element of the given array
  70151. * @param array defines the data source
  70152. * @param offset defines the offset in the data source
  70153. * @returns a new Vector2
  70154. */
  70155. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70156. /**
  70157. * Sets "result" from the given index element of the given array
  70158. * @param array defines the data source
  70159. * @param offset defines the offset in the data source
  70160. * @param result defines the target vector
  70161. */
  70162. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70163. /**
  70164. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70165. * @param value1 defines 1st point of control
  70166. * @param value2 defines 2nd point of control
  70167. * @param value3 defines 3rd point of control
  70168. * @param value4 defines 4th point of control
  70169. * @param amount defines the interpolation factor
  70170. * @returns a new Vector2
  70171. */
  70172. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70173. /**
  70174. * 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".
  70175. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70176. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70177. * @param value defines the value to clamp
  70178. * @param min defines the lower limit
  70179. * @param max defines the upper limit
  70180. * @returns a new Vector2
  70181. */
  70182. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70183. /**
  70184. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70185. * @param value1 defines the 1st control point
  70186. * @param tangent1 defines the outgoing tangent
  70187. * @param value2 defines the 2nd control point
  70188. * @param tangent2 defines the incoming tangent
  70189. * @param amount defines the interpolation factor
  70190. * @returns a new Vector2
  70191. */
  70192. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70193. /**
  70194. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70195. * @param start defines the start vector
  70196. * @param end defines the end vector
  70197. * @param amount defines the interpolation factor
  70198. * @returns a new Vector2
  70199. */
  70200. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70201. /**
  70202. * Gets the dot product of the vector "left" and the vector "right"
  70203. * @param left defines first vector
  70204. * @param right defines second vector
  70205. * @returns the dot product (float)
  70206. */
  70207. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70208. /**
  70209. * Returns a new Vector2 equal to the normalized given vector
  70210. * @param vector defines the vector to normalize
  70211. * @returns a new Vector2
  70212. */
  70213. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70214. /**
  70215. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70216. * @param left defines 1st vector
  70217. * @param right defines 2nd vector
  70218. * @returns a new Vector2
  70219. */
  70220. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70221. /**
  70222. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70223. * @param left defines 1st vector
  70224. * @param right defines 2nd vector
  70225. * @returns a new Vector2
  70226. */
  70227. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70228. /**
  70229. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70230. * @param vector defines the vector to transform
  70231. * @param transformation defines the matrix to apply
  70232. * @returns a new Vector2
  70233. */
  70234. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70235. /**
  70236. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70237. * @param vector defines the vector to transform
  70238. * @param transformation defines the matrix to apply
  70239. * @param result defines the target vector
  70240. */
  70241. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70242. /**
  70243. * Determines if a given vector is included in a triangle
  70244. * @param p defines the vector to test
  70245. * @param p0 defines 1st triangle point
  70246. * @param p1 defines 2nd triangle point
  70247. * @param p2 defines 3rd triangle point
  70248. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70249. */
  70250. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70251. /**
  70252. * Gets the distance between the vectors "value1" and "value2"
  70253. * @param value1 defines first vector
  70254. * @param value2 defines second vector
  70255. * @returns the distance between vectors
  70256. */
  70257. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70258. /**
  70259. * Returns the squared distance between the vectors "value1" and "value2"
  70260. * @param value1 defines first vector
  70261. * @param value2 defines second vector
  70262. * @returns the squared distance between vectors
  70263. */
  70264. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70265. /**
  70266. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70267. * @param value1 defines first vector
  70268. * @param value2 defines second vector
  70269. * @returns a new Vector2
  70270. */
  70271. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70272. /**
  70273. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70274. * @param p defines the middle point
  70275. * @param segA defines one point of the segment
  70276. * @param segB defines the other point of the segment
  70277. * @returns the shortest distance
  70278. */
  70279. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70280. }
  70281. /**
  70282. * Classed used to store (x,y,z) vector representation
  70283. * A Vector3 is the main object used in 3D geometry
  70284. * It can represent etiher the coordinates of a point the space, either a direction
  70285. * Reminder: js uses a left handed forward facing system
  70286. */
  70287. export class Vector3 {
  70288. /**
  70289. * Defines the first coordinates (on X axis)
  70290. */
  70291. x: number;
  70292. /**
  70293. * Defines the second coordinates (on Y axis)
  70294. */
  70295. y: number;
  70296. /**
  70297. * Defines the third coordinates (on Z axis)
  70298. */
  70299. z: number;
  70300. private static _UpReadOnly;
  70301. private static _ZeroReadOnly;
  70302. /**
  70303. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70304. * @param x defines the first coordinates (on X axis)
  70305. * @param y defines the second coordinates (on Y axis)
  70306. * @param z defines the third coordinates (on Z axis)
  70307. */
  70308. constructor(
  70309. /**
  70310. * Defines the first coordinates (on X axis)
  70311. */
  70312. x?: number,
  70313. /**
  70314. * Defines the second coordinates (on Y axis)
  70315. */
  70316. y?: number,
  70317. /**
  70318. * Defines the third coordinates (on Z axis)
  70319. */
  70320. z?: number);
  70321. /**
  70322. * Creates a string representation of the Vector3
  70323. * @returns a string with the Vector3 coordinates.
  70324. */
  70325. toString(): string;
  70326. /**
  70327. * Gets the class name
  70328. * @returns the string "Vector3"
  70329. */
  70330. getClassName(): string;
  70331. /**
  70332. * Creates the Vector3 hash code
  70333. * @returns a number which tends to be unique between Vector3 instances
  70334. */
  70335. getHashCode(): number;
  70336. /**
  70337. * Creates an array containing three elements : the coordinates of the Vector3
  70338. * @returns a new array of numbers
  70339. */
  70340. asArray(): number[];
  70341. /**
  70342. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70343. * @param array defines the destination array
  70344. * @param index defines the offset in the destination array
  70345. * @returns the current Vector3
  70346. */
  70347. toArray(array: FloatArray, index?: number): Vector3;
  70348. /**
  70349. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70350. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70351. */
  70352. toQuaternion(): Quaternion;
  70353. /**
  70354. * Adds the given vector to the current Vector3
  70355. * @param otherVector defines the second operand
  70356. * @returns the current updated Vector3
  70357. */
  70358. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70359. /**
  70360. * Adds the given coordinates to the current Vector3
  70361. * @param x defines the x coordinate of the operand
  70362. * @param y defines the y coordinate of the operand
  70363. * @param z defines the z coordinate of the operand
  70364. * @returns the current updated Vector3
  70365. */
  70366. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70367. /**
  70368. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70369. * @param otherVector defines the second operand
  70370. * @returns the resulting Vector3
  70371. */
  70372. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70373. /**
  70374. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70375. * @param otherVector defines the second operand
  70376. * @param result defines the Vector3 object where to store the result
  70377. * @returns the current Vector3
  70378. */
  70379. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70380. /**
  70381. * Subtract the given vector from the current Vector3
  70382. * @param otherVector defines the second operand
  70383. * @returns the current updated Vector3
  70384. */
  70385. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70386. /**
  70387. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70388. * @param otherVector defines the second operand
  70389. * @returns the resulting Vector3
  70390. */
  70391. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70392. /**
  70393. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70394. * @param otherVector defines the second operand
  70395. * @param result defines the Vector3 object where to store the result
  70396. * @returns the current Vector3
  70397. */
  70398. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70399. /**
  70400. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70401. * @param x defines the x coordinate of the operand
  70402. * @param y defines the y coordinate of the operand
  70403. * @param z defines the z coordinate of the operand
  70404. * @returns the resulting Vector3
  70405. */
  70406. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70407. /**
  70408. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70409. * @param x defines the x coordinate of the operand
  70410. * @param y defines the y coordinate of the operand
  70411. * @param z defines the z coordinate of the operand
  70412. * @param result defines the Vector3 object where to store the result
  70413. * @returns the current Vector3
  70414. */
  70415. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70416. /**
  70417. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70418. * @returns a new Vector3
  70419. */
  70420. negate(): Vector3;
  70421. /**
  70422. * Multiplies the Vector3 coordinates by the float "scale"
  70423. * @param scale defines the multiplier factor
  70424. * @returns the current updated Vector3
  70425. */
  70426. scaleInPlace(scale: number): Vector3;
  70427. /**
  70428. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70429. * @param scale defines the multiplier factor
  70430. * @returns a new Vector3
  70431. */
  70432. scale(scale: number): Vector3;
  70433. /**
  70434. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70435. * @param scale defines the multiplier factor
  70436. * @param result defines the Vector3 object where to store the result
  70437. * @returns the current Vector3
  70438. */
  70439. scaleToRef(scale: number, result: Vector3): Vector3;
  70440. /**
  70441. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70442. * @param scale defines the scale factor
  70443. * @param result defines the Vector3 object where to store the result
  70444. * @returns the unmodified current Vector3
  70445. */
  70446. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70447. /**
  70448. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70449. * @param otherVector defines the second operand
  70450. * @returns true if both vectors are equals
  70451. */
  70452. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70453. /**
  70454. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70455. * @param otherVector defines the second operand
  70456. * @param epsilon defines the minimal distance to define values as equals
  70457. * @returns true if both vectors are distant less than epsilon
  70458. */
  70459. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70460. /**
  70461. * Returns true if the current Vector3 coordinates equals the given floats
  70462. * @param x defines the x coordinate of the operand
  70463. * @param y defines the y coordinate of the operand
  70464. * @param z defines the z coordinate of the operand
  70465. * @returns true if both vectors are equals
  70466. */
  70467. equalsToFloats(x: number, y: number, z: number): boolean;
  70468. /**
  70469. * Multiplies the current Vector3 coordinates by the given ones
  70470. * @param otherVector defines the second operand
  70471. * @returns the current updated Vector3
  70472. */
  70473. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70474. /**
  70475. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70476. * @param otherVector defines the second operand
  70477. * @returns the new Vector3
  70478. */
  70479. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70480. /**
  70481. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70482. * @param otherVector defines the second operand
  70483. * @param result defines the Vector3 object where to store the result
  70484. * @returns the current Vector3
  70485. */
  70486. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70487. /**
  70488. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70489. * @param x defines the x coordinate of the operand
  70490. * @param y defines the y coordinate of the operand
  70491. * @param z defines the z coordinate of the operand
  70492. * @returns the new Vector3
  70493. */
  70494. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70495. /**
  70496. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70497. * @param otherVector defines the second operand
  70498. * @returns the new Vector3
  70499. */
  70500. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70501. /**
  70502. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70503. * @param otherVector defines the second operand
  70504. * @param result defines the Vector3 object where to store the result
  70505. * @returns the current Vector3
  70506. */
  70507. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70508. /**
  70509. * Divides the current Vector3 coordinates by the given ones.
  70510. * @param otherVector defines the second operand
  70511. * @returns the current updated Vector3
  70512. */
  70513. divideInPlace(otherVector: Vector3): Vector3;
  70514. /**
  70515. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70516. * @param other defines the second operand
  70517. * @returns the current updated Vector3
  70518. */
  70519. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70520. /**
  70521. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70522. * @param other defines the second operand
  70523. * @returns the current updated Vector3
  70524. */
  70525. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70526. /**
  70527. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70528. * @param x defines the x coordinate of the operand
  70529. * @param y defines the y coordinate of the operand
  70530. * @param z defines the z coordinate of the operand
  70531. * @returns the current updated Vector3
  70532. */
  70533. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70534. /**
  70535. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70536. * @param x defines the x coordinate of the operand
  70537. * @param y defines the y coordinate of the operand
  70538. * @param z defines the z coordinate of the operand
  70539. * @returns the current updated Vector3
  70540. */
  70541. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70542. /**
  70543. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70544. * Check if is non uniform within a certain amount of decimal places to account for this
  70545. * @param epsilon the amount the values can differ
  70546. * @returns if the the vector is non uniform to a certain number of decimal places
  70547. */
  70548. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70549. /**
  70550. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70551. */
  70552. readonly isNonUniform: boolean;
  70553. /**
  70554. * Gets a new Vector3 from current Vector3 floored values
  70555. * @returns a new Vector3
  70556. */
  70557. floor(): Vector3;
  70558. /**
  70559. * Gets a new Vector3 from current Vector3 floored values
  70560. * @returns a new Vector3
  70561. */
  70562. fract(): Vector3;
  70563. /**
  70564. * Gets the length of the Vector3
  70565. * @returns the length of the Vector3
  70566. */
  70567. length(): number;
  70568. /**
  70569. * Gets the squared length of the Vector3
  70570. * @returns squared length of the Vector3
  70571. */
  70572. lengthSquared(): number;
  70573. /**
  70574. * Normalize the current Vector3.
  70575. * Please note that this is an in place operation.
  70576. * @returns the current updated Vector3
  70577. */
  70578. normalize(): Vector3;
  70579. /**
  70580. * Reorders the x y z properties of the vector in place
  70581. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70582. * @returns the current updated vector
  70583. */
  70584. reorderInPlace(order: string): this;
  70585. /**
  70586. * Rotates the vector around 0,0,0 by a quaternion
  70587. * @param quaternion the rotation quaternion
  70588. * @param result vector to store the result
  70589. * @returns the resulting vector
  70590. */
  70591. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70592. /**
  70593. * Rotates a vector around a given point
  70594. * @param quaternion the rotation quaternion
  70595. * @param point the point to rotate around
  70596. * @param result vector to store the result
  70597. * @returns the resulting vector
  70598. */
  70599. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70600. /**
  70601. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70602. * The cross product is then orthogonal to both current and "other"
  70603. * @param other defines the right operand
  70604. * @returns the cross product
  70605. */
  70606. cross(other: Vector3): Vector3;
  70607. /**
  70608. * Normalize the current Vector3 with the given input length.
  70609. * Please note that this is an in place operation.
  70610. * @param len the length of the vector
  70611. * @returns the current updated Vector3
  70612. */
  70613. normalizeFromLength(len: number): Vector3;
  70614. /**
  70615. * Normalize the current Vector3 to a new vector
  70616. * @returns the new Vector3
  70617. */
  70618. normalizeToNew(): Vector3;
  70619. /**
  70620. * Normalize the current Vector3 to the reference
  70621. * @param reference define the Vector3 to update
  70622. * @returns the updated Vector3
  70623. */
  70624. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70625. /**
  70626. * Creates a new Vector3 copied from the current Vector3
  70627. * @returns the new Vector3
  70628. */
  70629. clone(): Vector3;
  70630. /**
  70631. * Copies the given vector coordinates to the current Vector3 ones
  70632. * @param source defines the source Vector3
  70633. * @returns the current updated Vector3
  70634. */
  70635. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70636. /**
  70637. * Copies the given floats to the current Vector3 coordinates
  70638. * @param x defines the x coordinate of the operand
  70639. * @param y defines the y coordinate of the operand
  70640. * @param z defines the z coordinate of the operand
  70641. * @returns the current updated Vector3
  70642. */
  70643. copyFromFloats(x: number, y: number, z: number): Vector3;
  70644. /**
  70645. * Copies the given floats to the current Vector3 coordinates
  70646. * @param x defines the x coordinate of the operand
  70647. * @param y defines the y coordinate of the operand
  70648. * @param z defines the z coordinate of the operand
  70649. * @returns the current updated Vector3
  70650. */
  70651. set(x: number, y: number, z: number): Vector3;
  70652. /**
  70653. * Copies the given float to the current Vector3 coordinates
  70654. * @param v defines the x, y and z coordinates of the operand
  70655. * @returns the current updated Vector3
  70656. */
  70657. setAll(v: number): Vector3;
  70658. /**
  70659. * Get the clip factor between two vectors
  70660. * @param vector0 defines the first operand
  70661. * @param vector1 defines the second operand
  70662. * @param axis defines the axis to use
  70663. * @param size defines the size along the axis
  70664. * @returns the clip factor
  70665. */
  70666. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70667. /**
  70668. * Get angle between two vectors
  70669. * @param vector0 angle between vector0 and vector1
  70670. * @param vector1 angle between vector0 and vector1
  70671. * @param normal direction of the normal
  70672. * @return the angle between vector0 and vector1
  70673. */
  70674. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70675. /**
  70676. * Returns a new Vector3 set from the index "offset" of the given array
  70677. * @param array defines the source array
  70678. * @param offset defines the offset in the source array
  70679. * @returns the new Vector3
  70680. */
  70681. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70682. /**
  70683. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70684. * This function is deprecated. Use FromArray instead
  70685. * @param array defines the source array
  70686. * @param offset defines the offset in the source array
  70687. * @returns the new Vector3
  70688. */
  70689. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70690. /**
  70691. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70692. * @param array defines the source array
  70693. * @param offset defines the offset in the source array
  70694. * @param result defines the Vector3 where to store the result
  70695. */
  70696. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70697. /**
  70698. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70699. * This function is deprecated. Use FromArrayToRef instead.
  70700. * @param array defines the source array
  70701. * @param offset defines the offset in the source array
  70702. * @param result defines the Vector3 where to store the result
  70703. */
  70704. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70705. /**
  70706. * Sets the given vector "result" with the given floats.
  70707. * @param x defines the x coordinate of the source
  70708. * @param y defines the y coordinate of the source
  70709. * @param z defines the z coordinate of the source
  70710. * @param result defines the Vector3 where to store the result
  70711. */
  70712. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70713. /**
  70714. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70715. * @returns a new empty Vector3
  70716. */
  70717. static Zero(): Vector3;
  70718. /**
  70719. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70720. * @returns a new unit Vector3
  70721. */
  70722. static One(): Vector3;
  70723. /**
  70724. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70725. * @returns a new up Vector3
  70726. */
  70727. static Up(): Vector3;
  70728. /**
  70729. * Gets a up Vector3 that must not be updated
  70730. */
  70731. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70732. /**
  70733. * Gets a zero Vector3 that must not be updated
  70734. */
  70735. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70736. /**
  70737. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70738. * @returns a new down Vector3
  70739. */
  70740. static Down(): Vector3;
  70741. /**
  70742. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70743. * @returns a new forward Vector3
  70744. */
  70745. static Forward(): Vector3;
  70746. /**
  70747. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70748. * @returns a new forward Vector3
  70749. */
  70750. static Backward(): Vector3;
  70751. /**
  70752. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70753. * @returns a new right Vector3
  70754. */
  70755. static Right(): Vector3;
  70756. /**
  70757. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70758. * @returns a new left Vector3
  70759. */
  70760. static Left(): Vector3;
  70761. /**
  70762. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70763. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70764. * @param vector defines the Vector3 to transform
  70765. * @param transformation defines the transformation matrix
  70766. * @returns the transformed Vector3
  70767. */
  70768. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70769. /**
  70770. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70771. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70772. * @param vector defines the Vector3 to transform
  70773. * @param transformation defines the transformation matrix
  70774. * @param result defines the Vector3 where to store the result
  70775. */
  70776. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70777. /**
  70778. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70779. * This method computes tranformed coordinates only, not transformed direction vectors
  70780. * @param x define the x coordinate of the source vector
  70781. * @param y define the y coordinate of the source vector
  70782. * @param z define the z coordinate of the source vector
  70783. * @param transformation defines the transformation matrix
  70784. * @param result defines the Vector3 where to store the result
  70785. */
  70786. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70787. /**
  70788. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70789. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70790. * @param vector defines the Vector3 to transform
  70791. * @param transformation defines the transformation matrix
  70792. * @returns the new Vector3
  70793. */
  70794. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70795. /**
  70796. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70797. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70798. * @param vector defines the Vector3 to transform
  70799. * @param transformation defines the transformation matrix
  70800. * @param result defines the Vector3 where to store the result
  70801. */
  70802. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70803. /**
  70804. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70806. * @param x define the x coordinate of the source vector
  70807. * @param y define the y coordinate of the source vector
  70808. * @param z define the z coordinate of the source vector
  70809. * @param transformation defines the transformation matrix
  70810. * @param result defines the Vector3 where to store the result
  70811. */
  70812. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70813. /**
  70814. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70815. * @param value1 defines the first control point
  70816. * @param value2 defines the second control point
  70817. * @param value3 defines the third control point
  70818. * @param value4 defines the fourth control point
  70819. * @param amount defines the amount on the spline to use
  70820. * @returns the new Vector3
  70821. */
  70822. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70823. /**
  70824. * 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"
  70825. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70826. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70827. * @param value defines the current value
  70828. * @param min defines the lower range value
  70829. * @param max defines the upper range value
  70830. * @returns the new Vector3
  70831. */
  70832. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70833. /**
  70834. * 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"
  70835. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70836. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70837. * @param value defines the current value
  70838. * @param min defines the lower range value
  70839. * @param max defines the upper range value
  70840. * @param result defines the Vector3 where to store the result
  70841. */
  70842. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70843. /**
  70844. * Checks if a given vector is inside a specific range
  70845. * @param v defines the vector to test
  70846. * @param min defines the minimum range
  70847. * @param max defines the maximum range
  70848. */
  70849. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70850. /**
  70851. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70852. * @param value1 defines the first control point
  70853. * @param tangent1 defines the first tangent vector
  70854. * @param value2 defines the second control point
  70855. * @param tangent2 defines the second tangent vector
  70856. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70857. * @returns the new Vector3
  70858. */
  70859. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70860. /**
  70861. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70862. * @param start defines the start value
  70863. * @param end defines the end value
  70864. * @param amount max defines amount between both (between 0 and 1)
  70865. * @returns the new Vector3
  70866. */
  70867. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70868. /**
  70869. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70870. * @param start defines the start value
  70871. * @param end defines the end value
  70872. * @param amount max defines amount between both (between 0 and 1)
  70873. * @param result defines the Vector3 where to store the result
  70874. */
  70875. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70876. /**
  70877. * Returns the dot product (float) between the vectors "left" and "right"
  70878. * @param left defines the left operand
  70879. * @param right defines the right operand
  70880. * @returns the dot product
  70881. */
  70882. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70883. /**
  70884. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70885. * The cross product is then orthogonal to both "left" and "right"
  70886. * @param left defines the left operand
  70887. * @param right defines the right operand
  70888. * @returns the cross product
  70889. */
  70890. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70891. /**
  70892. * Sets the given vector "result" with the cross product of "left" and "right"
  70893. * The cross product is then orthogonal to both "left" and "right"
  70894. * @param left defines the left operand
  70895. * @param right defines the right operand
  70896. * @param result defines the Vector3 where to store the result
  70897. */
  70898. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70899. /**
  70900. * Returns a new Vector3 as the normalization of the given vector
  70901. * @param vector defines the Vector3 to normalize
  70902. * @returns the new Vector3
  70903. */
  70904. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70905. /**
  70906. * Sets the given vector "result" with the normalization of the given first vector
  70907. * @param vector defines the Vector3 to normalize
  70908. * @param result defines the Vector3 where to store the result
  70909. */
  70910. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70911. /**
  70912. * Project a Vector3 onto screen space
  70913. * @param vector defines the Vector3 to project
  70914. * @param world defines the world matrix to use
  70915. * @param transform defines the transform (view x projection) matrix to use
  70916. * @param viewport defines the screen viewport to use
  70917. * @returns the new Vector3
  70918. */
  70919. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70920. /** @hidden */
  70921. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70922. /**
  70923. * Unproject from screen space to object space
  70924. * @param source defines the screen space Vector3 to use
  70925. * @param viewportWidth defines the current width of the viewport
  70926. * @param viewportHeight defines the current height of the viewport
  70927. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70928. * @param transform defines the transform (view x projection) matrix to use
  70929. * @returns the new Vector3
  70930. */
  70931. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70932. /**
  70933. * Unproject from screen space to object space
  70934. * @param source defines the screen space Vector3 to use
  70935. * @param viewportWidth defines the current width of the viewport
  70936. * @param viewportHeight defines the current height of the viewport
  70937. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70938. * @param view defines the view matrix to use
  70939. * @param projection defines the projection matrix to use
  70940. * @returns the new Vector3
  70941. */
  70942. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70943. /**
  70944. * Unproject from screen space to object space
  70945. * @param source defines the screen space Vector3 to use
  70946. * @param viewportWidth defines the current width of the viewport
  70947. * @param viewportHeight defines the current height of the viewport
  70948. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70949. * @param view defines the view matrix to use
  70950. * @param projection defines the projection matrix to use
  70951. * @param result defines the Vector3 where to store the result
  70952. */
  70953. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70954. /**
  70955. * Unproject from screen space to object space
  70956. * @param sourceX defines the screen space x coordinate to use
  70957. * @param sourceY defines the screen space y coordinate to use
  70958. * @param sourceZ defines the screen space z coordinate to use
  70959. * @param viewportWidth defines the current width of the viewport
  70960. * @param viewportHeight defines the current height of the viewport
  70961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70962. * @param view defines the view matrix to use
  70963. * @param projection defines the projection matrix to use
  70964. * @param result defines the Vector3 where to store the result
  70965. */
  70966. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70967. /**
  70968. * Gets the minimal coordinate values between two Vector3
  70969. * @param left defines the first operand
  70970. * @param right defines the second operand
  70971. * @returns the new Vector3
  70972. */
  70973. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70974. /**
  70975. * Gets the maximal coordinate values between two Vector3
  70976. * @param left defines the first operand
  70977. * @param right defines the second operand
  70978. * @returns the new Vector3
  70979. */
  70980. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70981. /**
  70982. * Returns the distance between the vectors "value1" and "value2"
  70983. * @param value1 defines the first operand
  70984. * @param value2 defines the second operand
  70985. * @returns the distance
  70986. */
  70987. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70988. /**
  70989. * Returns the squared distance between the vectors "value1" and "value2"
  70990. * @param value1 defines the first operand
  70991. * @param value2 defines the second operand
  70992. * @returns the squared distance
  70993. */
  70994. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70995. /**
  70996. * Returns a new Vector3 located at the center between "value1" and "value2"
  70997. * @param value1 defines the first operand
  70998. * @param value2 defines the second operand
  70999. * @returns the new Vector3
  71000. */
  71001. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71002. /**
  71003. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71004. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71005. * to something in order to rotate it from its local system to the given target system
  71006. * Note: axis1, axis2 and axis3 are normalized during this operation
  71007. * @param axis1 defines the first axis
  71008. * @param axis2 defines the second axis
  71009. * @param axis3 defines the third axis
  71010. * @returns a new Vector3
  71011. */
  71012. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71013. /**
  71014. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71015. * @param axis1 defines the first axis
  71016. * @param axis2 defines the second axis
  71017. * @param axis3 defines the third axis
  71018. * @param ref defines the Vector3 where to store the result
  71019. */
  71020. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71021. }
  71022. /**
  71023. * Vector4 class created for EulerAngle class conversion to Quaternion
  71024. */
  71025. export class Vector4 {
  71026. /** x value of the vector */
  71027. x: number;
  71028. /** y value of the vector */
  71029. y: number;
  71030. /** z value of the vector */
  71031. z: number;
  71032. /** w value of the vector */
  71033. w: number;
  71034. /**
  71035. * Creates a Vector4 object from the given floats.
  71036. * @param x x value of the vector
  71037. * @param y y value of the vector
  71038. * @param z z value of the vector
  71039. * @param w w value of the vector
  71040. */
  71041. constructor(
  71042. /** x value of the vector */
  71043. x: number,
  71044. /** y value of the vector */
  71045. y: number,
  71046. /** z value of the vector */
  71047. z: number,
  71048. /** w value of the vector */
  71049. w: number);
  71050. /**
  71051. * Returns the string with the Vector4 coordinates.
  71052. * @returns a string containing all the vector values
  71053. */
  71054. toString(): string;
  71055. /**
  71056. * Returns the string "Vector4".
  71057. * @returns "Vector4"
  71058. */
  71059. getClassName(): string;
  71060. /**
  71061. * Returns the Vector4 hash code.
  71062. * @returns a unique hash code
  71063. */
  71064. getHashCode(): number;
  71065. /**
  71066. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71067. * @returns the resulting array
  71068. */
  71069. asArray(): number[];
  71070. /**
  71071. * Populates the given array from the given index with the Vector4 coordinates.
  71072. * @param array array to populate
  71073. * @param index index of the array to start at (default: 0)
  71074. * @returns the Vector4.
  71075. */
  71076. toArray(array: FloatArray, index?: number): Vector4;
  71077. /**
  71078. * Adds the given vector to the current Vector4.
  71079. * @param otherVector the vector to add
  71080. * @returns the updated Vector4.
  71081. */
  71082. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71083. /**
  71084. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71085. * @param otherVector the vector to add
  71086. * @returns the resulting vector
  71087. */
  71088. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71089. /**
  71090. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71091. * @param otherVector the vector to add
  71092. * @param result the vector to store the result
  71093. * @returns the current Vector4.
  71094. */
  71095. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71096. /**
  71097. * Subtract in place the given vector from the current Vector4.
  71098. * @param otherVector the vector to subtract
  71099. * @returns the updated Vector4.
  71100. */
  71101. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71102. /**
  71103. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71104. * @param otherVector the vector to add
  71105. * @returns the new vector with the result
  71106. */
  71107. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71108. /**
  71109. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71110. * @param otherVector the vector to subtract
  71111. * @param result the vector to store the result
  71112. * @returns the current Vector4.
  71113. */
  71114. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71115. /**
  71116. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71117. */
  71118. /**
  71119. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71120. * @param x value to subtract
  71121. * @param y value to subtract
  71122. * @param z value to subtract
  71123. * @param w value to subtract
  71124. * @returns new vector containing the result
  71125. */
  71126. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71127. /**
  71128. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71129. * @param x value to subtract
  71130. * @param y value to subtract
  71131. * @param z value to subtract
  71132. * @param w value to subtract
  71133. * @param result the vector to store the result in
  71134. * @returns the current Vector4.
  71135. */
  71136. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71137. /**
  71138. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71139. * @returns a new vector with the negated values
  71140. */
  71141. negate(): Vector4;
  71142. /**
  71143. * Multiplies the current Vector4 coordinates by scale (float).
  71144. * @param scale the number to scale with
  71145. * @returns the updated Vector4.
  71146. */
  71147. scaleInPlace(scale: number): Vector4;
  71148. /**
  71149. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71150. * @param scale the number to scale with
  71151. * @returns a new vector with the result
  71152. */
  71153. scale(scale: number): Vector4;
  71154. /**
  71155. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71156. * @param scale the number to scale with
  71157. * @param result a vector to store the result in
  71158. * @returns the current Vector4.
  71159. */
  71160. scaleToRef(scale: number, result: Vector4): Vector4;
  71161. /**
  71162. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71163. * @param scale defines the scale factor
  71164. * @param result defines the Vector4 object where to store the result
  71165. * @returns the unmodified current Vector4
  71166. */
  71167. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71168. /**
  71169. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71170. * @param otherVector the vector to compare against
  71171. * @returns true if they are equal
  71172. */
  71173. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71174. /**
  71175. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71176. * @param otherVector vector to compare against
  71177. * @param epsilon (Default: very small number)
  71178. * @returns true if they are equal
  71179. */
  71180. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71181. /**
  71182. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71183. * @param x x value to compare against
  71184. * @param y y value to compare against
  71185. * @param z z value to compare against
  71186. * @param w w value to compare against
  71187. * @returns true if equal
  71188. */
  71189. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71190. /**
  71191. * Multiplies in place the current Vector4 by the given one.
  71192. * @param otherVector vector to multiple with
  71193. * @returns the updated Vector4.
  71194. */
  71195. multiplyInPlace(otherVector: Vector4): Vector4;
  71196. /**
  71197. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71198. * @param otherVector vector to multiple with
  71199. * @returns resulting new vector
  71200. */
  71201. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71202. /**
  71203. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71204. * @param otherVector vector to multiple with
  71205. * @param result vector to store the result
  71206. * @returns the current Vector4.
  71207. */
  71208. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71209. /**
  71210. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71211. * @param x x value multiply with
  71212. * @param y y value multiply with
  71213. * @param z z value multiply with
  71214. * @param w w value multiply with
  71215. * @returns resulting new vector
  71216. */
  71217. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71218. /**
  71219. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71220. * @param otherVector vector to devide with
  71221. * @returns resulting new vector
  71222. */
  71223. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71224. /**
  71225. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71226. * @param otherVector vector to devide with
  71227. * @param result vector to store the result
  71228. * @returns the current Vector4.
  71229. */
  71230. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71231. /**
  71232. * Divides the current Vector3 coordinates by the given ones.
  71233. * @param otherVector vector to devide with
  71234. * @returns the updated Vector3.
  71235. */
  71236. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71237. /**
  71238. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71239. * @param other defines the second operand
  71240. * @returns the current updated Vector4
  71241. */
  71242. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71243. /**
  71244. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71245. * @param other defines the second operand
  71246. * @returns the current updated Vector4
  71247. */
  71248. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71249. /**
  71250. * Gets a new Vector4 from current Vector4 floored values
  71251. * @returns a new Vector4
  71252. */
  71253. floor(): Vector4;
  71254. /**
  71255. * Gets a new Vector4 from current Vector3 floored values
  71256. * @returns a new Vector4
  71257. */
  71258. fract(): Vector4;
  71259. /**
  71260. * Returns the Vector4 length (float).
  71261. * @returns the length
  71262. */
  71263. length(): number;
  71264. /**
  71265. * Returns the Vector4 squared length (float).
  71266. * @returns the length squared
  71267. */
  71268. lengthSquared(): number;
  71269. /**
  71270. * Normalizes in place the Vector4.
  71271. * @returns the updated Vector4.
  71272. */
  71273. normalize(): Vector4;
  71274. /**
  71275. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71276. * @returns this converted to a new vector3
  71277. */
  71278. toVector3(): Vector3;
  71279. /**
  71280. * Returns a new Vector4 copied from the current one.
  71281. * @returns the new cloned vector
  71282. */
  71283. clone(): Vector4;
  71284. /**
  71285. * Updates the current Vector4 with the given one coordinates.
  71286. * @param source the source vector to copy from
  71287. * @returns the updated Vector4.
  71288. */
  71289. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71290. /**
  71291. * Updates the current Vector4 coordinates with the given floats.
  71292. * @param x float to copy from
  71293. * @param y float to copy from
  71294. * @param z float to copy from
  71295. * @param w float to copy from
  71296. * @returns the updated Vector4.
  71297. */
  71298. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71299. /**
  71300. * Updates the current Vector4 coordinates with the given floats.
  71301. * @param x float to set from
  71302. * @param y float to set from
  71303. * @param z float to set from
  71304. * @param w float to set from
  71305. * @returns the updated Vector4.
  71306. */
  71307. set(x: number, y: number, z: number, w: number): Vector4;
  71308. /**
  71309. * Copies the given float to the current Vector3 coordinates
  71310. * @param v defines the x, y, z and w coordinates of the operand
  71311. * @returns the current updated Vector3
  71312. */
  71313. setAll(v: number): Vector4;
  71314. /**
  71315. * Returns a new Vector4 set from the starting index of the given array.
  71316. * @param array the array to pull values from
  71317. * @param offset the offset into the array to start at
  71318. * @returns the new vector
  71319. */
  71320. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71321. /**
  71322. * Updates the given vector "result" from the starting index of the given array.
  71323. * @param array the array to pull values from
  71324. * @param offset the offset into the array to start at
  71325. * @param result the vector to store the result in
  71326. */
  71327. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71328. /**
  71329. * Updates the given vector "result" from the starting index of the given Float32Array.
  71330. * @param array the array to pull values from
  71331. * @param offset the offset into the array to start at
  71332. * @param result the vector to store the result in
  71333. */
  71334. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71335. /**
  71336. * Updates the given vector "result" coordinates from the given floats.
  71337. * @param x float to set from
  71338. * @param y float to set from
  71339. * @param z float to set from
  71340. * @param w float to set from
  71341. * @param result the vector to the floats in
  71342. */
  71343. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71344. /**
  71345. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71346. * @returns the new vector
  71347. */
  71348. static Zero(): Vector4;
  71349. /**
  71350. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71351. * @returns the new vector
  71352. */
  71353. static One(): Vector4;
  71354. /**
  71355. * Returns a new normalized Vector4 from the given one.
  71356. * @param vector the vector to normalize
  71357. * @returns the vector
  71358. */
  71359. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71360. /**
  71361. * Updates the given vector "result" from the normalization of the given one.
  71362. * @param vector the vector to normalize
  71363. * @param result the vector to store the result in
  71364. */
  71365. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71366. /**
  71367. * Returns a vector with the minimum values from the left and right vectors
  71368. * @param left left vector to minimize
  71369. * @param right right vector to minimize
  71370. * @returns a new vector with the minimum of the left and right vector values
  71371. */
  71372. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71373. /**
  71374. * Returns a vector with the maximum values from the left and right vectors
  71375. * @param left left vector to maximize
  71376. * @param right right vector to maximize
  71377. * @returns a new vector with the maximum of the left and right vector values
  71378. */
  71379. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71380. /**
  71381. * Returns the distance (float) between the vectors "value1" and "value2".
  71382. * @param value1 value to calulate the distance between
  71383. * @param value2 value to calulate the distance between
  71384. * @return the distance between the two vectors
  71385. */
  71386. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71387. /**
  71388. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71389. * @param value1 value to calulate the distance between
  71390. * @param value2 value to calulate the distance between
  71391. * @return the distance between the two vectors squared
  71392. */
  71393. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71394. /**
  71395. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71396. * @param value1 value to calulate the center between
  71397. * @param value2 value to calulate the center between
  71398. * @return the center between the two vectors
  71399. */
  71400. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71401. /**
  71402. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71403. * This methods computes transformed normalized direction vectors only.
  71404. * @param vector the vector to transform
  71405. * @param transformation the transformation matrix to apply
  71406. * @returns the new vector
  71407. */
  71408. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71409. /**
  71410. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71411. * This methods computes transformed normalized direction vectors only.
  71412. * @param vector the vector to transform
  71413. * @param transformation the transformation matrix to apply
  71414. * @param result the vector to store the result in
  71415. */
  71416. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71417. /**
  71418. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71419. * This methods computes transformed normalized direction vectors only.
  71420. * @param x value to transform
  71421. * @param y value to transform
  71422. * @param z value to transform
  71423. * @param w value to transform
  71424. * @param transformation the transformation matrix to apply
  71425. * @param result the vector to store the results in
  71426. */
  71427. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71428. /**
  71429. * Creates a new Vector4 from a Vector3
  71430. * @param source defines the source data
  71431. * @param w defines the 4th component (default is 0)
  71432. * @returns a new Vector4
  71433. */
  71434. static FromVector3(source: Vector3, w?: number): Vector4;
  71435. }
  71436. /**
  71437. * Class used to store quaternion data
  71438. * @see https://en.wikipedia.org/wiki/Quaternion
  71439. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71440. */
  71441. export class Quaternion {
  71442. /** defines the first component (0 by default) */
  71443. x: number;
  71444. /** defines the second component (0 by default) */
  71445. y: number;
  71446. /** defines the third component (0 by default) */
  71447. z: number;
  71448. /** defines the fourth component (1.0 by default) */
  71449. w: number;
  71450. /**
  71451. * Creates a new Quaternion from the given floats
  71452. * @param x defines the first component (0 by default)
  71453. * @param y defines the second component (0 by default)
  71454. * @param z defines the third component (0 by default)
  71455. * @param w defines the fourth component (1.0 by default)
  71456. */
  71457. constructor(
  71458. /** defines the first component (0 by default) */
  71459. x?: number,
  71460. /** defines the second component (0 by default) */
  71461. y?: number,
  71462. /** defines the third component (0 by default) */
  71463. z?: number,
  71464. /** defines the fourth component (1.0 by default) */
  71465. w?: number);
  71466. /**
  71467. * Gets a string representation for the current quaternion
  71468. * @returns a string with the Quaternion coordinates
  71469. */
  71470. toString(): string;
  71471. /**
  71472. * Gets the class name of the quaternion
  71473. * @returns the string "Quaternion"
  71474. */
  71475. getClassName(): string;
  71476. /**
  71477. * Gets a hash code for this quaternion
  71478. * @returns the quaternion hash code
  71479. */
  71480. getHashCode(): number;
  71481. /**
  71482. * Copy the quaternion to an array
  71483. * @returns a new array populated with 4 elements from the quaternion coordinates
  71484. */
  71485. asArray(): number[];
  71486. /**
  71487. * Check if two quaternions are equals
  71488. * @param otherQuaternion defines the second operand
  71489. * @return true if the current quaternion and the given one coordinates are strictly equals
  71490. */
  71491. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71492. /**
  71493. * Clone the current quaternion
  71494. * @returns a new quaternion copied from the current one
  71495. */
  71496. clone(): Quaternion;
  71497. /**
  71498. * Copy a quaternion to the current one
  71499. * @param other defines the other quaternion
  71500. * @returns the updated current quaternion
  71501. */
  71502. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71503. /**
  71504. * Updates the current quaternion with the given float coordinates
  71505. * @param x defines the x coordinate
  71506. * @param y defines the y coordinate
  71507. * @param z defines the z coordinate
  71508. * @param w defines the w coordinate
  71509. * @returns the updated current quaternion
  71510. */
  71511. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71512. /**
  71513. * Updates the current quaternion from the given float coordinates
  71514. * @param x defines the x coordinate
  71515. * @param y defines the y coordinate
  71516. * @param z defines the z coordinate
  71517. * @param w defines the w coordinate
  71518. * @returns the updated current quaternion
  71519. */
  71520. set(x: number, y: number, z: number, w: number): Quaternion;
  71521. /**
  71522. * Adds two quaternions
  71523. * @param other defines the second operand
  71524. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71525. */
  71526. add(other: DeepImmutable<Quaternion>): Quaternion;
  71527. /**
  71528. * Add a quaternion to the current one
  71529. * @param other defines the quaternion to add
  71530. * @returns the current quaternion
  71531. */
  71532. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71533. /**
  71534. * Subtract two quaternions
  71535. * @param other defines the second operand
  71536. * @returns a new quaternion as the subtraction result of the given one from the current one
  71537. */
  71538. subtract(other: Quaternion): Quaternion;
  71539. /**
  71540. * Multiplies the current quaternion by a scale factor
  71541. * @param value defines the scale factor
  71542. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71543. */
  71544. scale(value: number): Quaternion;
  71545. /**
  71546. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71547. * @param scale defines the scale factor
  71548. * @param result defines the Quaternion object where to store the result
  71549. * @returns the unmodified current quaternion
  71550. */
  71551. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71552. /**
  71553. * Multiplies in place the current quaternion by a scale factor
  71554. * @param value defines the scale factor
  71555. * @returns the current modified quaternion
  71556. */
  71557. scaleInPlace(value: number): Quaternion;
  71558. /**
  71559. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71560. * @param scale defines the scale factor
  71561. * @param result defines the Quaternion object where to store the result
  71562. * @returns the unmodified current quaternion
  71563. */
  71564. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71565. /**
  71566. * Multiplies two quaternions
  71567. * @param q1 defines the second operand
  71568. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71569. */
  71570. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71571. /**
  71572. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71573. * @param q1 defines the second operand
  71574. * @param result defines the target quaternion
  71575. * @returns the current quaternion
  71576. */
  71577. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71578. /**
  71579. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71580. * @param q1 defines the second operand
  71581. * @returns the currentupdated quaternion
  71582. */
  71583. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71584. /**
  71585. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71586. * @param ref defines the target quaternion
  71587. * @returns the current quaternion
  71588. */
  71589. conjugateToRef(ref: Quaternion): Quaternion;
  71590. /**
  71591. * Conjugates in place (1-q) the current quaternion
  71592. * @returns the current updated quaternion
  71593. */
  71594. conjugateInPlace(): Quaternion;
  71595. /**
  71596. * Conjugates in place (1-q) the current quaternion
  71597. * @returns a new quaternion
  71598. */
  71599. conjugate(): Quaternion;
  71600. /**
  71601. * Gets length of current quaternion
  71602. * @returns the quaternion length (float)
  71603. */
  71604. length(): number;
  71605. /**
  71606. * Normalize in place the current quaternion
  71607. * @returns the current updated quaternion
  71608. */
  71609. normalize(): Quaternion;
  71610. /**
  71611. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71612. * @param order is a reserved parameter and is ignore for now
  71613. * @returns a new Vector3 containing the Euler angles
  71614. */
  71615. toEulerAngles(order?: string): Vector3;
  71616. /**
  71617. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71618. * @param result defines the vector which will be filled with the Euler angles
  71619. * @param order is a reserved parameter and is ignore for now
  71620. * @returns the current unchanged quaternion
  71621. */
  71622. toEulerAnglesToRef(result: Vector3): Quaternion;
  71623. /**
  71624. * Updates the given rotation matrix with the current quaternion values
  71625. * @param result defines the target matrix
  71626. * @returns the current unchanged quaternion
  71627. */
  71628. toRotationMatrix(result: Matrix): Quaternion;
  71629. /**
  71630. * Updates the current quaternion from the given rotation matrix values
  71631. * @param matrix defines the source matrix
  71632. * @returns the current updated quaternion
  71633. */
  71634. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71635. /**
  71636. * Creates a new quaternion from a rotation matrix
  71637. * @param matrix defines the source matrix
  71638. * @returns a new quaternion created from the given rotation matrix values
  71639. */
  71640. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71641. /**
  71642. * Updates the given quaternion with the given rotation matrix values
  71643. * @param matrix defines the source matrix
  71644. * @param result defines the target quaternion
  71645. */
  71646. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71647. /**
  71648. * Returns the dot product (float) between the quaternions "left" and "right"
  71649. * @param left defines the left operand
  71650. * @param right defines the right operand
  71651. * @returns the dot product
  71652. */
  71653. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71654. /**
  71655. * Checks if the two quaternions are close to each other
  71656. * @param quat0 defines the first quaternion to check
  71657. * @param quat1 defines the second quaternion to check
  71658. * @returns true if the two quaternions are close to each other
  71659. */
  71660. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71661. /**
  71662. * Creates an empty quaternion
  71663. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71664. */
  71665. static Zero(): Quaternion;
  71666. /**
  71667. * Inverse a given quaternion
  71668. * @param q defines the source quaternion
  71669. * @returns a new quaternion as the inverted current quaternion
  71670. */
  71671. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71672. /**
  71673. * Inverse a given quaternion
  71674. * @param q defines the source quaternion
  71675. * @param result the quaternion the result will be stored in
  71676. * @returns the result quaternion
  71677. */
  71678. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71679. /**
  71680. * Creates an identity quaternion
  71681. * @returns the identity quaternion
  71682. */
  71683. static Identity(): Quaternion;
  71684. /**
  71685. * Gets a boolean indicating if the given quaternion is identity
  71686. * @param quaternion defines the quaternion to check
  71687. * @returns true if the quaternion is identity
  71688. */
  71689. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71690. /**
  71691. * Creates a quaternion from a rotation around an axis
  71692. * @param axis defines the axis to use
  71693. * @param angle defines the angle to use
  71694. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71695. */
  71696. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71697. /**
  71698. * Creates a rotation around an axis and stores it into the given quaternion
  71699. * @param axis defines the axis to use
  71700. * @param angle defines the angle to use
  71701. * @param result defines the target quaternion
  71702. * @returns the target quaternion
  71703. */
  71704. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71705. /**
  71706. * Creates a new quaternion from data stored into an array
  71707. * @param array defines the data source
  71708. * @param offset defines the offset in the source array where the data starts
  71709. * @returns a new quaternion
  71710. */
  71711. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71712. /**
  71713. * Create a quaternion from Euler rotation angles
  71714. * @param x Pitch
  71715. * @param y Yaw
  71716. * @param z Roll
  71717. * @returns the new Quaternion
  71718. */
  71719. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71720. /**
  71721. * Updates a quaternion from Euler rotation angles
  71722. * @param x Pitch
  71723. * @param y Yaw
  71724. * @param z Roll
  71725. * @param result the quaternion to store the result
  71726. * @returns the updated quaternion
  71727. */
  71728. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71729. /**
  71730. * Create a quaternion from Euler rotation vector
  71731. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71732. * @returns the new Quaternion
  71733. */
  71734. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71735. /**
  71736. * Updates a quaternion from Euler rotation vector
  71737. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71738. * @param result the quaternion to store the result
  71739. * @returns the updated quaternion
  71740. */
  71741. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71742. /**
  71743. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71744. * @param yaw defines the rotation around Y axis
  71745. * @param pitch defines the rotation around X axis
  71746. * @param roll defines the rotation around Z axis
  71747. * @returns the new quaternion
  71748. */
  71749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71750. /**
  71751. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71752. * @param yaw defines the rotation around Y axis
  71753. * @param pitch defines the rotation around X axis
  71754. * @param roll defines the rotation around Z axis
  71755. * @param result defines the target quaternion
  71756. */
  71757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71758. /**
  71759. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71760. * @param alpha defines the rotation around first axis
  71761. * @param beta defines the rotation around second axis
  71762. * @param gamma defines the rotation around third axis
  71763. * @returns the new quaternion
  71764. */
  71765. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71766. /**
  71767. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71768. * @param alpha defines the rotation around first axis
  71769. * @param beta defines the rotation around second axis
  71770. * @param gamma defines the rotation around third axis
  71771. * @param result defines the target quaternion
  71772. */
  71773. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71774. /**
  71775. * 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)
  71776. * @param axis1 defines the first axis
  71777. * @param axis2 defines the second axis
  71778. * @param axis3 defines the third axis
  71779. * @returns the new quaternion
  71780. */
  71781. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71782. /**
  71783. * 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
  71784. * @param axis1 defines the first axis
  71785. * @param axis2 defines the second axis
  71786. * @param axis3 defines the third axis
  71787. * @param ref defines the target quaternion
  71788. */
  71789. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71790. /**
  71791. * Interpolates between two quaternions
  71792. * @param left defines first quaternion
  71793. * @param right defines second quaternion
  71794. * @param amount defines the gradient to use
  71795. * @returns the new interpolated quaternion
  71796. */
  71797. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71798. /**
  71799. * Interpolates between two quaternions and stores it into a target quaternion
  71800. * @param left defines first quaternion
  71801. * @param right defines second quaternion
  71802. * @param amount defines the gradient to use
  71803. * @param result defines the target quaternion
  71804. */
  71805. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71806. /**
  71807. * Interpolate between two quaternions using Hermite interpolation
  71808. * @param value1 defines first quaternion
  71809. * @param tangent1 defines the incoming tangent
  71810. * @param value2 defines second quaternion
  71811. * @param tangent2 defines the outgoing tangent
  71812. * @param amount defines the target quaternion
  71813. * @returns the new interpolated quaternion
  71814. */
  71815. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71816. }
  71817. /**
  71818. * Class used to store matrix data (4x4)
  71819. */
  71820. export class Matrix {
  71821. private static _updateFlagSeed;
  71822. private static _identityReadOnly;
  71823. private _isIdentity;
  71824. private _isIdentityDirty;
  71825. private _isIdentity3x2;
  71826. private _isIdentity3x2Dirty;
  71827. /**
  71828. * Gets the update flag of the matrix which is an unique number for the matrix.
  71829. * It will be incremented every time the matrix data change.
  71830. * You can use it to speed the comparison between two versions of the same matrix.
  71831. */
  71832. updateFlag: number;
  71833. private readonly _m;
  71834. /**
  71835. * Gets the internal data of the matrix
  71836. */
  71837. readonly m: DeepImmutable<Float32Array>;
  71838. /** @hidden */
  71839. _markAsUpdated(): void;
  71840. /** @hidden */
  71841. private _updateIdentityStatus;
  71842. /**
  71843. * Creates an empty matrix (filled with zeros)
  71844. */
  71845. constructor();
  71846. /**
  71847. * Check if the current matrix is identity
  71848. * @returns true is the matrix is the identity matrix
  71849. */
  71850. isIdentity(): boolean;
  71851. /**
  71852. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71853. * @returns true is the matrix is the identity matrix
  71854. */
  71855. isIdentityAs3x2(): boolean;
  71856. /**
  71857. * Gets the determinant of the matrix
  71858. * @returns the matrix determinant
  71859. */
  71860. determinant(): number;
  71861. /**
  71862. * Returns the matrix as a Float32Array
  71863. * @returns the matrix underlying array
  71864. */
  71865. toArray(): DeepImmutable<Float32Array>;
  71866. /**
  71867. * Returns the matrix as a Float32Array
  71868. * @returns the matrix underlying array.
  71869. */
  71870. asArray(): DeepImmutable<Float32Array>;
  71871. /**
  71872. * Inverts the current matrix in place
  71873. * @returns the current inverted matrix
  71874. */
  71875. invert(): Matrix;
  71876. /**
  71877. * Sets all the matrix elements to zero
  71878. * @returns the current matrix
  71879. */
  71880. reset(): Matrix;
  71881. /**
  71882. * Adds the current matrix with a second one
  71883. * @param other defines the matrix to add
  71884. * @returns a new matrix as the addition of the current matrix and the given one
  71885. */
  71886. add(other: DeepImmutable<Matrix>): Matrix;
  71887. /**
  71888. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71889. * @param other defines the matrix to add
  71890. * @param result defines the target matrix
  71891. * @returns the current matrix
  71892. */
  71893. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71894. /**
  71895. * Adds in place the given matrix to the current matrix
  71896. * @param other defines the second operand
  71897. * @returns the current updated matrix
  71898. */
  71899. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71900. /**
  71901. * Sets the given matrix to the current inverted Matrix
  71902. * @param other defines the target matrix
  71903. * @returns the unmodified current matrix
  71904. */
  71905. invertToRef(other: Matrix): Matrix;
  71906. /**
  71907. * add a value at the specified position in the current Matrix
  71908. * @param index the index of the value within the matrix. between 0 and 15.
  71909. * @param value the value to be added
  71910. * @returns the current updated matrix
  71911. */
  71912. addAtIndex(index: number, value: number): Matrix;
  71913. /**
  71914. * mutiply the specified position in the current Matrix by a value
  71915. * @param index the index of the value within the matrix. between 0 and 15.
  71916. * @param value the value to be added
  71917. * @returns the current updated matrix
  71918. */
  71919. multiplyAtIndex(index: number, value: number): Matrix;
  71920. /**
  71921. * Inserts the translation vector (using 3 floats) in the current matrix
  71922. * @param x defines the 1st component of the translation
  71923. * @param y defines the 2nd component of the translation
  71924. * @param z defines the 3rd component of the translation
  71925. * @returns the current updated matrix
  71926. */
  71927. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71928. /**
  71929. * Adds the translation vector (using 3 floats) in the current matrix
  71930. * @param x defines the 1st component of the translation
  71931. * @param y defines the 2nd component of the translation
  71932. * @param z defines the 3rd component of the translation
  71933. * @returns the current updated matrix
  71934. */
  71935. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71936. /**
  71937. * Inserts the translation vector in the current matrix
  71938. * @param vector3 defines the translation to insert
  71939. * @returns the current updated matrix
  71940. */
  71941. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71942. /**
  71943. * Gets the translation value of the current matrix
  71944. * @returns a new Vector3 as the extracted translation from the matrix
  71945. */
  71946. getTranslation(): Vector3;
  71947. /**
  71948. * Fill a Vector3 with the extracted translation from the matrix
  71949. * @param result defines the Vector3 where to store the translation
  71950. * @returns the current matrix
  71951. */
  71952. getTranslationToRef(result: Vector3): Matrix;
  71953. /**
  71954. * Remove rotation and scaling part from the matrix
  71955. * @returns the updated matrix
  71956. */
  71957. removeRotationAndScaling(): Matrix;
  71958. /**
  71959. * Multiply two matrices
  71960. * @param other defines the second operand
  71961. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71962. */
  71963. multiply(other: DeepImmutable<Matrix>): Matrix;
  71964. /**
  71965. * Copy the current matrix from the given one
  71966. * @param other defines the source matrix
  71967. * @returns the current updated matrix
  71968. */
  71969. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71970. /**
  71971. * Populates the given array from the starting index with the current matrix values
  71972. * @param array defines the target array
  71973. * @param offset defines the offset in the target array where to start storing values
  71974. * @returns the current matrix
  71975. */
  71976. copyToArray(array: Float32Array, offset?: number): Matrix;
  71977. /**
  71978. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71979. * @param other defines the second operand
  71980. * @param result defines the matrix where to store the multiplication
  71981. * @returns the current matrix
  71982. */
  71983. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71984. /**
  71985. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71986. * @param other defines the second operand
  71987. * @param result defines the array where to store the multiplication
  71988. * @param offset defines the offset in the target array where to start storing values
  71989. * @returns the current matrix
  71990. */
  71991. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71992. /**
  71993. * Check equality between this matrix and a second one
  71994. * @param value defines the second matrix to compare
  71995. * @returns true is the current matrix and the given one values are strictly equal
  71996. */
  71997. equals(value: DeepImmutable<Matrix>): boolean;
  71998. /**
  71999. * Clone the current matrix
  72000. * @returns a new matrix from the current matrix
  72001. */
  72002. clone(): Matrix;
  72003. /**
  72004. * Returns the name of the current matrix class
  72005. * @returns the string "Matrix"
  72006. */
  72007. getClassName(): string;
  72008. /**
  72009. * Gets the hash code of the current matrix
  72010. * @returns the hash code
  72011. */
  72012. getHashCode(): number;
  72013. /**
  72014. * Decomposes the current Matrix into a translation, rotation and scaling components
  72015. * @param scale defines the scale vector3 given as a reference to update
  72016. * @param rotation defines the rotation quaternion given as a reference to update
  72017. * @param translation defines the translation vector3 given as a reference to update
  72018. * @returns true if operation was successful
  72019. */
  72020. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72021. /**
  72022. * Gets specific row of the matrix
  72023. * @param index defines the number of the row to get
  72024. * @returns the index-th row of the current matrix as a new Vector4
  72025. */
  72026. getRow(index: number): Nullable<Vector4>;
  72027. /**
  72028. * Sets the index-th row of the current matrix to the vector4 values
  72029. * @param index defines the number of the row to set
  72030. * @param row defines the target vector4
  72031. * @returns the updated current matrix
  72032. */
  72033. setRow(index: number, row: Vector4): Matrix;
  72034. /**
  72035. * Compute the transpose of the matrix
  72036. * @returns the new transposed matrix
  72037. */
  72038. transpose(): Matrix;
  72039. /**
  72040. * Compute the transpose of the matrix and store it in a given matrix
  72041. * @param result defines the target matrix
  72042. * @returns the current matrix
  72043. */
  72044. transposeToRef(result: Matrix): Matrix;
  72045. /**
  72046. * Sets the index-th row of the current matrix with the given 4 x float values
  72047. * @param index defines the row index
  72048. * @param x defines the x component to set
  72049. * @param y defines the y component to set
  72050. * @param z defines the z component to set
  72051. * @param w defines the w component to set
  72052. * @returns the updated current matrix
  72053. */
  72054. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72055. /**
  72056. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72057. * @param scale defines the scale factor
  72058. * @returns a new matrix
  72059. */
  72060. scale(scale: number): Matrix;
  72061. /**
  72062. * Scale the current matrix values by a factor to a given result matrix
  72063. * @param scale defines the scale factor
  72064. * @param result defines the matrix to store the result
  72065. * @returns the current matrix
  72066. */
  72067. scaleToRef(scale: number, result: Matrix): Matrix;
  72068. /**
  72069. * Scale the current matrix values by a factor and add the result to a given matrix
  72070. * @param scale defines the scale factor
  72071. * @param result defines the Matrix to store the result
  72072. * @returns the current matrix
  72073. */
  72074. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72075. /**
  72076. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72077. * @param ref matrix to store the result
  72078. */
  72079. toNormalMatrix(ref: Matrix): void;
  72080. /**
  72081. * Gets only rotation part of the current matrix
  72082. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72083. */
  72084. getRotationMatrix(): Matrix;
  72085. /**
  72086. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72087. * @param result defines the target matrix to store data to
  72088. * @returns the current matrix
  72089. */
  72090. getRotationMatrixToRef(result: Matrix): Matrix;
  72091. /**
  72092. * Toggles model matrix from being right handed to left handed in place and vice versa
  72093. */
  72094. toggleModelMatrixHandInPlace(): void;
  72095. /**
  72096. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72097. */
  72098. toggleProjectionMatrixHandInPlace(): void;
  72099. /**
  72100. * Creates a matrix from an array
  72101. * @param array defines the source array
  72102. * @param offset defines an offset in the source array
  72103. * @returns a new Matrix set from the starting index of the given array
  72104. */
  72105. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72106. /**
  72107. * Copy the content of an array into a given matrix
  72108. * @param array defines the source array
  72109. * @param offset defines an offset in the source array
  72110. * @param result defines the target matrix
  72111. */
  72112. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72113. /**
  72114. * Stores an array into a matrix after having multiplied each component by a given factor
  72115. * @param array defines the source array
  72116. * @param offset defines the offset in the source array
  72117. * @param scale defines the scaling factor
  72118. * @param result defines the target matrix
  72119. */
  72120. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72121. /**
  72122. * Gets an identity matrix that must not be updated
  72123. */
  72124. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72125. /**
  72126. * Stores a list of values (16) inside a given matrix
  72127. * @param initialM11 defines 1st value of 1st row
  72128. * @param initialM12 defines 2nd value of 1st row
  72129. * @param initialM13 defines 3rd value of 1st row
  72130. * @param initialM14 defines 4th value of 1st row
  72131. * @param initialM21 defines 1st value of 2nd row
  72132. * @param initialM22 defines 2nd value of 2nd row
  72133. * @param initialM23 defines 3rd value of 2nd row
  72134. * @param initialM24 defines 4th value of 2nd row
  72135. * @param initialM31 defines 1st value of 3rd row
  72136. * @param initialM32 defines 2nd value of 3rd row
  72137. * @param initialM33 defines 3rd value of 3rd row
  72138. * @param initialM34 defines 4th value of 3rd row
  72139. * @param initialM41 defines 1st value of 4th row
  72140. * @param initialM42 defines 2nd value of 4th row
  72141. * @param initialM43 defines 3rd value of 4th row
  72142. * @param initialM44 defines 4th value of 4th row
  72143. * @param result defines the target matrix
  72144. */
  72145. 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;
  72146. /**
  72147. * Creates new matrix from a list of values (16)
  72148. * @param initialM11 defines 1st value of 1st row
  72149. * @param initialM12 defines 2nd value of 1st row
  72150. * @param initialM13 defines 3rd value of 1st row
  72151. * @param initialM14 defines 4th value of 1st row
  72152. * @param initialM21 defines 1st value of 2nd row
  72153. * @param initialM22 defines 2nd value of 2nd row
  72154. * @param initialM23 defines 3rd value of 2nd row
  72155. * @param initialM24 defines 4th value of 2nd row
  72156. * @param initialM31 defines 1st value of 3rd row
  72157. * @param initialM32 defines 2nd value of 3rd row
  72158. * @param initialM33 defines 3rd value of 3rd row
  72159. * @param initialM34 defines 4th value of 3rd row
  72160. * @param initialM41 defines 1st value of 4th row
  72161. * @param initialM42 defines 2nd value of 4th row
  72162. * @param initialM43 defines 3rd value of 4th row
  72163. * @param initialM44 defines 4th value of 4th row
  72164. * @returns the new matrix
  72165. */
  72166. 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;
  72167. /**
  72168. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72169. * @param scale defines the scale vector3
  72170. * @param rotation defines the rotation quaternion
  72171. * @param translation defines the translation vector3
  72172. * @returns a new matrix
  72173. */
  72174. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72175. /**
  72176. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72177. * @param scale defines the scale vector3
  72178. * @param rotation defines the rotation quaternion
  72179. * @param translation defines the translation vector3
  72180. * @param result defines the target matrix
  72181. */
  72182. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72183. /**
  72184. * Creates a new identity matrix
  72185. * @returns a new identity matrix
  72186. */
  72187. static Identity(): Matrix;
  72188. /**
  72189. * Creates a new identity matrix and stores the result in a given matrix
  72190. * @param result defines the target matrix
  72191. */
  72192. static IdentityToRef(result: Matrix): void;
  72193. /**
  72194. * Creates a new zero matrix
  72195. * @returns a new zero matrix
  72196. */
  72197. static Zero(): Matrix;
  72198. /**
  72199. * Creates a new rotation matrix for "angle" radians around the X axis
  72200. * @param angle defines the angle (in radians) to use
  72201. * @return the new matrix
  72202. */
  72203. static RotationX(angle: number): Matrix;
  72204. /**
  72205. * Creates a new matrix as the invert of a given matrix
  72206. * @param source defines the source matrix
  72207. * @returns the new matrix
  72208. */
  72209. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72210. /**
  72211. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72212. * @param angle defines the angle (in radians) to use
  72213. * @param result defines the target matrix
  72214. */
  72215. static RotationXToRef(angle: number, result: Matrix): void;
  72216. /**
  72217. * Creates a new rotation matrix for "angle" radians around the Y axis
  72218. * @param angle defines the angle (in radians) to use
  72219. * @return the new matrix
  72220. */
  72221. static RotationY(angle: number): Matrix;
  72222. /**
  72223. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72224. * @param angle defines the angle (in radians) to use
  72225. * @param result defines the target matrix
  72226. */
  72227. static RotationYToRef(angle: number, result: Matrix): void;
  72228. /**
  72229. * Creates a new rotation matrix for "angle" radians around the Z axis
  72230. * @param angle defines the angle (in radians) to use
  72231. * @return the new matrix
  72232. */
  72233. static RotationZ(angle: number): Matrix;
  72234. /**
  72235. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72236. * @param angle defines the angle (in radians) to use
  72237. * @param result defines the target matrix
  72238. */
  72239. static RotationZToRef(angle: number, result: Matrix): void;
  72240. /**
  72241. * Creates a new rotation matrix for "angle" radians around the given axis
  72242. * @param axis defines the axis to use
  72243. * @param angle defines the angle (in radians) to use
  72244. * @return the new matrix
  72245. */
  72246. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72247. /**
  72248. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72249. * @param axis defines the axis to use
  72250. * @param angle defines the angle (in radians) to use
  72251. * @param result defines the target matrix
  72252. */
  72253. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72254. /**
  72255. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72256. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72257. * @param from defines the vector to align
  72258. * @param to defines the vector to align to
  72259. * @param result defines the target matrix
  72260. */
  72261. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72262. /**
  72263. * Creates a rotation matrix
  72264. * @param yaw defines the yaw angle in radians (Y axis)
  72265. * @param pitch defines the pitch angle in radians (X axis)
  72266. * @param roll defines the roll angle in radians (X axis)
  72267. * @returns the new rotation matrix
  72268. */
  72269. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72270. /**
  72271. * Creates a rotation matrix and stores it in a given matrix
  72272. * @param yaw defines the yaw angle in radians (Y axis)
  72273. * @param pitch defines the pitch angle in radians (X axis)
  72274. * @param roll defines the roll angle in radians (X axis)
  72275. * @param result defines the target matrix
  72276. */
  72277. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72278. /**
  72279. * Creates a scaling matrix
  72280. * @param x defines the scale factor on X axis
  72281. * @param y defines the scale factor on Y axis
  72282. * @param z defines the scale factor on Z axis
  72283. * @returns the new matrix
  72284. */
  72285. static Scaling(x: number, y: number, z: number): Matrix;
  72286. /**
  72287. * Creates a scaling matrix and stores it in a given matrix
  72288. * @param x defines the scale factor on X axis
  72289. * @param y defines the scale factor on Y axis
  72290. * @param z defines the scale factor on Z axis
  72291. * @param result defines the target matrix
  72292. */
  72293. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72294. /**
  72295. * Creates a translation matrix
  72296. * @param x defines the translation on X axis
  72297. * @param y defines the translation on Y axis
  72298. * @param z defines the translationon Z axis
  72299. * @returns the new matrix
  72300. */
  72301. static Translation(x: number, y: number, z: number): Matrix;
  72302. /**
  72303. * Creates a translation matrix and stores it in a given matrix
  72304. * @param x defines the translation on X axis
  72305. * @param y defines the translation on Y axis
  72306. * @param z defines the translationon Z axis
  72307. * @param result defines the target matrix
  72308. */
  72309. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72310. /**
  72311. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72312. * @param startValue defines the start value
  72313. * @param endValue defines the end value
  72314. * @param gradient defines the gradient factor
  72315. * @returns the new matrix
  72316. */
  72317. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72318. /**
  72319. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72320. * @param startValue defines the start value
  72321. * @param endValue defines the end value
  72322. * @param gradient defines the gradient factor
  72323. * @param result defines the Matrix object where to store data
  72324. */
  72325. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72326. /**
  72327. * Builds a new matrix whose values are computed by:
  72328. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72329. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72330. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72331. * @param startValue defines the first matrix
  72332. * @param endValue defines the second matrix
  72333. * @param gradient defines the gradient between the two matrices
  72334. * @returns the new matrix
  72335. */
  72336. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72337. /**
  72338. * Update a matrix to values which are computed by:
  72339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72342. * @param startValue defines the first matrix
  72343. * @param endValue defines the second matrix
  72344. * @param gradient defines the gradient between the two matrices
  72345. * @param result defines the target matrix
  72346. */
  72347. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72348. /**
  72349. * 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"
  72350. * This function works in left handed mode
  72351. * @param eye defines the final position of the entity
  72352. * @param target defines where the entity should look at
  72353. * @param up defines the up vector for the entity
  72354. * @returns the new matrix
  72355. */
  72356. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72357. /**
  72358. * 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".
  72359. * This function works in left handed mode
  72360. * @param eye defines the final position of the entity
  72361. * @param target defines where the entity should look at
  72362. * @param up defines the up vector for the entity
  72363. * @param result defines the target matrix
  72364. */
  72365. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72366. /**
  72367. * 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"
  72368. * This function works in right handed mode
  72369. * @param eye defines the final position of the entity
  72370. * @param target defines where the entity should look at
  72371. * @param up defines the up vector for the entity
  72372. * @returns the new matrix
  72373. */
  72374. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72375. /**
  72376. * 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".
  72377. * This function works in right handed mode
  72378. * @param eye defines the final position of the entity
  72379. * @param target defines where the entity should look at
  72380. * @param up defines the up vector for the entity
  72381. * @param result defines the target matrix
  72382. */
  72383. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72384. /**
  72385. * Create a left-handed orthographic projection matrix
  72386. * @param width defines the viewport width
  72387. * @param height defines the viewport height
  72388. * @param znear defines the near clip plane
  72389. * @param zfar defines the far clip plane
  72390. * @returns a new matrix as a left-handed orthographic projection matrix
  72391. */
  72392. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72393. /**
  72394. * Store a left-handed orthographic projection to a given matrix
  72395. * @param width defines the viewport width
  72396. * @param height defines the viewport height
  72397. * @param znear defines the near clip plane
  72398. * @param zfar defines the far clip plane
  72399. * @param result defines the target matrix
  72400. */
  72401. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72402. /**
  72403. * Create a left-handed orthographic projection matrix
  72404. * @param left defines the viewport left coordinate
  72405. * @param right defines the viewport right coordinate
  72406. * @param bottom defines the viewport bottom coordinate
  72407. * @param top defines the viewport top coordinate
  72408. * @param znear defines the near clip plane
  72409. * @param zfar defines the far clip plane
  72410. * @returns a new matrix as a left-handed orthographic projection matrix
  72411. */
  72412. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72413. /**
  72414. * Stores a left-handed orthographic projection into a given matrix
  72415. * @param left defines the viewport left coordinate
  72416. * @param right defines the viewport right coordinate
  72417. * @param bottom defines the viewport bottom coordinate
  72418. * @param top defines the viewport top coordinate
  72419. * @param znear defines the near clip plane
  72420. * @param zfar defines the far clip plane
  72421. * @param result defines the target matrix
  72422. */
  72423. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72424. /**
  72425. * Creates a right-handed orthographic projection matrix
  72426. * @param left defines the viewport left coordinate
  72427. * @param right defines the viewport right coordinate
  72428. * @param bottom defines the viewport bottom coordinate
  72429. * @param top defines the viewport top coordinate
  72430. * @param znear defines the near clip plane
  72431. * @param zfar defines the far clip plane
  72432. * @returns a new matrix as a right-handed orthographic projection matrix
  72433. */
  72434. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72435. /**
  72436. * Stores a right-handed orthographic projection into a given matrix
  72437. * @param left defines the viewport left coordinate
  72438. * @param right defines the viewport right coordinate
  72439. * @param bottom defines the viewport bottom coordinate
  72440. * @param top defines the viewport top coordinate
  72441. * @param znear defines the near clip plane
  72442. * @param zfar defines the far clip plane
  72443. * @param result defines the target matrix
  72444. */
  72445. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72446. /**
  72447. * Creates a left-handed perspective projection matrix
  72448. * @param width defines the viewport width
  72449. * @param height defines the viewport height
  72450. * @param znear defines the near clip plane
  72451. * @param zfar defines the far clip plane
  72452. * @returns a new matrix as a left-handed perspective projection matrix
  72453. */
  72454. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72455. /**
  72456. * Creates a left-handed perspective projection matrix
  72457. * @param fov defines the horizontal field of view
  72458. * @param aspect defines the aspect ratio
  72459. * @param znear defines the near clip plane
  72460. * @param zfar defines the far clip plane
  72461. * @returns a new matrix as a left-handed perspective projection matrix
  72462. */
  72463. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72464. /**
  72465. * Stores a left-handed perspective projection into a given matrix
  72466. * @param fov defines the horizontal field of view
  72467. * @param aspect defines the aspect ratio
  72468. * @param znear defines the near clip plane
  72469. * @param zfar defines the far clip plane
  72470. * @param result defines the target matrix
  72471. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72472. */
  72473. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72474. /**
  72475. * Creates a right-handed perspective projection matrix
  72476. * @param fov defines the horizontal field of view
  72477. * @param aspect defines the aspect ratio
  72478. * @param znear defines the near clip plane
  72479. * @param zfar defines the far clip plane
  72480. * @returns a new matrix as a right-handed perspective projection matrix
  72481. */
  72482. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72483. /**
  72484. * Stores a right-handed perspective projection into a given matrix
  72485. * @param fov defines the horizontal field of view
  72486. * @param aspect defines the aspect ratio
  72487. * @param znear defines the near clip plane
  72488. * @param zfar defines the far clip plane
  72489. * @param result defines the target matrix
  72490. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72491. */
  72492. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72493. /**
  72494. * Stores a perspective projection for WebVR info a given matrix
  72495. * @param fov defines the field of view
  72496. * @param znear defines the near clip plane
  72497. * @param zfar defines the far clip plane
  72498. * @param result defines the target matrix
  72499. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72500. */
  72501. static PerspectiveFovWebVRToRef(fov: {
  72502. upDegrees: number;
  72503. downDegrees: number;
  72504. leftDegrees: number;
  72505. rightDegrees: number;
  72506. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72507. /**
  72508. * Computes a complete transformation matrix
  72509. * @param viewport defines the viewport to use
  72510. * @param world defines the world matrix
  72511. * @param view defines the view matrix
  72512. * @param projection defines the projection matrix
  72513. * @param zmin defines the near clip plane
  72514. * @param zmax defines the far clip plane
  72515. * @returns the transformation matrix
  72516. */
  72517. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72518. /**
  72519. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72520. * @param matrix defines the matrix to use
  72521. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72522. */
  72523. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72524. /**
  72525. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72526. * @param matrix defines the matrix to use
  72527. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72528. */
  72529. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72530. /**
  72531. * Compute the transpose of a given matrix
  72532. * @param matrix defines the matrix to transpose
  72533. * @returns the new matrix
  72534. */
  72535. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72536. /**
  72537. * Compute the transpose of a matrix and store it in a target matrix
  72538. * @param matrix defines the matrix to transpose
  72539. * @param result defines the target matrix
  72540. */
  72541. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72542. /**
  72543. * Computes a reflection matrix from a plane
  72544. * @param plane defines the reflection plane
  72545. * @returns a new matrix
  72546. */
  72547. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72548. /**
  72549. * Computes a reflection matrix from a plane
  72550. * @param plane defines the reflection plane
  72551. * @param result defines the target matrix
  72552. */
  72553. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72554. /**
  72555. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72556. * @param xaxis defines the value of the 1st axis
  72557. * @param yaxis defines the value of the 2nd axis
  72558. * @param zaxis defines the value of the 3rd axis
  72559. * @param result defines the target matrix
  72560. */
  72561. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72562. /**
  72563. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72564. * @param quat defines the quaternion to use
  72565. * @param result defines the target matrix
  72566. */
  72567. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72568. }
  72569. /**
  72570. * @hidden
  72571. */
  72572. export class TmpVectors {
  72573. static Vector2: Vector2[];
  72574. static Vector3: Vector3[];
  72575. static Vector4: Vector4[];
  72576. static Quaternion: Quaternion[];
  72577. static Matrix: Matrix[];
  72578. }
  72579. }
  72580. declare module BABYLON {
  72581. /**
  72582. * Defines potential orientation for back face culling
  72583. */
  72584. export enum Orientation {
  72585. /**
  72586. * Clockwise
  72587. */
  72588. CW = 0,
  72589. /** Counter clockwise */
  72590. CCW = 1
  72591. }
  72592. /** Class used to represent a Bezier curve */
  72593. export class BezierCurve {
  72594. /**
  72595. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72596. * @param t defines the time
  72597. * @param x1 defines the left coordinate on X axis
  72598. * @param y1 defines the left coordinate on Y axis
  72599. * @param x2 defines the right coordinate on X axis
  72600. * @param y2 defines the right coordinate on Y axis
  72601. * @returns the interpolated value
  72602. */
  72603. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72604. }
  72605. /**
  72606. * Defines angle representation
  72607. */
  72608. export class Angle {
  72609. private _radians;
  72610. /**
  72611. * Creates an Angle object of "radians" radians (float).
  72612. * @param radians the angle in radians
  72613. */
  72614. constructor(radians: number);
  72615. /**
  72616. * Get value in degrees
  72617. * @returns the Angle value in degrees (float)
  72618. */
  72619. degrees(): number;
  72620. /**
  72621. * Get value in radians
  72622. * @returns the Angle value in radians (float)
  72623. */
  72624. radians(): number;
  72625. /**
  72626. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72627. * @param a defines first vector
  72628. * @param b defines second vector
  72629. * @returns a new Angle
  72630. */
  72631. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72632. /**
  72633. * Gets a new Angle object from the given float in radians
  72634. * @param radians defines the angle value in radians
  72635. * @returns a new Angle
  72636. */
  72637. static FromRadians(radians: number): Angle;
  72638. /**
  72639. * Gets a new Angle object from the given float in degrees
  72640. * @param degrees defines the angle value in degrees
  72641. * @returns a new Angle
  72642. */
  72643. static FromDegrees(degrees: number): Angle;
  72644. }
  72645. /**
  72646. * This represents an arc in a 2d space.
  72647. */
  72648. export class Arc2 {
  72649. /** Defines the start point of the arc */
  72650. startPoint: Vector2;
  72651. /** Defines the mid point of the arc */
  72652. midPoint: Vector2;
  72653. /** Defines the end point of the arc */
  72654. endPoint: Vector2;
  72655. /**
  72656. * Defines the center point of the arc.
  72657. */
  72658. centerPoint: Vector2;
  72659. /**
  72660. * Defines the radius of the arc.
  72661. */
  72662. radius: number;
  72663. /**
  72664. * Defines the angle of the arc (from mid point to end point).
  72665. */
  72666. angle: Angle;
  72667. /**
  72668. * Defines the start angle of the arc (from start point to middle point).
  72669. */
  72670. startAngle: Angle;
  72671. /**
  72672. * Defines the orientation of the arc (clock wise/counter clock wise).
  72673. */
  72674. orientation: Orientation;
  72675. /**
  72676. * Creates an Arc object from the three given points : start, middle and end.
  72677. * @param startPoint Defines the start point of the arc
  72678. * @param midPoint Defines the midlle point of the arc
  72679. * @param endPoint Defines the end point of the arc
  72680. */
  72681. constructor(
  72682. /** Defines the start point of the arc */
  72683. startPoint: Vector2,
  72684. /** Defines the mid point of the arc */
  72685. midPoint: Vector2,
  72686. /** Defines the end point of the arc */
  72687. endPoint: Vector2);
  72688. }
  72689. /**
  72690. * Represents a 2D path made up of multiple 2D points
  72691. */
  72692. export class Path2 {
  72693. private _points;
  72694. private _length;
  72695. /**
  72696. * If the path start and end point are the same
  72697. */
  72698. closed: boolean;
  72699. /**
  72700. * Creates a Path2 object from the starting 2D coordinates x and y.
  72701. * @param x the starting points x value
  72702. * @param y the starting points y value
  72703. */
  72704. constructor(x: number, y: number);
  72705. /**
  72706. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72707. * @param x the added points x value
  72708. * @param y the added points y value
  72709. * @returns the updated Path2.
  72710. */
  72711. addLineTo(x: number, y: number): Path2;
  72712. /**
  72713. * 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.
  72714. * @param midX middle point x value
  72715. * @param midY middle point y value
  72716. * @param endX end point x value
  72717. * @param endY end point y value
  72718. * @param numberOfSegments (default: 36)
  72719. * @returns the updated Path2.
  72720. */
  72721. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72722. /**
  72723. * Closes the Path2.
  72724. * @returns the Path2.
  72725. */
  72726. close(): Path2;
  72727. /**
  72728. * Gets the sum of the distance between each sequential point in the path
  72729. * @returns the Path2 total length (float).
  72730. */
  72731. length(): number;
  72732. /**
  72733. * Gets the points which construct the path
  72734. * @returns the Path2 internal array of points.
  72735. */
  72736. getPoints(): Vector2[];
  72737. /**
  72738. * Retreives the point at the distance aways from the starting point
  72739. * @param normalizedLengthPosition the length along the path to retreive the point from
  72740. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72741. */
  72742. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72743. /**
  72744. * Creates a new path starting from an x and y position
  72745. * @param x starting x value
  72746. * @param y starting y value
  72747. * @returns a new Path2 starting at the coordinates (x, y).
  72748. */
  72749. static StartingAt(x: number, y: number): Path2;
  72750. }
  72751. /**
  72752. * Represents a 3D path made up of multiple 3D points
  72753. */
  72754. export class Path3D {
  72755. /**
  72756. * an array of Vector3, the curve axis of the Path3D
  72757. */
  72758. path: Vector3[];
  72759. private _curve;
  72760. private _distances;
  72761. private _tangents;
  72762. private _normals;
  72763. private _binormals;
  72764. private _raw;
  72765. /**
  72766. * new Path3D(path, normal, raw)
  72767. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72768. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72769. * @param path an array of Vector3, the curve axis of the Path3D
  72770. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72771. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72772. */
  72773. constructor(
  72774. /**
  72775. * an array of Vector3, the curve axis of the Path3D
  72776. */
  72777. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72778. /**
  72779. * Returns the Path3D array of successive Vector3 designing its curve.
  72780. * @returns the Path3D array of successive Vector3 designing its curve.
  72781. */
  72782. getCurve(): Vector3[];
  72783. /**
  72784. * Returns an array populated with tangent vectors on each Path3D curve point.
  72785. * @returns an array populated with tangent vectors on each Path3D curve point.
  72786. */
  72787. getTangents(): Vector3[];
  72788. /**
  72789. * Returns an array populated with normal vectors on each Path3D curve point.
  72790. * @returns an array populated with normal vectors on each Path3D curve point.
  72791. */
  72792. getNormals(): Vector3[];
  72793. /**
  72794. * Returns an array populated with binormal vectors on each Path3D curve point.
  72795. * @returns an array populated with binormal vectors on each Path3D curve point.
  72796. */
  72797. getBinormals(): Vector3[];
  72798. /**
  72799. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72800. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72801. */
  72802. getDistances(): number[];
  72803. /**
  72804. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72805. * @param path path which all values are copied into the curves points
  72806. * @param firstNormal which should be projected onto the curve
  72807. * @returns the same object updated.
  72808. */
  72809. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72810. private _compute;
  72811. private _getFirstNonNullVector;
  72812. private _getLastNonNullVector;
  72813. private _normalVector;
  72814. }
  72815. /**
  72816. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72817. * A Curve3 is designed from a series of successive Vector3.
  72818. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72819. */
  72820. export class Curve3 {
  72821. private _points;
  72822. private _length;
  72823. /**
  72824. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72825. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72826. * @param v1 (Vector3) the control point
  72827. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72828. * @param nbPoints (integer) the wanted number of points in the curve
  72829. * @returns the created Curve3
  72830. */
  72831. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72832. /**
  72833. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72834. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72835. * @param v1 (Vector3) the first control point
  72836. * @param v2 (Vector3) the second control point
  72837. * @param v3 (Vector3) the end point of the Cubic Bezier
  72838. * @param nbPoints (integer) the wanted number of points in the curve
  72839. * @returns the created Curve3
  72840. */
  72841. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72842. /**
  72843. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72844. * @param p1 (Vector3) the origin point of the Hermite Spline
  72845. * @param t1 (Vector3) the tangent vector at the origin point
  72846. * @param p2 (Vector3) the end point of the Hermite Spline
  72847. * @param t2 (Vector3) the tangent vector at the end point
  72848. * @param nbPoints (integer) the wanted number of points in the curve
  72849. * @returns the created Curve3
  72850. */
  72851. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72852. /**
  72853. * Returns a Curve3 object along a CatmullRom Spline curve :
  72854. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72855. * @param nbPoints (integer) the wanted number of points between each curve control points
  72856. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72857. * @returns the created Curve3
  72858. */
  72859. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72860. /**
  72861. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72862. * A Curve3 is designed from a series of successive Vector3.
  72863. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72864. * @param points points which make up the curve
  72865. */
  72866. constructor(points: Vector3[]);
  72867. /**
  72868. * @returns the Curve3 stored array of successive Vector3
  72869. */
  72870. getPoints(): Vector3[];
  72871. /**
  72872. * @returns the computed length (float) of the curve.
  72873. */
  72874. length(): number;
  72875. /**
  72876. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72877. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72878. * curveA and curveB keep unchanged.
  72879. * @param curve the curve to continue from this curve
  72880. * @returns the newly constructed curve
  72881. */
  72882. continue(curve: DeepImmutable<Curve3>): Curve3;
  72883. private _computeLength;
  72884. }
  72885. }
  72886. declare module BABYLON {
  72887. /**
  72888. * This represents the main contract an easing function should follow.
  72889. * Easing functions are used throughout the animation system.
  72890. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72891. */
  72892. export interface IEasingFunction {
  72893. /**
  72894. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72895. * of the easing function.
  72896. * The link below provides some of the most common examples of easing functions.
  72897. * @see https://easings.net/
  72898. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72899. * @returns the corresponding value on the curve defined by the easing function
  72900. */
  72901. ease(gradient: number): number;
  72902. }
  72903. /**
  72904. * Base class used for every default easing function.
  72905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72906. */
  72907. export class EasingFunction implements IEasingFunction {
  72908. /**
  72909. * Interpolation follows the mathematical formula associated with the easing function.
  72910. */
  72911. static readonly EASINGMODE_EASEIN: number;
  72912. /**
  72913. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72914. */
  72915. static readonly EASINGMODE_EASEOUT: number;
  72916. /**
  72917. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72918. */
  72919. static readonly EASINGMODE_EASEINOUT: number;
  72920. private _easingMode;
  72921. /**
  72922. * Sets the easing mode of the current function.
  72923. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72924. */
  72925. setEasingMode(easingMode: number): void;
  72926. /**
  72927. * Gets the current easing mode.
  72928. * @returns the easing mode
  72929. */
  72930. getEasingMode(): number;
  72931. /**
  72932. * @hidden
  72933. */
  72934. easeInCore(gradient: number): number;
  72935. /**
  72936. * Given an input gradient between 0 and 1, this returns the corresponding value
  72937. * of the easing function.
  72938. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72939. * @returns the corresponding value on the curve defined by the easing function
  72940. */
  72941. ease(gradient: number): number;
  72942. }
  72943. /**
  72944. * Easing function with a circle shape (see link below).
  72945. * @see https://easings.net/#easeInCirc
  72946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72947. */
  72948. export class CircleEase extends EasingFunction implements IEasingFunction {
  72949. /** @hidden */
  72950. easeInCore(gradient: number): number;
  72951. }
  72952. /**
  72953. * Easing function with a ease back shape (see link below).
  72954. * @see https://easings.net/#easeInBack
  72955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72956. */
  72957. export class BackEase extends EasingFunction implements IEasingFunction {
  72958. /** Defines the amplitude of the function */
  72959. amplitude: number;
  72960. /**
  72961. * Instantiates a back ease easing
  72962. * @see https://easings.net/#easeInBack
  72963. * @param amplitude Defines the amplitude of the function
  72964. */
  72965. constructor(
  72966. /** Defines the amplitude of the function */
  72967. amplitude?: number);
  72968. /** @hidden */
  72969. easeInCore(gradient: number): number;
  72970. }
  72971. /**
  72972. * Easing function with a bouncing shape (see link below).
  72973. * @see https://easings.net/#easeInBounce
  72974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72975. */
  72976. export class BounceEase extends EasingFunction implements IEasingFunction {
  72977. /** Defines the number of bounces */
  72978. bounces: number;
  72979. /** Defines the amplitude of the bounce */
  72980. bounciness: number;
  72981. /**
  72982. * Instantiates a bounce easing
  72983. * @see https://easings.net/#easeInBounce
  72984. * @param bounces Defines the number of bounces
  72985. * @param bounciness Defines the amplitude of the bounce
  72986. */
  72987. constructor(
  72988. /** Defines the number of bounces */
  72989. bounces?: number,
  72990. /** Defines the amplitude of the bounce */
  72991. bounciness?: number);
  72992. /** @hidden */
  72993. easeInCore(gradient: number): number;
  72994. }
  72995. /**
  72996. * Easing function with a power of 3 shape (see link below).
  72997. * @see https://easings.net/#easeInCubic
  72998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72999. */
  73000. export class CubicEase extends EasingFunction implements IEasingFunction {
  73001. /** @hidden */
  73002. easeInCore(gradient: number): number;
  73003. }
  73004. /**
  73005. * Easing function with an elastic shape (see link below).
  73006. * @see https://easings.net/#easeInElastic
  73007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73008. */
  73009. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73010. /** Defines the number of oscillations*/
  73011. oscillations: number;
  73012. /** Defines the amplitude of the oscillations*/
  73013. springiness: number;
  73014. /**
  73015. * Instantiates an elastic easing function
  73016. * @see https://easings.net/#easeInElastic
  73017. * @param oscillations Defines the number of oscillations
  73018. * @param springiness Defines the amplitude of the oscillations
  73019. */
  73020. constructor(
  73021. /** Defines the number of oscillations*/
  73022. oscillations?: number,
  73023. /** Defines the amplitude of the oscillations*/
  73024. springiness?: number);
  73025. /** @hidden */
  73026. easeInCore(gradient: number): number;
  73027. }
  73028. /**
  73029. * Easing function with an exponential shape (see link below).
  73030. * @see https://easings.net/#easeInExpo
  73031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73032. */
  73033. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73034. /** Defines the exponent of the function */
  73035. exponent: number;
  73036. /**
  73037. * Instantiates an exponential easing function
  73038. * @see https://easings.net/#easeInExpo
  73039. * @param exponent Defines the exponent of the function
  73040. */
  73041. constructor(
  73042. /** Defines the exponent of the function */
  73043. exponent?: number);
  73044. /** @hidden */
  73045. easeInCore(gradient: number): number;
  73046. }
  73047. /**
  73048. * Easing function with a power shape (see link below).
  73049. * @see https://easings.net/#easeInQuad
  73050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73051. */
  73052. export class PowerEase extends EasingFunction implements IEasingFunction {
  73053. /** Defines the power of the function */
  73054. power: number;
  73055. /**
  73056. * Instantiates an power base easing function
  73057. * @see https://easings.net/#easeInQuad
  73058. * @param power Defines the power of the function
  73059. */
  73060. constructor(
  73061. /** Defines the power of the function */
  73062. power?: number);
  73063. /** @hidden */
  73064. easeInCore(gradient: number): number;
  73065. }
  73066. /**
  73067. * Easing function with a power of 2 shape (see link below).
  73068. * @see https://easings.net/#easeInQuad
  73069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73070. */
  73071. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73072. /** @hidden */
  73073. easeInCore(gradient: number): number;
  73074. }
  73075. /**
  73076. * Easing function with a power of 4 shape (see link below).
  73077. * @see https://easings.net/#easeInQuart
  73078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73079. */
  73080. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73081. /** @hidden */
  73082. easeInCore(gradient: number): number;
  73083. }
  73084. /**
  73085. * Easing function with a power of 5 shape (see link below).
  73086. * @see https://easings.net/#easeInQuint
  73087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73088. */
  73089. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73090. /** @hidden */
  73091. easeInCore(gradient: number): number;
  73092. }
  73093. /**
  73094. * Easing function with a sin shape (see link below).
  73095. * @see https://easings.net/#easeInSine
  73096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73097. */
  73098. export class SineEase extends EasingFunction implements IEasingFunction {
  73099. /** @hidden */
  73100. easeInCore(gradient: number): number;
  73101. }
  73102. /**
  73103. * Easing function with a bezier shape (see link below).
  73104. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73106. */
  73107. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73108. /** Defines the x component of the start tangent in the bezier curve */
  73109. x1: number;
  73110. /** Defines the y component of the start tangent in the bezier curve */
  73111. y1: number;
  73112. /** Defines the x component of the end tangent in the bezier curve */
  73113. x2: number;
  73114. /** Defines the y component of the end tangent in the bezier curve */
  73115. y2: number;
  73116. /**
  73117. * Instantiates a bezier function
  73118. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73119. * @param x1 Defines the x component of the start tangent in the bezier curve
  73120. * @param y1 Defines the y component of the start tangent in the bezier curve
  73121. * @param x2 Defines the x component of the end tangent in the bezier curve
  73122. * @param y2 Defines the y component of the end tangent in the bezier curve
  73123. */
  73124. constructor(
  73125. /** Defines the x component of the start tangent in the bezier curve */
  73126. x1?: number,
  73127. /** Defines the y component of the start tangent in the bezier curve */
  73128. y1?: number,
  73129. /** Defines the x component of the end tangent in the bezier curve */
  73130. x2?: number,
  73131. /** Defines the y component of the end tangent in the bezier curve */
  73132. y2?: number);
  73133. /** @hidden */
  73134. easeInCore(gradient: number): number;
  73135. }
  73136. }
  73137. declare module BABYLON {
  73138. /**
  73139. * Class used to hold a RBG color
  73140. */
  73141. export class Color3 {
  73142. /**
  73143. * Defines the red component (between 0 and 1, default is 0)
  73144. */
  73145. r: number;
  73146. /**
  73147. * Defines the green component (between 0 and 1, default is 0)
  73148. */
  73149. g: number;
  73150. /**
  73151. * Defines the blue component (between 0 and 1, default is 0)
  73152. */
  73153. b: number;
  73154. /**
  73155. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73156. * @param r defines the red component (between 0 and 1, default is 0)
  73157. * @param g defines the green component (between 0 and 1, default is 0)
  73158. * @param b defines the blue component (between 0 and 1, default is 0)
  73159. */
  73160. constructor(
  73161. /**
  73162. * Defines the red component (between 0 and 1, default is 0)
  73163. */
  73164. r?: number,
  73165. /**
  73166. * Defines the green component (between 0 and 1, default is 0)
  73167. */
  73168. g?: number,
  73169. /**
  73170. * Defines the blue component (between 0 and 1, default is 0)
  73171. */
  73172. b?: number);
  73173. /**
  73174. * Creates a string with the Color3 current values
  73175. * @returns the string representation of the Color3 object
  73176. */
  73177. toString(): string;
  73178. /**
  73179. * Returns the string "Color3"
  73180. * @returns "Color3"
  73181. */
  73182. getClassName(): string;
  73183. /**
  73184. * Compute the Color3 hash code
  73185. * @returns an unique number that can be used to hash Color3 objects
  73186. */
  73187. getHashCode(): number;
  73188. /**
  73189. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73190. * @param array defines the array where to store the r,g,b components
  73191. * @param index defines an optional index in the target array to define where to start storing values
  73192. * @returns the current Color3 object
  73193. */
  73194. toArray(array: FloatArray, index?: number): Color3;
  73195. /**
  73196. * Returns a new Color4 object from the current Color3 and the given alpha
  73197. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73198. * @returns a new Color4 object
  73199. */
  73200. toColor4(alpha?: number): Color4;
  73201. /**
  73202. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73203. * @returns the new array
  73204. */
  73205. asArray(): number[];
  73206. /**
  73207. * Returns the luminance value
  73208. * @returns a float value
  73209. */
  73210. toLuminance(): number;
  73211. /**
  73212. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73213. * @param otherColor defines the second operand
  73214. * @returns the new Color3 object
  73215. */
  73216. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73217. /**
  73218. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73219. * @param otherColor defines the second operand
  73220. * @param result defines the Color3 object where to store the result
  73221. * @returns the current Color3
  73222. */
  73223. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73224. /**
  73225. * Determines equality between Color3 objects
  73226. * @param otherColor defines the second operand
  73227. * @returns true if the rgb values are equal to the given ones
  73228. */
  73229. equals(otherColor: DeepImmutable<Color3>): boolean;
  73230. /**
  73231. * Determines equality between the current Color3 object and a set of r,b,g values
  73232. * @param r defines the red component to check
  73233. * @param g defines the green component to check
  73234. * @param b defines the blue component to check
  73235. * @returns true if the rgb values are equal to the given ones
  73236. */
  73237. equalsFloats(r: number, g: number, b: number): boolean;
  73238. /**
  73239. * Multiplies in place each rgb value by scale
  73240. * @param scale defines the scaling factor
  73241. * @returns the updated Color3
  73242. */
  73243. scale(scale: number): Color3;
  73244. /**
  73245. * Multiplies the rgb values by scale and stores the result into "result"
  73246. * @param scale defines the scaling factor
  73247. * @param result defines the Color3 object where to store the result
  73248. * @returns the unmodified current Color3
  73249. */
  73250. scaleToRef(scale: number, result: Color3): Color3;
  73251. /**
  73252. * Scale the current Color3 values by a factor and add the result to a given Color3
  73253. * @param scale defines the scale factor
  73254. * @param result defines color to store the result into
  73255. * @returns the unmodified current Color3
  73256. */
  73257. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73258. /**
  73259. * Clamps the rgb values by the min and max values and stores the result into "result"
  73260. * @param min defines minimum clamping value (default is 0)
  73261. * @param max defines maximum clamping value (default is 1)
  73262. * @param result defines color to store the result into
  73263. * @returns the original Color3
  73264. */
  73265. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73266. /**
  73267. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73268. * @param otherColor defines the second operand
  73269. * @returns the new Color3
  73270. */
  73271. add(otherColor: DeepImmutable<Color3>): Color3;
  73272. /**
  73273. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73274. * @param otherColor defines the second operand
  73275. * @param result defines Color3 object to store the result into
  73276. * @returns the unmodified current Color3
  73277. */
  73278. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73279. /**
  73280. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73281. * @param otherColor defines the second operand
  73282. * @returns the new Color3
  73283. */
  73284. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73285. /**
  73286. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73287. * @param otherColor defines the second operand
  73288. * @param result defines Color3 object to store the result into
  73289. * @returns the unmodified current Color3
  73290. */
  73291. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73292. /**
  73293. * Copy the current object
  73294. * @returns a new Color3 copied the current one
  73295. */
  73296. clone(): Color3;
  73297. /**
  73298. * Copies the rgb values from the source in the current Color3
  73299. * @param source defines the source Color3 object
  73300. * @returns the updated Color3 object
  73301. */
  73302. copyFrom(source: DeepImmutable<Color3>): Color3;
  73303. /**
  73304. * Updates the Color3 rgb values from the given floats
  73305. * @param r defines the red component to read from
  73306. * @param g defines the green component to read from
  73307. * @param b defines the blue component to read from
  73308. * @returns the current Color3 object
  73309. */
  73310. copyFromFloats(r: number, g: number, b: number): Color3;
  73311. /**
  73312. * Updates the Color3 rgb values from the given floats
  73313. * @param r defines the red component to read from
  73314. * @param g defines the green component to read from
  73315. * @param b defines the blue component to read from
  73316. * @returns the current Color3 object
  73317. */
  73318. set(r: number, g: number, b: number): Color3;
  73319. /**
  73320. * Compute the Color3 hexadecimal code as a string
  73321. * @returns a string containing the hexadecimal representation of the Color3 object
  73322. */
  73323. toHexString(): string;
  73324. /**
  73325. * Computes a new Color3 converted from the current one to linear space
  73326. * @returns a new Color3 object
  73327. */
  73328. toLinearSpace(): Color3;
  73329. /**
  73330. * Converts current color in rgb space to HSV values
  73331. * @returns a new color3 representing the HSV values
  73332. */
  73333. toHSV(): Color3;
  73334. /**
  73335. * Converts current color in rgb space to HSV values
  73336. * @param result defines the Color3 where to store the HSV values
  73337. */
  73338. toHSVToRef(result: Color3): void;
  73339. /**
  73340. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73341. * @param convertedColor defines the Color3 object where to store the linear space version
  73342. * @returns the unmodified Color3
  73343. */
  73344. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73345. /**
  73346. * Computes a new Color3 converted from the current one to gamma space
  73347. * @returns a new Color3 object
  73348. */
  73349. toGammaSpace(): Color3;
  73350. /**
  73351. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73352. * @param convertedColor defines the Color3 object where to store the gamma space version
  73353. * @returns the unmodified Color3
  73354. */
  73355. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73356. private static _BlackReadOnly;
  73357. /**
  73358. * Convert Hue, saturation and value to a Color3 (RGB)
  73359. * @param hue defines the hue
  73360. * @param saturation defines the saturation
  73361. * @param value defines the value
  73362. * @param result defines the Color3 where to store the RGB values
  73363. */
  73364. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73365. /**
  73366. * Creates a new Color3 from the string containing valid hexadecimal values
  73367. * @param hex defines a string containing valid hexadecimal values
  73368. * @returns a new Color3 object
  73369. */
  73370. static FromHexString(hex: string): Color3;
  73371. /**
  73372. * Creates a new Color3 from the starting index of the given array
  73373. * @param array defines the source array
  73374. * @param offset defines an offset in the source array
  73375. * @returns a new Color3 object
  73376. */
  73377. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73378. /**
  73379. * Creates a new Color3 from integer values (< 256)
  73380. * @param r defines the red component to read from (value between 0 and 255)
  73381. * @param g defines the green component to read from (value between 0 and 255)
  73382. * @param b defines the blue component to read from (value between 0 and 255)
  73383. * @returns a new Color3 object
  73384. */
  73385. static FromInts(r: number, g: number, b: number): Color3;
  73386. /**
  73387. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73388. * @param start defines the start Color3 value
  73389. * @param end defines the end Color3 value
  73390. * @param amount defines the gradient value between start and end
  73391. * @returns a new Color3 object
  73392. */
  73393. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73394. /**
  73395. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73396. * @param left defines the start value
  73397. * @param right defines the end value
  73398. * @param amount defines the gradient factor
  73399. * @param result defines the Color3 object where to store the result
  73400. */
  73401. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73402. /**
  73403. * Returns a Color3 value containing a red color
  73404. * @returns a new Color3 object
  73405. */
  73406. static Red(): Color3;
  73407. /**
  73408. * Returns a Color3 value containing a green color
  73409. * @returns a new Color3 object
  73410. */
  73411. static Green(): Color3;
  73412. /**
  73413. * Returns a Color3 value containing a blue color
  73414. * @returns a new Color3 object
  73415. */
  73416. static Blue(): Color3;
  73417. /**
  73418. * Returns a Color3 value containing a black color
  73419. * @returns a new Color3 object
  73420. */
  73421. static Black(): Color3;
  73422. /**
  73423. * Gets a Color3 value containing a black color that must not be updated
  73424. */
  73425. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73426. /**
  73427. * Returns a Color3 value containing a white color
  73428. * @returns a new Color3 object
  73429. */
  73430. static White(): Color3;
  73431. /**
  73432. * Returns a Color3 value containing a purple color
  73433. * @returns a new Color3 object
  73434. */
  73435. static Purple(): Color3;
  73436. /**
  73437. * Returns a Color3 value containing a magenta color
  73438. * @returns a new Color3 object
  73439. */
  73440. static Magenta(): Color3;
  73441. /**
  73442. * Returns a Color3 value containing a yellow color
  73443. * @returns a new Color3 object
  73444. */
  73445. static Yellow(): Color3;
  73446. /**
  73447. * Returns a Color3 value containing a gray color
  73448. * @returns a new Color3 object
  73449. */
  73450. static Gray(): Color3;
  73451. /**
  73452. * Returns a Color3 value containing a teal color
  73453. * @returns a new Color3 object
  73454. */
  73455. static Teal(): Color3;
  73456. /**
  73457. * Returns a Color3 value containing a random color
  73458. * @returns a new Color3 object
  73459. */
  73460. static Random(): Color3;
  73461. }
  73462. /**
  73463. * Class used to hold a RBGA color
  73464. */
  73465. export class Color4 {
  73466. /**
  73467. * Defines the red component (between 0 and 1, default is 0)
  73468. */
  73469. r: number;
  73470. /**
  73471. * Defines the green component (between 0 and 1, default is 0)
  73472. */
  73473. g: number;
  73474. /**
  73475. * Defines the blue component (between 0 and 1, default is 0)
  73476. */
  73477. b: number;
  73478. /**
  73479. * Defines the alpha component (between 0 and 1, default is 1)
  73480. */
  73481. a: number;
  73482. /**
  73483. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73484. * @param r defines the red component (between 0 and 1, default is 0)
  73485. * @param g defines the green component (between 0 and 1, default is 0)
  73486. * @param b defines the blue component (between 0 and 1, default is 0)
  73487. * @param a defines the alpha component (between 0 and 1, default is 1)
  73488. */
  73489. constructor(
  73490. /**
  73491. * Defines the red component (between 0 and 1, default is 0)
  73492. */
  73493. r?: number,
  73494. /**
  73495. * Defines the green component (between 0 and 1, default is 0)
  73496. */
  73497. g?: number,
  73498. /**
  73499. * Defines the blue component (between 0 and 1, default is 0)
  73500. */
  73501. b?: number,
  73502. /**
  73503. * Defines the alpha component (between 0 and 1, default is 1)
  73504. */
  73505. a?: number);
  73506. /**
  73507. * Adds in place the given Color4 values to the current Color4 object
  73508. * @param right defines the second operand
  73509. * @returns the current updated Color4 object
  73510. */
  73511. addInPlace(right: DeepImmutable<Color4>): Color4;
  73512. /**
  73513. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73514. * @returns the new array
  73515. */
  73516. asArray(): number[];
  73517. /**
  73518. * Stores from the starting index in the given array the Color4 successive values
  73519. * @param array defines the array where to store the r,g,b components
  73520. * @param index defines an optional index in the target array to define where to start storing values
  73521. * @returns the current Color4 object
  73522. */
  73523. toArray(array: number[], index?: number): Color4;
  73524. /**
  73525. * Determines equality between Color4 objects
  73526. * @param otherColor defines the second operand
  73527. * @returns true if the rgba values are equal to the given ones
  73528. */
  73529. equals(otherColor: DeepImmutable<Color4>): boolean;
  73530. /**
  73531. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73532. * @param right defines the second operand
  73533. * @returns a new Color4 object
  73534. */
  73535. add(right: DeepImmutable<Color4>): Color4;
  73536. /**
  73537. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73538. * @param right defines the second operand
  73539. * @returns a new Color4 object
  73540. */
  73541. subtract(right: DeepImmutable<Color4>): Color4;
  73542. /**
  73543. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73544. * @param right defines the second operand
  73545. * @param result defines the Color4 object where to store the result
  73546. * @returns the current Color4 object
  73547. */
  73548. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73549. /**
  73550. * Creates a new Color4 with the current Color4 values multiplied by scale
  73551. * @param scale defines the scaling factor to apply
  73552. * @returns a new Color4 object
  73553. */
  73554. scale(scale: number): Color4;
  73555. /**
  73556. * Multiplies the current Color4 values by scale and stores the result in "result"
  73557. * @param scale defines the scaling factor to apply
  73558. * @param result defines the Color4 object where to store the result
  73559. * @returns the current unmodified Color4
  73560. */
  73561. scaleToRef(scale: number, result: Color4): Color4;
  73562. /**
  73563. * Scale the current Color4 values by a factor and add the result to a given Color4
  73564. * @param scale defines the scale factor
  73565. * @param result defines the Color4 object where to store the result
  73566. * @returns the unmodified current Color4
  73567. */
  73568. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73569. /**
  73570. * Clamps the rgb values by the min and max values and stores the result into "result"
  73571. * @param min defines minimum clamping value (default is 0)
  73572. * @param max defines maximum clamping value (default is 1)
  73573. * @param result defines color to store the result into.
  73574. * @returns the cuurent Color4
  73575. */
  73576. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73577. /**
  73578. * Multipy an Color4 value by another and return a new Color4 object
  73579. * @param color defines the Color4 value to multiply by
  73580. * @returns a new Color4 object
  73581. */
  73582. multiply(color: Color4): Color4;
  73583. /**
  73584. * Multipy a Color4 value by another and push the result in a reference value
  73585. * @param color defines the Color4 value to multiply by
  73586. * @param result defines the Color4 to fill the result in
  73587. * @returns the result Color4
  73588. */
  73589. multiplyToRef(color: Color4, result: Color4): Color4;
  73590. /**
  73591. * Creates a string with the Color4 current values
  73592. * @returns the string representation of the Color4 object
  73593. */
  73594. toString(): string;
  73595. /**
  73596. * Returns the string "Color4"
  73597. * @returns "Color4"
  73598. */
  73599. getClassName(): string;
  73600. /**
  73601. * Compute the Color4 hash code
  73602. * @returns an unique number that can be used to hash Color4 objects
  73603. */
  73604. getHashCode(): number;
  73605. /**
  73606. * Creates a new Color4 copied from the current one
  73607. * @returns a new Color4 object
  73608. */
  73609. clone(): Color4;
  73610. /**
  73611. * Copies the given Color4 values into the current one
  73612. * @param source defines the source Color4 object
  73613. * @returns the current updated Color4 object
  73614. */
  73615. copyFrom(source: Color4): Color4;
  73616. /**
  73617. * Copies the given float values into the current one
  73618. * @param r defines the red component to read from
  73619. * @param g defines the green component to read from
  73620. * @param b defines the blue component to read from
  73621. * @param a defines the alpha component to read from
  73622. * @returns the current updated Color4 object
  73623. */
  73624. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73625. /**
  73626. * Copies the given float values into the current one
  73627. * @param r defines the red component to read from
  73628. * @param g defines the green component to read from
  73629. * @param b defines the blue component to read from
  73630. * @param a defines the alpha component to read from
  73631. * @returns the current updated Color4 object
  73632. */
  73633. set(r: number, g: number, b: number, a: number): Color4;
  73634. /**
  73635. * Compute the Color4 hexadecimal code as a string
  73636. * @returns a string containing the hexadecimal representation of the Color4 object
  73637. */
  73638. toHexString(): string;
  73639. /**
  73640. * Computes a new Color4 converted from the current one to linear space
  73641. * @returns a new Color4 object
  73642. */
  73643. toLinearSpace(): Color4;
  73644. /**
  73645. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73646. * @param convertedColor defines the Color4 object where to store the linear space version
  73647. * @returns the unmodified Color4
  73648. */
  73649. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73650. /**
  73651. * Computes a new Color4 converted from the current one to gamma space
  73652. * @returns a new Color4 object
  73653. */
  73654. toGammaSpace(): Color4;
  73655. /**
  73656. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73657. * @param convertedColor defines the Color4 object where to store the gamma space version
  73658. * @returns the unmodified Color4
  73659. */
  73660. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73661. /**
  73662. * Creates a new Color4 from the string containing valid hexadecimal values
  73663. * @param hex defines a string containing valid hexadecimal values
  73664. * @returns a new Color4 object
  73665. */
  73666. static FromHexString(hex: string): Color4;
  73667. /**
  73668. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73669. * @param left defines the start value
  73670. * @param right defines the end value
  73671. * @param amount defines the gradient factor
  73672. * @returns a new Color4 object
  73673. */
  73674. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73675. /**
  73676. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73677. * @param left defines the start value
  73678. * @param right defines the end value
  73679. * @param amount defines the gradient factor
  73680. * @param result defines the Color4 object where to store data
  73681. */
  73682. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73683. /**
  73684. * Creates a new Color4 from a Color3 and an alpha value
  73685. * @param color3 defines the source Color3 to read from
  73686. * @param alpha defines the alpha component (1.0 by default)
  73687. * @returns a new Color4 object
  73688. */
  73689. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73690. /**
  73691. * Creates a new Color4 from the starting index element of the given array
  73692. * @param array defines the source array to read from
  73693. * @param offset defines the offset in the source array
  73694. * @returns a new Color4 object
  73695. */
  73696. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73697. /**
  73698. * Creates a new Color3 from integer values (< 256)
  73699. * @param r defines the red component to read from (value between 0 and 255)
  73700. * @param g defines the green component to read from (value between 0 and 255)
  73701. * @param b defines the blue component to read from (value between 0 and 255)
  73702. * @param a defines the alpha component to read from (value between 0 and 255)
  73703. * @returns a new Color3 object
  73704. */
  73705. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73706. /**
  73707. * Check the content of a given array and convert it to an array containing RGBA data
  73708. * If the original array was already containing count * 4 values then it is returned directly
  73709. * @param colors defines the array to check
  73710. * @param count defines the number of RGBA data to expect
  73711. * @returns an array containing count * 4 values (RGBA)
  73712. */
  73713. static CheckColors4(colors: number[], count: number): number[];
  73714. }
  73715. /**
  73716. * @hidden
  73717. */
  73718. export class TmpColors {
  73719. static Color3: Color3[];
  73720. static Color4: Color4[];
  73721. }
  73722. }
  73723. declare module BABYLON {
  73724. /**
  73725. * Defines an interface which represents an animation key frame
  73726. */
  73727. export interface IAnimationKey {
  73728. /**
  73729. * Frame of the key frame
  73730. */
  73731. frame: number;
  73732. /**
  73733. * Value at the specifies key frame
  73734. */
  73735. value: any;
  73736. /**
  73737. * The input tangent for the cubic hermite spline
  73738. */
  73739. inTangent?: any;
  73740. /**
  73741. * The output tangent for the cubic hermite spline
  73742. */
  73743. outTangent?: any;
  73744. /**
  73745. * The animation interpolation type
  73746. */
  73747. interpolation?: AnimationKeyInterpolation;
  73748. }
  73749. /**
  73750. * Enum for the animation key frame interpolation type
  73751. */
  73752. export enum AnimationKeyInterpolation {
  73753. /**
  73754. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73755. */
  73756. STEP = 1
  73757. }
  73758. }
  73759. declare module BABYLON {
  73760. /**
  73761. * Represents the range of an animation
  73762. */
  73763. export class AnimationRange {
  73764. /**The name of the animation range**/
  73765. name: string;
  73766. /**The starting frame of the animation */
  73767. from: number;
  73768. /**The ending frame of the animation*/
  73769. to: number;
  73770. /**
  73771. * Initializes the range of an animation
  73772. * @param name The name of the animation range
  73773. * @param from The starting frame of the animation
  73774. * @param to The ending frame of the animation
  73775. */
  73776. constructor(
  73777. /**The name of the animation range**/
  73778. name: string,
  73779. /**The starting frame of the animation */
  73780. from: number,
  73781. /**The ending frame of the animation*/
  73782. to: number);
  73783. /**
  73784. * Makes a copy of the animation range
  73785. * @returns A copy of the animation range
  73786. */
  73787. clone(): AnimationRange;
  73788. }
  73789. }
  73790. declare module BABYLON {
  73791. /**
  73792. * Composed of a frame, and an action function
  73793. */
  73794. export class AnimationEvent {
  73795. /** The frame for which the event is triggered **/
  73796. frame: number;
  73797. /** The event to perform when triggered **/
  73798. action: (currentFrame: number) => void;
  73799. /** Specifies if the event should be triggered only once**/
  73800. onlyOnce?: boolean | undefined;
  73801. /**
  73802. * Specifies if the animation event is done
  73803. */
  73804. isDone: boolean;
  73805. /**
  73806. * Initializes the animation event
  73807. * @param frame The frame for which the event is triggered
  73808. * @param action The event to perform when triggered
  73809. * @param onlyOnce Specifies if the event should be triggered only once
  73810. */
  73811. constructor(
  73812. /** The frame for which the event is triggered **/
  73813. frame: number,
  73814. /** The event to perform when triggered **/
  73815. action: (currentFrame: number) => void,
  73816. /** Specifies if the event should be triggered only once**/
  73817. onlyOnce?: boolean | undefined);
  73818. /** @hidden */
  73819. _clone(): AnimationEvent;
  73820. }
  73821. }
  73822. declare module BABYLON {
  73823. /**
  73824. * Interface used to define a behavior
  73825. */
  73826. export interface Behavior<T> {
  73827. /** gets or sets behavior's name */
  73828. name: string;
  73829. /**
  73830. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73831. */
  73832. init(): void;
  73833. /**
  73834. * Called when the behavior is attached to a target
  73835. * @param target defines the target where the behavior is attached to
  73836. */
  73837. attach(target: T): void;
  73838. /**
  73839. * Called when the behavior is detached from its target
  73840. */
  73841. detach(): void;
  73842. }
  73843. /**
  73844. * Interface implemented by classes supporting behaviors
  73845. */
  73846. export interface IBehaviorAware<T> {
  73847. /**
  73848. * Attach a behavior
  73849. * @param behavior defines the behavior to attach
  73850. * @returns the current host
  73851. */
  73852. addBehavior(behavior: Behavior<T>): T;
  73853. /**
  73854. * Remove a behavior from the current object
  73855. * @param behavior defines the behavior to detach
  73856. * @returns the current host
  73857. */
  73858. removeBehavior(behavior: Behavior<T>): T;
  73859. /**
  73860. * Gets a behavior using its name to search
  73861. * @param name defines the name to search
  73862. * @returns the behavior or null if not found
  73863. */
  73864. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73865. }
  73866. }
  73867. declare module BABYLON {
  73868. /**
  73869. * Defines an array and its length.
  73870. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73871. */
  73872. export interface ISmartArrayLike<T> {
  73873. /**
  73874. * The data of the array.
  73875. */
  73876. data: Array<T>;
  73877. /**
  73878. * The active length of the array.
  73879. */
  73880. length: number;
  73881. }
  73882. /**
  73883. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73884. */
  73885. export class SmartArray<T> implements ISmartArrayLike<T> {
  73886. /**
  73887. * The full set of data from the array.
  73888. */
  73889. data: Array<T>;
  73890. /**
  73891. * The active length of the array.
  73892. */
  73893. length: number;
  73894. protected _id: number;
  73895. /**
  73896. * Instantiates a Smart Array.
  73897. * @param capacity defines the default capacity of the array.
  73898. */
  73899. constructor(capacity: number);
  73900. /**
  73901. * Pushes a value at the end of the active data.
  73902. * @param value defines the object to push in the array.
  73903. */
  73904. push(value: T): void;
  73905. /**
  73906. * Iterates over the active data and apply the lambda to them.
  73907. * @param func defines the action to apply on each value.
  73908. */
  73909. forEach(func: (content: T) => void): void;
  73910. /**
  73911. * Sorts the full sets of data.
  73912. * @param compareFn defines the comparison function to apply.
  73913. */
  73914. sort(compareFn: (a: T, b: T) => number): void;
  73915. /**
  73916. * Resets the active data to an empty array.
  73917. */
  73918. reset(): void;
  73919. /**
  73920. * Releases all the data from the array as well as the array.
  73921. */
  73922. dispose(): void;
  73923. /**
  73924. * Concats the active data with a given array.
  73925. * @param array defines the data to concatenate with.
  73926. */
  73927. concat(array: any): void;
  73928. /**
  73929. * Returns the position of a value in the active data.
  73930. * @param value defines the value to find the index for
  73931. * @returns the index if found in the active data otherwise -1
  73932. */
  73933. indexOf(value: T): number;
  73934. /**
  73935. * Returns whether an element is part of the active data.
  73936. * @param value defines the value to look for
  73937. * @returns true if found in the active data otherwise false
  73938. */
  73939. contains(value: T): boolean;
  73940. private static _GlobalId;
  73941. }
  73942. /**
  73943. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73944. * The data in this array can only be present once
  73945. */
  73946. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73947. private _duplicateId;
  73948. /**
  73949. * Pushes a value at the end of the active data.
  73950. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73951. * @param value defines the object to push in the array.
  73952. */
  73953. push(value: T): void;
  73954. /**
  73955. * Pushes a value at the end of the active data.
  73956. * If the data is already present, it won t be added again
  73957. * @param value defines the object to push in the array.
  73958. * @returns true if added false if it was already present
  73959. */
  73960. pushNoDuplicate(value: T): boolean;
  73961. /**
  73962. * Resets the active data to an empty array.
  73963. */
  73964. reset(): void;
  73965. /**
  73966. * Concats the active data with a given array.
  73967. * This ensures no dupplicate will be present in the result.
  73968. * @param array defines the data to concatenate with.
  73969. */
  73970. concatWithNoDuplicate(array: any): void;
  73971. }
  73972. }
  73973. declare module BABYLON {
  73974. /**
  73975. * @ignore
  73976. * This is a list of all the different input types that are available in the application.
  73977. * Fo instance: ArcRotateCameraGamepadInput...
  73978. */
  73979. export var CameraInputTypes: {};
  73980. /**
  73981. * This is the contract to implement in order to create a new input class.
  73982. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73983. */
  73984. export interface ICameraInput<TCamera extends Camera> {
  73985. /**
  73986. * Defines the camera the input is attached to.
  73987. */
  73988. camera: Nullable<TCamera>;
  73989. /**
  73990. * Gets the class name of the current intput.
  73991. * @returns the class name
  73992. */
  73993. getClassName(): string;
  73994. /**
  73995. * Get the friendly name associated with the input class.
  73996. * @returns the input friendly name
  73997. */
  73998. getSimpleName(): string;
  73999. /**
  74000. * Attach the input controls to a specific dom element to get the input from.
  74001. * @param element Defines the element the controls should be listened from
  74002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74003. */
  74004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74005. /**
  74006. * Detach the current controls from the specified dom element.
  74007. * @param element Defines the element to stop listening the inputs from
  74008. */
  74009. detachControl(element: Nullable<HTMLElement>): void;
  74010. /**
  74011. * Update the current camera state depending on the inputs that have been used this frame.
  74012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74013. */
  74014. checkInputs?: () => void;
  74015. }
  74016. /**
  74017. * Represents a map of input types to input instance or input index to input instance.
  74018. */
  74019. export interface CameraInputsMap<TCamera extends Camera> {
  74020. /**
  74021. * Accessor to the input by input type.
  74022. */
  74023. [name: string]: ICameraInput<TCamera>;
  74024. /**
  74025. * Accessor to the input by input index.
  74026. */
  74027. [idx: number]: ICameraInput<TCamera>;
  74028. }
  74029. /**
  74030. * This represents the input manager used within a camera.
  74031. * It helps dealing with all the different kind of input attached to a camera.
  74032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74033. */
  74034. export class CameraInputsManager<TCamera extends Camera> {
  74035. /**
  74036. * Defines the list of inputs attahed to the camera.
  74037. */
  74038. attached: CameraInputsMap<TCamera>;
  74039. /**
  74040. * Defines the dom element the camera is collecting inputs from.
  74041. * This is null if the controls have not been attached.
  74042. */
  74043. attachedElement: Nullable<HTMLElement>;
  74044. /**
  74045. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74046. */
  74047. noPreventDefault: boolean;
  74048. /**
  74049. * Defined the camera the input manager belongs to.
  74050. */
  74051. camera: TCamera;
  74052. /**
  74053. * Update the current camera state depending on the inputs that have been used this frame.
  74054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74055. */
  74056. checkInputs: () => void;
  74057. /**
  74058. * Instantiate a new Camera Input Manager.
  74059. * @param camera Defines the camera the input manager blongs to
  74060. */
  74061. constructor(camera: TCamera);
  74062. /**
  74063. * Add an input method to a camera
  74064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74065. * @param input camera input method
  74066. */
  74067. add(input: ICameraInput<TCamera>): void;
  74068. /**
  74069. * Remove a specific input method from a camera
  74070. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74071. * @param inputToRemove camera input method
  74072. */
  74073. remove(inputToRemove: ICameraInput<TCamera>): void;
  74074. /**
  74075. * Remove a specific input type from a camera
  74076. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74077. * @param inputType the type of the input to remove
  74078. */
  74079. removeByType(inputType: string): void;
  74080. private _addCheckInputs;
  74081. /**
  74082. * Attach the input controls to the currently attached dom element to listen the events from.
  74083. * @param input Defines the input to attach
  74084. */
  74085. attachInput(input: ICameraInput<TCamera>): void;
  74086. /**
  74087. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74088. * @param element Defines the dom element to collect the events from
  74089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74090. */
  74091. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74092. /**
  74093. * Detach the current manager inputs controls from a specific dom element.
  74094. * @param element Defines the dom element to collect the events from
  74095. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74096. */
  74097. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74098. /**
  74099. * Rebuild the dynamic inputCheck function from the current list of
  74100. * defined inputs in the manager.
  74101. */
  74102. rebuildInputCheck(): void;
  74103. /**
  74104. * Remove all attached input methods from a camera
  74105. */
  74106. clear(): void;
  74107. /**
  74108. * Serialize the current input manager attached to a camera.
  74109. * This ensures than once parsed,
  74110. * the input associated to the camera will be identical to the current ones
  74111. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74112. */
  74113. serialize(serializedCamera: any): void;
  74114. /**
  74115. * Parses an input manager serialized JSON to restore the previous list of inputs
  74116. * and states associated to a camera.
  74117. * @param parsedCamera Defines the JSON to parse
  74118. */
  74119. parse(parsedCamera: any): void;
  74120. }
  74121. }
  74122. declare module BABYLON {
  74123. /**
  74124. * Class used to store data that will be store in GPU memory
  74125. */
  74126. export class Buffer {
  74127. private _engine;
  74128. private _buffer;
  74129. /** @hidden */
  74130. _data: Nullable<DataArray>;
  74131. private _updatable;
  74132. private _instanced;
  74133. private _divisor;
  74134. /**
  74135. * Gets the byte stride.
  74136. */
  74137. readonly byteStride: number;
  74138. /**
  74139. * Constructor
  74140. * @param engine the engine
  74141. * @param data the data to use for this buffer
  74142. * @param updatable whether the data is updatable
  74143. * @param stride the stride (optional)
  74144. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74145. * @param instanced whether the buffer is instanced (optional)
  74146. * @param useBytes set to true if the stride in in bytes (optional)
  74147. * @param divisor sets an optional divisor for instances (1 by default)
  74148. */
  74149. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74150. /**
  74151. * Create a new VertexBuffer based on the current buffer
  74152. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74153. * @param offset defines offset in the buffer (0 by default)
  74154. * @param size defines the size in floats of attributes (position is 3 for instance)
  74155. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74156. * @param instanced defines if the vertex buffer contains indexed data
  74157. * @param useBytes defines if the offset and stride are in bytes *
  74158. * @param divisor sets an optional divisor for instances (1 by default)
  74159. * @returns the new vertex buffer
  74160. */
  74161. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74162. /**
  74163. * Gets a boolean indicating if the Buffer is updatable?
  74164. * @returns true if the buffer is updatable
  74165. */
  74166. isUpdatable(): boolean;
  74167. /**
  74168. * Gets current buffer's data
  74169. * @returns a DataArray or null
  74170. */
  74171. getData(): Nullable<DataArray>;
  74172. /**
  74173. * Gets underlying native buffer
  74174. * @returns underlying native buffer
  74175. */
  74176. getBuffer(): Nullable<DataBuffer>;
  74177. /**
  74178. * Gets the stride in float32 units (i.e. byte stride / 4).
  74179. * May not be an integer if the byte stride is not divisible by 4.
  74180. * DEPRECATED. Use byteStride instead.
  74181. * @returns the stride in float32 units
  74182. */
  74183. getStrideSize(): number;
  74184. /**
  74185. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74186. * @param data defines the data to store
  74187. */
  74188. create(data?: Nullable<DataArray>): void;
  74189. /** @hidden */
  74190. _rebuild(): void;
  74191. /**
  74192. * Update current buffer data
  74193. * @param data defines the data to store
  74194. */
  74195. update(data: DataArray): void;
  74196. /**
  74197. * Updates the data directly.
  74198. * @param data the new data
  74199. * @param offset the new offset
  74200. * @param vertexCount the vertex count (optional)
  74201. * @param useBytes set to true if the offset is in bytes
  74202. */
  74203. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74204. /**
  74205. * Release all resources
  74206. */
  74207. dispose(): void;
  74208. }
  74209. /**
  74210. * Specialized buffer used to store vertex data
  74211. */
  74212. export class VertexBuffer {
  74213. /** @hidden */
  74214. _buffer: Buffer;
  74215. private _kind;
  74216. private _size;
  74217. private _ownsBuffer;
  74218. private _instanced;
  74219. private _instanceDivisor;
  74220. /**
  74221. * The byte type.
  74222. */
  74223. static readonly BYTE: number;
  74224. /**
  74225. * The unsigned byte type.
  74226. */
  74227. static readonly UNSIGNED_BYTE: number;
  74228. /**
  74229. * The short type.
  74230. */
  74231. static readonly SHORT: number;
  74232. /**
  74233. * The unsigned short type.
  74234. */
  74235. static readonly UNSIGNED_SHORT: number;
  74236. /**
  74237. * The integer type.
  74238. */
  74239. static readonly INT: number;
  74240. /**
  74241. * The unsigned integer type.
  74242. */
  74243. static readonly UNSIGNED_INT: number;
  74244. /**
  74245. * The float type.
  74246. */
  74247. static readonly FLOAT: number;
  74248. /**
  74249. * Gets or sets the instance divisor when in instanced mode
  74250. */
  74251. instanceDivisor: number;
  74252. /**
  74253. * Gets the byte stride.
  74254. */
  74255. readonly byteStride: number;
  74256. /**
  74257. * Gets the byte offset.
  74258. */
  74259. readonly byteOffset: number;
  74260. /**
  74261. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74262. */
  74263. readonly normalized: boolean;
  74264. /**
  74265. * Gets the data type of each component in the array.
  74266. */
  74267. readonly type: number;
  74268. /**
  74269. * Constructor
  74270. * @param engine the engine
  74271. * @param data the data to use for this vertex buffer
  74272. * @param kind the vertex buffer kind
  74273. * @param updatable whether the data is updatable
  74274. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74275. * @param stride the stride (optional)
  74276. * @param instanced whether the buffer is instanced (optional)
  74277. * @param offset the offset of the data (optional)
  74278. * @param size the number of components (optional)
  74279. * @param type the type of the component (optional)
  74280. * @param normalized whether the data contains normalized data (optional)
  74281. * @param useBytes set to true if stride and offset are in bytes (optional)
  74282. * @param divisor defines the instance divisor to use (1 by default)
  74283. */
  74284. 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);
  74285. /** @hidden */
  74286. _rebuild(): void;
  74287. /**
  74288. * Returns the kind of the VertexBuffer (string)
  74289. * @returns a string
  74290. */
  74291. getKind(): string;
  74292. /**
  74293. * Gets a boolean indicating if the VertexBuffer is updatable?
  74294. * @returns true if the buffer is updatable
  74295. */
  74296. isUpdatable(): boolean;
  74297. /**
  74298. * Gets current buffer's data
  74299. * @returns a DataArray or null
  74300. */
  74301. getData(): Nullable<DataArray>;
  74302. /**
  74303. * Gets underlying native buffer
  74304. * @returns underlying native buffer
  74305. */
  74306. getBuffer(): Nullable<DataBuffer>;
  74307. /**
  74308. * Gets the stride in float32 units (i.e. byte stride / 4).
  74309. * May not be an integer if the byte stride is not divisible by 4.
  74310. * DEPRECATED. Use byteStride instead.
  74311. * @returns the stride in float32 units
  74312. */
  74313. getStrideSize(): number;
  74314. /**
  74315. * Returns the offset as a multiple of the type byte length.
  74316. * DEPRECATED. Use byteOffset instead.
  74317. * @returns the offset in bytes
  74318. */
  74319. getOffset(): number;
  74320. /**
  74321. * Returns the number of components per vertex attribute (integer)
  74322. * @returns the size in float
  74323. */
  74324. getSize(): number;
  74325. /**
  74326. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74327. * @returns true if this buffer is instanced
  74328. */
  74329. getIsInstanced(): boolean;
  74330. /**
  74331. * Returns the instancing divisor, zero for non-instanced (integer).
  74332. * @returns a number
  74333. */
  74334. getInstanceDivisor(): number;
  74335. /**
  74336. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74337. * @param data defines the data to store
  74338. */
  74339. create(data?: DataArray): void;
  74340. /**
  74341. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74342. * This function will create a new buffer if the current one is not updatable
  74343. * @param data defines the data to store
  74344. */
  74345. update(data: DataArray): void;
  74346. /**
  74347. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74348. * Returns the directly updated WebGLBuffer.
  74349. * @param data the new data
  74350. * @param offset the new offset
  74351. * @param useBytes set to true if the offset is in bytes
  74352. */
  74353. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74354. /**
  74355. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74356. */
  74357. dispose(): void;
  74358. /**
  74359. * Enumerates each value of this vertex buffer as numbers.
  74360. * @param count the number of values to enumerate
  74361. * @param callback the callback function called for each value
  74362. */
  74363. forEach(count: number, callback: (value: number, index: number) => void): void;
  74364. /**
  74365. * Positions
  74366. */
  74367. static readonly PositionKind: string;
  74368. /**
  74369. * Normals
  74370. */
  74371. static readonly NormalKind: string;
  74372. /**
  74373. * Tangents
  74374. */
  74375. static readonly TangentKind: string;
  74376. /**
  74377. * Texture coordinates
  74378. */
  74379. static readonly UVKind: string;
  74380. /**
  74381. * Texture coordinates 2
  74382. */
  74383. static readonly UV2Kind: string;
  74384. /**
  74385. * Texture coordinates 3
  74386. */
  74387. static readonly UV3Kind: string;
  74388. /**
  74389. * Texture coordinates 4
  74390. */
  74391. static readonly UV4Kind: string;
  74392. /**
  74393. * Texture coordinates 5
  74394. */
  74395. static readonly UV5Kind: string;
  74396. /**
  74397. * Texture coordinates 6
  74398. */
  74399. static readonly UV6Kind: string;
  74400. /**
  74401. * Colors
  74402. */
  74403. static readonly ColorKind: string;
  74404. /**
  74405. * Matrix indices (for bones)
  74406. */
  74407. static readonly MatricesIndicesKind: string;
  74408. /**
  74409. * Matrix weights (for bones)
  74410. */
  74411. static readonly MatricesWeightsKind: string;
  74412. /**
  74413. * Additional matrix indices (for bones)
  74414. */
  74415. static readonly MatricesIndicesExtraKind: string;
  74416. /**
  74417. * Additional matrix weights (for bones)
  74418. */
  74419. static readonly MatricesWeightsExtraKind: string;
  74420. /**
  74421. * Deduces the stride given a kind.
  74422. * @param kind The kind string to deduce
  74423. * @returns The deduced stride
  74424. */
  74425. static DeduceStride(kind: string): number;
  74426. /**
  74427. * Gets the byte length of the given type.
  74428. * @param type the type
  74429. * @returns the number of bytes
  74430. */
  74431. static GetTypeByteLength(type: number): number;
  74432. /**
  74433. * Enumerates each value of the given parameters as numbers.
  74434. * @param data the data to enumerate
  74435. * @param byteOffset the byte offset of the data
  74436. * @param byteStride the byte stride of the data
  74437. * @param componentCount the number of components per element
  74438. * @param componentType the type of the component
  74439. * @param count the number of values to enumerate
  74440. * @param normalized whether the data is normalized
  74441. * @param callback the callback function called for each value
  74442. */
  74443. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74444. private static _GetFloatValue;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /**
  74449. * @hidden
  74450. */
  74451. export class IntersectionInfo {
  74452. bu: Nullable<number>;
  74453. bv: Nullable<number>;
  74454. distance: number;
  74455. faceId: number;
  74456. subMeshId: number;
  74457. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74458. }
  74459. }
  74460. declare module BABYLON {
  74461. /**
  74462. * Represens a plane by the equation ax + by + cz + d = 0
  74463. */
  74464. export class Plane {
  74465. private static _TmpMatrix;
  74466. /**
  74467. * Normal of the plane (a,b,c)
  74468. */
  74469. normal: Vector3;
  74470. /**
  74471. * d component of the plane
  74472. */
  74473. d: number;
  74474. /**
  74475. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74476. * @param a a component of the plane
  74477. * @param b b component of the plane
  74478. * @param c c component of the plane
  74479. * @param d d component of the plane
  74480. */
  74481. constructor(a: number, b: number, c: number, d: number);
  74482. /**
  74483. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74484. */
  74485. asArray(): number[];
  74486. /**
  74487. * @returns a new plane copied from the current Plane.
  74488. */
  74489. clone(): Plane;
  74490. /**
  74491. * @returns the string "Plane".
  74492. */
  74493. getClassName(): string;
  74494. /**
  74495. * @returns the Plane hash code.
  74496. */
  74497. getHashCode(): number;
  74498. /**
  74499. * Normalize the current Plane in place.
  74500. * @returns the updated Plane.
  74501. */
  74502. normalize(): Plane;
  74503. /**
  74504. * Applies a transformation the plane and returns the result
  74505. * @param transformation the transformation matrix to be applied to the plane
  74506. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74507. */
  74508. transform(transformation: DeepImmutable<Matrix>): Plane;
  74509. /**
  74510. * Calcualtte the dot product between the point and the plane normal
  74511. * @param point point to calculate the dot product with
  74512. * @returns the dot product (float) of the point coordinates and the plane normal.
  74513. */
  74514. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74515. /**
  74516. * Updates the current Plane from the plane defined by the three given points.
  74517. * @param point1 one of the points used to contruct the plane
  74518. * @param point2 one of the points used to contruct the plane
  74519. * @param point3 one of the points used to contruct the plane
  74520. * @returns the updated Plane.
  74521. */
  74522. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74523. /**
  74524. * Checks if the plane is facing a given direction
  74525. * @param direction the direction to check if the plane is facing
  74526. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74527. * @returns True is the vector "direction" is the same side than the plane normal.
  74528. */
  74529. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74530. /**
  74531. * Calculates the distance to a point
  74532. * @param point point to calculate distance to
  74533. * @returns the signed distance (float) from the given point to the Plane.
  74534. */
  74535. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74536. /**
  74537. * Creates a plane from an array
  74538. * @param array the array to create a plane from
  74539. * @returns a new Plane from the given array.
  74540. */
  74541. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74542. /**
  74543. * Creates a plane from three points
  74544. * @param point1 point used to create the plane
  74545. * @param point2 point used to create the plane
  74546. * @param point3 point used to create the plane
  74547. * @returns a new Plane defined by the three given points.
  74548. */
  74549. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74550. /**
  74551. * Creates a plane from an origin point and a normal
  74552. * @param origin origin of the plane to be constructed
  74553. * @param normal normal of the plane to be constructed
  74554. * @returns a new Plane the normal vector to this plane at the given origin point.
  74555. * Note : the vector "normal" is updated because normalized.
  74556. */
  74557. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74558. /**
  74559. * Calculates the distance from a plane and a point
  74560. * @param origin origin of the plane to be constructed
  74561. * @param normal normal of the plane to be constructed
  74562. * @param point point to calculate distance to
  74563. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74564. */
  74565. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74566. }
  74567. }
  74568. declare module BABYLON {
  74569. /**
  74570. * Class used to store bounding sphere information
  74571. */
  74572. export class BoundingSphere {
  74573. /**
  74574. * Gets the center of the bounding sphere in local space
  74575. */
  74576. readonly center: Vector3;
  74577. /**
  74578. * Radius of the bounding sphere in local space
  74579. */
  74580. radius: number;
  74581. /**
  74582. * Gets the center of the bounding sphere in world space
  74583. */
  74584. readonly centerWorld: Vector3;
  74585. /**
  74586. * Radius of the bounding sphere in world space
  74587. */
  74588. radiusWorld: number;
  74589. /**
  74590. * Gets the minimum vector in local space
  74591. */
  74592. readonly minimum: Vector3;
  74593. /**
  74594. * Gets the maximum vector in local space
  74595. */
  74596. readonly maximum: Vector3;
  74597. private _worldMatrix;
  74598. private static readonly TmpVector3;
  74599. /**
  74600. * Creates a new bounding sphere
  74601. * @param min defines the minimum vector (in local space)
  74602. * @param max defines the maximum vector (in local space)
  74603. * @param worldMatrix defines the new world matrix
  74604. */
  74605. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74606. /**
  74607. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74608. * @param min defines the new minimum vector (in local space)
  74609. * @param max defines the new maximum vector (in local space)
  74610. * @param worldMatrix defines the new world matrix
  74611. */
  74612. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74613. /**
  74614. * Scale the current bounding sphere by applying a scale factor
  74615. * @param factor defines the scale factor to apply
  74616. * @returns the current bounding box
  74617. */
  74618. scale(factor: number): BoundingSphere;
  74619. /**
  74620. * Gets the world matrix of the bounding box
  74621. * @returns a matrix
  74622. */
  74623. getWorldMatrix(): DeepImmutable<Matrix>;
  74624. /** @hidden */
  74625. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74626. /**
  74627. * Tests if the bounding sphere is intersecting the frustum planes
  74628. * @param frustumPlanes defines the frustum planes to test
  74629. * @returns true if there is an intersection
  74630. */
  74631. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74632. /**
  74633. * Tests if the bounding sphere center is in between the frustum planes.
  74634. * Used for optimistic fast inclusion.
  74635. * @param frustumPlanes defines the frustum planes to test
  74636. * @returns true if the sphere center is in between the frustum planes
  74637. */
  74638. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74639. /**
  74640. * Tests if a point is inside the bounding sphere
  74641. * @param point defines the point to test
  74642. * @returns true if the point is inside the bounding sphere
  74643. */
  74644. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74645. /**
  74646. * Checks if two sphere intersct
  74647. * @param sphere0 sphere 0
  74648. * @param sphere1 sphere 1
  74649. * @returns true if the speres intersect
  74650. */
  74651. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74652. }
  74653. }
  74654. declare module BABYLON {
  74655. /**
  74656. * Class used to store bounding box information
  74657. */
  74658. export class BoundingBox implements ICullable {
  74659. /**
  74660. * Gets the 8 vectors representing the bounding box in local space
  74661. */
  74662. readonly vectors: Vector3[];
  74663. /**
  74664. * Gets the center of the bounding box in local space
  74665. */
  74666. readonly center: Vector3;
  74667. /**
  74668. * Gets the center of the bounding box in world space
  74669. */
  74670. readonly centerWorld: Vector3;
  74671. /**
  74672. * Gets the extend size in local space
  74673. */
  74674. readonly extendSize: Vector3;
  74675. /**
  74676. * Gets the extend size in world space
  74677. */
  74678. readonly extendSizeWorld: Vector3;
  74679. /**
  74680. * Gets the OBB (object bounding box) directions
  74681. */
  74682. readonly directions: Vector3[];
  74683. /**
  74684. * Gets the 8 vectors representing the bounding box in world space
  74685. */
  74686. readonly vectorsWorld: Vector3[];
  74687. /**
  74688. * Gets the minimum vector in world space
  74689. */
  74690. readonly minimumWorld: Vector3;
  74691. /**
  74692. * Gets the maximum vector in world space
  74693. */
  74694. readonly maximumWorld: Vector3;
  74695. /**
  74696. * Gets the minimum vector in local space
  74697. */
  74698. readonly minimum: Vector3;
  74699. /**
  74700. * Gets the maximum vector in local space
  74701. */
  74702. readonly maximum: Vector3;
  74703. private _worldMatrix;
  74704. private static readonly TmpVector3;
  74705. /**
  74706. * @hidden
  74707. */
  74708. _tag: number;
  74709. /**
  74710. * Creates a new bounding box
  74711. * @param min defines the minimum vector (in local space)
  74712. * @param max defines the maximum vector (in local space)
  74713. * @param worldMatrix defines the new world matrix
  74714. */
  74715. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74716. /**
  74717. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74718. * @param min defines the new minimum vector (in local space)
  74719. * @param max defines the new maximum vector (in local space)
  74720. * @param worldMatrix defines the new world matrix
  74721. */
  74722. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74723. /**
  74724. * Scale the current bounding box by applying a scale factor
  74725. * @param factor defines the scale factor to apply
  74726. * @returns the current bounding box
  74727. */
  74728. scale(factor: number): BoundingBox;
  74729. /**
  74730. * Gets the world matrix of the bounding box
  74731. * @returns a matrix
  74732. */
  74733. getWorldMatrix(): DeepImmutable<Matrix>;
  74734. /** @hidden */
  74735. _update(world: DeepImmutable<Matrix>): void;
  74736. /**
  74737. * Tests if the bounding box is intersecting the frustum planes
  74738. * @param frustumPlanes defines the frustum planes to test
  74739. * @returns true if there is an intersection
  74740. */
  74741. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74742. /**
  74743. * Tests if the bounding box is entirely inside the frustum planes
  74744. * @param frustumPlanes defines the frustum planes to test
  74745. * @returns true if there is an inclusion
  74746. */
  74747. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74748. /**
  74749. * Tests if a point is inside the bounding box
  74750. * @param point defines the point to test
  74751. * @returns true if the point is inside the bounding box
  74752. */
  74753. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74754. /**
  74755. * Tests if the bounding box intersects with a bounding sphere
  74756. * @param sphere defines the sphere to test
  74757. * @returns true if there is an intersection
  74758. */
  74759. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74760. /**
  74761. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74762. * @param min defines the min vector to use
  74763. * @param max defines the max vector to use
  74764. * @returns true if there is an intersection
  74765. */
  74766. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74767. /**
  74768. * Tests if two bounding boxes are intersections
  74769. * @param box0 defines the first box to test
  74770. * @param box1 defines the second box to test
  74771. * @returns true if there is an intersection
  74772. */
  74773. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74774. /**
  74775. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74776. * @param minPoint defines the minimum vector of the bounding box
  74777. * @param maxPoint defines the maximum vector of the bounding box
  74778. * @param sphereCenter defines the sphere center
  74779. * @param sphereRadius defines the sphere radius
  74780. * @returns true if there is an intersection
  74781. */
  74782. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74783. /**
  74784. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74785. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74786. * @param frustumPlanes defines the frustum planes to test
  74787. * @return true if there is an inclusion
  74788. */
  74789. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74790. /**
  74791. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74792. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74793. * @param frustumPlanes defines the frustum planes to test
  74794. * @return true if there is an intersection
  74795. */
  74796. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74797. }
  74798. }
  74799. declare module BABYLON {
  74800. /** @hidden */
  74801. export class Collider {
  74802. /** Define if a collision was found */
  74803. collisionFound: boolean;
  74804. /**
  74805. * Define last intersection point in local space
  74806. */
  74807. intersectionPoint: Vector3;
  74808. /**
  74809. * Define last collided mesh
  74810. */
  74811. collidedMesh: Nullable<AbstractMesh>;
  74812. private _collisionPoint;
  74813. private _planeIntersectionPoint;
  74814. private _tempVector;
  74815. private _tempVector2;
  74816. private _tempVector3;
  74817. private _tempVector4;
  74818. private _edge;
  74819. private _baseToVertex;
  74820. private _destinationPoint;
  74821. private _slidePlaneNormal;
  74822. private _displacementVector;
  74823. /** @hidden */
  74824. _radius: Vector3;
  74825. /** @hidden */
  74826. _retry: number;
  74827. private _velocity;
  74828. private _basePoint;
  74829. private _epsilon;
  74830. /** @hidden */
  74831. _velocityWorldLength: number;
  74832. /** @hidden */
  74833. _basePointWorld: Vector3;
  74834. private _velocityWorld;
  74835. private _normalizedVelocity;
  74836. /** @hidden */
  74837. _initialVelocity: Vector3;
  74838. /** @hidden */
  74839. _initialPosition: Vector3;
  74840. private _nearestDistance;
  74841. private _collisionMask;
  74842. collisionMask: number;
  74843. /**
  74844. * Gets the plane normal used to compute the sliding response (in local space)
  74845. */
  74846. readonly slidePlaneNormal: Vector3;
  74847. /** @hidden */
  74848. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74849. /** @hidden */
  74850. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74851. /** @hidden */
  74852. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74853. /** @hidden */
  74854. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74855. /** @hidden */
  74856. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74857. /** @hidden */
  74858. _getResponse(pos: Vector3, vel: Vector3): void;
  74859. }
  74860. }
  74861. declare module BABYLON {
  74862. /**
  74863. * Interface for cullable objects
  74864. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74865. */
  74866. export interface ICullable {
  74867. /**
  74868. * Checks if the object or part of the object is in the frustum
  74869. * @param frustumPlanes Camera near/planes
  74870. * @returns true if the object is in frustum otherwise false
  74871. */
  74872. isInFrustum(frustumPlanes: Plane[]): boolean;
  74873. /**
  74874. * Checks if a cullable object (mesh...) is in the camera frustum
  74875. * Unlike isInFrustum this cheks the full bounding box
  74876. * @param frustumPlanes Camera near/planes
  74877. * @returns true if the object is in frustum otherwise false
  74878. */
  74879. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74880. }
  74881. /**
  74882. * Info for a bounding data of a mesh
  74883. */
  74884. export class BoundingInfo implements ICullable {
  74885. /**
  74886. * Bounding box for the mesh
  74887. */
  74888. readonly boundingBox: BoundingBox;
  74889. /**
  74890. * Bounding sphere for the mesh
  74891. */
  74892. readonly boundingSphere: BoundingSphere;
  74893. private _isLocked;
  74894. private static readonly TmpVector3;
  74895. /**
  74896. * Constructs bounding info
  74897. * @param minimum min vector of the bounding box/sphere
  74898. * @param maximum max vector of the bounding box/sphere
  74899. * @param worldMatrix defines the new world matrix
  74900. */
  74901. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74902. /**
  74903. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74904. * @param min defines the new minimum vector (in local space)
  74905. * @param max defines the new maximum vector (in local space)
  74906. * @param worldMatrix defines the new world matrix
  74907. */
  74908. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74909. /**
  74910. * min vector of the bounding box/sphere
  74911. */
  74912. readonly minimum: Vector3;
  74913. /**
  74914. * max vector of the bounding box/sphere
  74915. */
  74916. readonly maximum: Vector3;
  74917. /**
  74918. * If the info is locked and won't be updated to avoid perf overhead
  74919. */
  74920. isLocked: boolean;
  74921. /**
  74922. * Updates the bounding sphere and box
  74923. * @param world world matrix to be used to update
  74924. */
  74925. update(world: DeepImmutable<Matrix>): void;
  74926. /**
  74927. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74928. * @param center New center of the bounding info
  74929. * @param extend New extend of the bounding info
  74930. * @returns the current bounding info
  74931. */
  74932. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74933. /**
  74934. * Scale the current bounding info by applying a scale factor
  74935. * @param factor defines the scale factor to apply
  74936. * @returns the current bounding info
  74937. */
  74938. scale(factor: number): BoundingInfo;
  74939. /**
  74940. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74941. * @param frustumPlanes defines the frustum to test
  74942. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74943. * @returns true if the bounding info is in the frustum planes
  74944. */
  74945. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74946. /**
  74947. * Gets the world distance between the min and max points of the bounding box
  74948. */
  74949. readonly diagonalLength: number;
  74950. /**
  74951. * Checks if a cullable object (mesh...) is in the camera frustum
  74952. * Unlike isInFrustum this cheks the full bounding box
  74953. * @param frustumPlanes Camera near/planes
  74954. * @returns true if the object is in frustum otherwise false
  74955. */
  74956. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74957. /** @hidden */
  74958. _checkCollision(collider: Collider): boolean;
  74959. /**
  74960. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74961. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74962. * @param point the point to check intersection with
  74963. * @returns if the point intersects
  74964. */
  74965. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74966. /**
  74967. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74968. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74969. * @param boundingInfo the bounding info to check intersection with
  74970. * @param precise if the intersection should be done using OBB
  74971. * @returns if the bounding info intersects
  74972. */
  74973. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74974. }
  74975. }
  74976. declare module BABYLON {
  74977. /**
  74978. * Extracts minimum and maximum values from a list of indexed positions
  74979. * @param positions defines the positions to use
  74980. * @param indices defines the indices to the positions
  74981. * @param indexStart defines the start index
  74982. * @param indexCount defines the end index
  74983. * @param bias defines bias value to add to the result
  74984. * @return minimum and maximum values
  74985. */
  74986. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74987. minimum: Vector3;
  74988. maximum: Vector3;
  74989. };
  74990. /**
  74991. * Extracts minimum and maximum values from a list of positions
  74992. * @param positions defines the positions to use
  74993. * @param start defines the start index in the positions array
  74994. * @param count defines the number of positions to handle
  74995. * @param bias defines bias value to add to the result
  74996. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74997. * @return minimum and maximum values
  74998. */
  74999. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75000. minimum: Vector3;
  75001. maximum: Vector3;
  75002. };
  75003. }
  75004. declare module BABYLON {
  75005. /** @hidden */
  75006. export class WebGLDataBuffer extends DataBuffer {
  75007. private _buffer;
  75008. constructor(resource: WebGLBuffer);
  75009. readonly underlyingResource: any;
  75010. }
  75011. }
  75012. declare module BABYLON {
  75013. /** @hidden */
  75014. export class WebGLPipelineContext implements IPipelineContext {
  75015. engine: ThinEngine;
  75016. program: Nullable<WebGLProgram>;
  75017. context?: WebGLRenderingContext;
  75018. vertexShader?: WebGLShader;
  75019. fragmentShader?: WebGLShader;
  75020. isParallelCompiled: boolean;
  75021. onCompiled?: () => void;
  75022. transformFeedback?: WebGLTransformFeedback | null;
  75023. readonly isAsync: boolean;
  75024. readonly isReady: boolean;
  75025. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75026. }
  75027. }
  75028. declare module BABYLON {
  75029. interface ThinEngine {
  75030. /**
  75031. * Create an uniform buffer
  75032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75033. * @param elements defines the content of the uniform buffer
  75034. * @returns the webGL uniform buffer
  75035. */
  75036. createUniformBuffer(elements: FloatArray): DataBuffer;
  75037. /**
  75038. * Create a dynamic uniform buffer
  75039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75040. * @param elements defines the content of the uniform buffer
  75041. * @returns the webGL uniform buffer
  75042. */
  75043. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75044. /**
  75045. * Update an existing uniform buffer
  75046. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75047. * @param uniformBuffer defines the target uniform buffer
  75048. * @param elements defines the content to update
  75049. * @param offset defines the offset in the uniform buffer where update should start
  75050. * @param count defines the size of the data to update
  75051. */
  75052. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75053. /**
  75054. * Bind an uniform buffer to the current webGL context
  75055. * @param buffer defines the buffer to bind
  75056. */
  75057. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75058. /**
  75059. * Bind a buffer to the current webGL context at a given location
  75060. * @param buffer defines the buffer to bind
  75061. * @param location defines the index where to bind the buffer
  75062. */
  75063. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75064. /**
  75065. * Bind a specific block at a given index in a specific shader program
  75066. * @param pipelineContext defines the pipeline context to use
  75067. * @param blockName defines the block name
  75068. * @param index defines the index where to bind the block
  75069. */
  75070. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75071. }
  75072. }
  75073. declare module BABYLON {
  75074. /**
  75075. * Uniform buffer objects.
  75076. *
  75077. * Handles blocks of uniform on the GPU.
  75078. *
  75079. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75080. *
  75081. * For more information, please refer to :
  75082. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75083. */
  75084. export class UniformBuffer {
  75085. private _engine;
  75086. private _buffer;
  75087. private _data;
  75088. private _bufferData;
  75089. private _dynamic?;
  75090. private _uniformLocations;
  75091. private _uniformSizes;
  75092. private _uniformLocationPointer;
  75093. private _needSync;
  75094. private _noUBO;
  75095. private _currentEffect;
  75096. /** @hidden */
  75097. _alreadyBound: boolean;
  75098. private static _MAX_UNIFORM_SIZE;
  75099. private static _tempBuffer;
  75100. /**
  75101. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75102. * This is dynamic to allow compat with webgl 1 and 2.
  75103. * You will need to pass the name of the uniform as well as the value.
  75104. */
  75105. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75106. /**
  75107. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75108. * This is dynamic to allow compat with webgl 1 and 2.
  75109. * You will need to pass the name of the uniform as well as the value.
  75110. */
  75111. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75112. /**
  75113. * Lambda to Update a single float in a uniform buffer.
  75114. * This is dynamic to allow compat with webgl 1 and 2.
  75115. * You will need to pass the name of the uniform as well as the value.
  75116. */
  75117. updateFloat: (name: string, x: number) => void;
  75118. /**
  75119. * Lambda to Update a vec2 of float in a uniform buffer.
  75120. * This is dynamic to allow compat with webgl 1 and 2.
  75121. * You will need to pass the name of the uniform as well as the value.
  75122. */
  75123. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75124. /**
  75125. * Lambda to Update a vec3 of float in a uniform buffer.
  75126. * This is dynamic to allow compat with webgl 1 and 2.
  75127. * You will need to pass the name of the uniform as well as the value.
  75128. */
  75129. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75130. /**
  75131. * Lambda to Update a vec4 of float in a uniform buffer.
  75132. * This is dynamic to allow compat with webgl 1 and 2.
  75133. * You will need to pass the name of the uniform as well as the value.
  75134. */
  75135. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75136. /**
  75137. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75138. * This is dynamic to allow compat with webgl 1 and 2.
  75139. * You will need to pass the name of the uniform as well as the value.
  75140. */
  75141. updateMatrix: (name: string, mat: Matrix) => void;
  75142. /**
  75143. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75144. * This is dynamic to allow compat with webgl 1 and 2.
  75145. * You will need to pass the name of the uniform as well as the value.
  75146. */
  75147. updateVector3: (name: string, vector: Vector3) => void;
  75148. /**
  75149. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75150. * This is dynamic to allow compat with webgl 1 and 2.
  75151. * You will need to pass the name of the uniform as well as the value.
  75152. */
  75153. updateVector4: (name: string, vector: Vector4) => void;
  75154. /**
  75155. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75156. * This is dynamic to allow compat with webgl 1 and 2.
  75157. * You will need to pass the name of the uniform as well as the value.
  75158. */
  75159. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75160. /**
  75161. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75162. * This is dynamic to allow compat with webgl 1 and 2.
  75163. * You will need to pass the name of the uniform as well as the value.
  75164. */
  75165. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75166. /**
  75167. * Instantiates a new Uniform buffer objects.
  75168. *
  75169. * Handles blocks of uniform on the GPU.
  75170. *
  75171. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75172. *
  75173. * For more information, please refer to :
  75174. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75175. * @param engine Define the engine the buffer is associated with
  75176. * @param data Define the data contained in the buffer
  75177. * @param dynamic Define if the buffer is updatable
  75178. */
  75179. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75180. /**
  75181. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75182. * or just falling back on setUniformXXX calls.
  75183. */
  75184. readonly useUbo: boolean;
  75185. /**
  75186. * Indicates if the WebGL underlying uniform buffer is in sync
  75187. * with the javascript cache data.
  75188. */
  75189. readonly isSync: boolean;
  75190. /**
  75191. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75192. * Also, a dynamic UniformBuffer will disable cache verification and always
  75193. * update the underlying WebGL uniform buffer to the GPU.
  75194. * @returns if Dynamic, otherwise false
  75195. */
  75196. isDynamic(): boolean;
  75197. /**
  75198. * The data cache on JS side.
  75199. * @returns the underlying data as a float array
  75200. */
  75201. getData(): Float32Array;
  75202. /**
  75203. * The underlying WebGL Uniform buffer.
  75204. * @returns the webgl buffer
  75205. */
  75206. getBuffer(): Nullable<DataBuffer>;
  75207. /**
  75208. * std140 layout specifies how to align data within an UBO structure.
  75209. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75210. * for specs.
  75211. */
  75212. private _fillAlignment;
  75213. /**
  75214. * Adds an uniform in the buffer.
  75215. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75216. * for the layout to be correct !
  75217. * @param name Name of the uniform, as used in the uniform block in the shader.
  75218. * @param size Data size, or data directly.
  75219. */
  75220. addUniform(name: string, size: number | number[]): void;
  75221. /**
  75222. * Adds a Matrix 4x4 to the uniform buffer.
  75223. * @param name Name of the uniform, as used in the uniform block in the shader.
  75224. * @param mat A 4x4 matrix.
  75225. */
  75226. addMatrix(name: string, mat: Matrix): void;
  75227. /**
  75228. * Adds a vec2 to the uniform buffer.
  75229. * @param name Name of the uniform, as used in the uniform block in the shader.
  75230. * @param x Define the x component value of the vec2
  75231. * @param y Define the y component value of the vec2
  75232. */
  75233. addFloat2(name: string, x: number, y: number): void;
  75234. /**
  75235. * Adds a vec3 to the uniform buffer.
  75236. * @param name Name of the uniform, as used in the uniform block in the shader.
  75237. * @param x Define the x component value of the vec3
  75238. * @param y Define the y component value of the vec3
  75239. * @param z Define the z component value of the vec3
  75240. */
  75241. addFloat3(name: string, x: number, y: number, z: number): void;
  75242. /**
  75243. * Adds a vec3 to the uniform buffer.
  75244. * @param name Name of the uniform, as used in the uniform block in the shader.
  75245. * @param color Define the vec3 from a Color
  75246. */
  75247. addColor3(name: string, color: Color3): void;
  75248. /**
  75249. * Adds a vec4 to the uniform buffer.
  75250. * @param name Name of the uniform, as used in the uniform block in the shader.
  75251. * @param color Define the rgb components from a Color
  75252. * @param alpha Define the a component of the vec4
  75253. */
  75254. addColor4(name: string, color: Color3, alpha: number): void;
  75255. /**
  75256. * Adds a vec3 to the uniform buffer.
  75257. * @param name Name of the uniform, as used in the uniform block in the shader.
  75258. * @param vector Define the vec3 components from a Vector
  75259. */
  75260. addVector3(name: string, vector: Vector3): void;
  75261. /**
  75262. * Adds a Matrix 3x3 to the uniform buffer.
  75263. * @param name Name of the uniform, as used in the uniform block in the shader.
  75264. */
  75265. addMatrix3x3(name: string): void;
  75266. /**
  75267. * Adds a Matrix 2x2 to the uniform buffer.
  75268. * @param name Name of the uniform, as used in the uniform block in the shader.
  75269. */
  75270. addMatrix2x2(name: string): void;
  75271. /**
  75272. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75273. */
  75274. create(): void;
  75275. /** @hidden */
  75276. _rebuild(): void;
  75277. /**
  75278. * Updates the WebGL Uniform Buffer on the GPU.
  75279. * If the `dynamic` flag is set to true, no cache comparison is done.
  75280. * Otherwise, the buffer will be updated only if the cache differs.
  75281. */
  75282. update(): void;
  75283. /**
  75284. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75285. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75286. * @param data Define the flattened data
  75287. * @param size Define the size of the data.
  75288. */
  75289. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75290. private _valueCache;
  75291. private _cacheMatrix;
  75292. private _updateMatrix3x3ForUniform;
  75293. private _updateMatrix3x3ForEffect;
  75294. private _updateMatrix2x2ForEffect;
  75295. private _updateMatrix2x2ForUniform;
  75296. private _updateFloatForEffect;
  75297. private _updateFloatForUniform;
  75298. private _updateFloat2ForEffect;
  75299. private _updateFloat2ForUniform;
  75300. private _updateFloat3ForEffect;
  75301. private _updateFloat3ForUniform;
  75302. private _updateFloat4ForEffect;
  75303. private _updateFloat4ForUniform;
  75304. private _updateMatrixForEffect;
  75305. private _updateMatrixForUniform;
  75306. private _updateVector3ForEffect;
  75307. private _updateVector3ForUniform;
  75308. private _updateVector4ForEffect;
  75309. private _updateVector4ForUniform;
  75310. private _updateColor3ForEffect;
  75311. private _updateColor3ForUniform;
  75312. private _updateColor4ForEffect;
  75313. private _updateColor4ForUniform;
  75314. /**
  75315. * Sets a sampler uniform on the effect.
  75316. * @param name Define the name of the sampler.
  75317. * @param texture Define the texture to set in the sampler
  75318. */
  75319. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75320. /**
  75321. * Directly updates the value of the uniform in the cache AND on the GPU.
  75322. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75323. * @param data Define the flattened data
  75324. */
  75325. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75326. /**
  75327. * Binds this uniform buffer to an effect.
  75328. * @param effect Define the effect to bind the buffer to
  75329. * @param name Name of the uniform block in the shader.
  75330. */
  75331. bindToEffect(effect: Effect, name: string): void;
  75332. /**
  75333. * Disposes the uniform buffer.
  75334. */
  75335. dispose(): void;
  75336. }
  75337. }
  75338. declare module BABYLON {
  75339. /**
  75340. * Enum that determines the text-wrapping mode to use.
  75341. */
  75342. export enum InspectableType {
  75343. /**
  75344. * Checkbox for booleans
  75345. */
  75346. Checkbox = 0,
  75347. /**
  75348. * Sliders for numbers
  75349. */
  75350. Slider = 1,
  75351. /**
  75352. * Vector3
  75353. */
  75354. Vector3 = 2,
  75355. /**
  75356. * Quaternions
  75357. */
  75358. Quaternion = 3,
  75359. /**
  75360. * Color3
  75361. */
  75362. Color3 = 4,
  75363. /**
  75364. * String
  75365. */
  75366. String = 5
  75367. }
  75368. /**
  75369. * Interface used to define custom inspectable properties.
  75370. * This interface is used by the inspector to display custom property grids
  75371. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75372. */
  75373. export interface IInspectable {
  75374. /**
  75375. * Gets the label to display
  75376. */
  75377. label: string;
  75378. /**
  75379. * Gets the name of the property to edit
  75380. */
  75381. propertyName: string;
  75382. /**
  75383. * Gets the type of the editor to use
  75384. */
  75385. type: InspectableType;
  75386. /**
  75387. * Gets the minimum value of the property when using in "slider" mode
  75388. */
  75389. min?: number;
  75390. /**
  75391. * Gets the maximum value of the property when using in "slider" mode
  75392. */
  75393. max?: number;
  75394. /**
  75395. * Gets the setp to use when using in "slider" mode
  75396. */
  75397. step?: number;
  75398. }
  75399. }
  75400. declare module BABYLON {
  75401. /**
  75402. * Class used to provide helper for timing
  75403. */
  75404. export class TimingTools {
  75405. /**
  75406. * Polyfill for setImmediate
  75407. * @param action defines the action to execute after the current execution block
  75408. */
  75409. static SetImmediate(action: () => void): void;
  75410. }
  75411. }
  75412. declare module BABYLON {
  75413. /**
  75414. * Class used to enable instatition of objects by class name
  75415. */
  75416. export class InstantiationTools {
  75417. /**
  75418. * Use this object to register external classes like custom textures or material
  75419. * to allow the laoders to instantiate them
  75420. */
  75421. static RegisteredExternalClasses: {
  75422. [key: string]: Object;
  75423. };
  75424. /**
  75425. * Tries to instantiate a new object from a given class name
  75426. * @param className defines the class name to instantiate
  75427. * @returns the new object or null if the system was not able to do the instantiation
  75428. */
  75429. static Instantiate(className: string): any;
  75430. }
  75431. }
  75432. declare module BABYLON {
  75433. /**
  75434. * Define options used to create a depth texture
  75435. */
  75436. export class DepthTextureCreationOptions {
  75437. /** Specifies whether or not a stencil should be allocated in the texture */
  75438. generateStencil?: boolean;
  75439. /** Specifies whether or not bilinear filtering is enable on the texture */
  75440. bilinearFiltering?: boolean;
  75441. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75442. comparisonFunction?: number;
  75443. /** Specifies if the created texture is a cube texture */
  75444. isCube?: boolean;
  75445. }
  75446. }
  75447. declare module BABYLON {
  75448. interface ThinEngine {
  75449. /**
  75450. * Creates a depth stencil cube texture.
  75451. * This is only available in WebGL 2.
  75452. * @param size The size of face edge in the cube texture.
  75453. * @param options The options defining the cube texture.
  75454. * @returns The cube texture
  75455. */
  75456. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75457. /**
  75458. * Creates a cube texture
  75459. * @param rootUrl defines the url where the files to load is located
  75460. * @param scene defines the current scene
  75461. * @param files defines the list of files to load (1 per face)
  75462. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75463. * @param onLoad defines an optional callback raised when the texture is loaded
  75464. * @param onError defines an optional callback raised if there is an issue to load the texture
  75465. * @param format defines the format of the data
  75466. * @param forcedExtension defines the extension to use to pick the right loader
  75467. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75470. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75471. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75472. * @returns the cube texture as an InternalTexture
  75473. */
  75474. 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;
  75475. /**
  75476. * Creates a cube texture
  75477. * @param rootUrl defines the url where the files to load is located
  75478. * @param scene defines the current scene
  75479. * @param files defines the list of files to load (1 per face)
  75480. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75481. * @param onLoad defines an optional callback raised when the texture is loaded
  75482. * @param onError defines an optional callback raised if there is an issue to load the texture
  75483. * @param format defines the format of the data
  75484. * @param forcedExtension defines the extension to use to pick the right loader
  75485. * @returns the cube texture as an InternalTexture
  75486. */
  75487. 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;
  75488. /**
  75489. * Creates a cube texture
  75490. * @param rootUrl defines the url where the files to load is located
  75491. * @param scene defines the current scene
  75492. * @param files defines the list of files to load (1 per face)
  75493. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75494. * @param onLoad defines an optional callback raised when the texture is loaded
  75495. * @param onError defines an optional callback raised if there is an issue to load the texture
  75496. * @param format defines the format of the data
  75497. * @param forcedExtension defines the extension to use to pick the right loader
  75498. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75499. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75500. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75501. * @returns the cube texture as an InternalTexture
  75502. */
  75503. 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;
  75504. /** @hidden */
  75505. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75506. /** @hidden */
  75507. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75508. /** @hidden */
  75509. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75510. /** @hidden */
  75511. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75512. /**
  75513. * @hidden
  75514. */
  75515. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75516. }
  75517. }
  75518. declare module BABYLON {
  75519. /**
  75520. * Class for creating a cube texture
  75521. */
  75522. export class CubeTexture extends BaseTexture {
  75523. private _delayedOnLoad;
  75524. /**
  75525. * The url of the texture
  75526. */
  75527. url: string;
  75528. /**
  75529. * Gets or sets the center of the bounding box associated with the cube texture.
  75530. * It must define where the camera used to render the texture was set
  75531. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75532. */
  75533. boundingBoxPosition: Vector3;
  75534. private _boundingBoxSize;
  75535. /**
  75536. * Gets or sets the size of the bounding box associated with the cube texture
  75537. * When defined, the cubemap will switch to local mode
  75538. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75539. * @example https://www.babylonjs-playground.com/#RNASML
  75540. */
  75541. /**
  75542. * Returns the bounding box size
  75543. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75544. */
  75545. boundingBoxSize: Vector3;
  75546. protected _rotationY: number;
  75547. /**
  75548. * Sets texture matrix rotation angle around Y axis in radians.
  75549. */
  75550. /**
  75551. * Gets texture matrix rotation angle around Y axis radians.
  75552. */
  75553. rotationY: number;
  75554. /**
  75555. * Are mip maps generated for this texture or not.
  75556. */
  75557. readonly noMipmap: boolean;
  75558. private _noMipmap;
  75559. private _files;
  75560. protected _forcedExtension: Nullable<string>;
  75561. private _extensions;
  75562. private _textureMatrix;
  75563. private _format;
  75564. private _createPolynomials;
  75565. /** @hidden */
  75566. _prefiltered: boolean;
  75567. /**
  75568. * Creates a cube texture from an array of image urls
  75569. * @param files defines an array of image urls
  75570. * @param scene defines the hosting scene
  75571. * @param noMipmap specifies if mip maps are not used
  75572. * @returns a cube texture
  75573. */
  75574. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75575. /**
  75576. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75577. * @param url defines the url of the prefiltered texture
  75578. * @param scene defines the scene the texture is attached to
  75579. * @param forcedExtension defines the extension of the file if different from the url
  75580. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75581. * @return the prefiltered texture
  75582. */
  75583. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75584. /**
  75585. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75586. * as prefiltered data.
  75587. * @param rootUrl defines the url of the texture or the root name of the six images
  75588. * @param scene defines the scene the texture is attached to
  75589. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75590. * @param noMipmap defines if mipmaps should be created or not
  75591. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75592. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75593. * @param onError defines a callback triggered in case of error during load
  75594. * @param format defines the internal format to use for the texture once loaded
  75595. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75596. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75597. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75598. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75599. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75600. * @return the cube texture
  75601. */
  75602. 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);
  75603. /**
  75604. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75605. */
  75606. readonly isPrefiltered: boolean;
  75607. /**
  75608. * Get the current class name of the texture useful for serialization or dynamic coding.
  75609. * @returns "CubeTexture"
  75610. */
  75611. getClassName(): string;
  75612. /**
  75613. * Update the url (and optional buffer) of this texture if url was null during construction.
  75614. * @param url the url of the texture
  75615. * @param forcedExtension defines the extension to use
  75616. * @param onLoad callback called when the texture is loaded (defaults to null)
  75617. */
  75618. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75619. /**
  75620. * Delays loading of the cube texture
  75621. * @param forcedExtension defines the extension to use
  75622. */
  75623. delayLoad(forcedExtension?: string): void;
  75624. /**
  75625. * Returns the reflection texture matrix
  75626. * @returns the reflection texture matrix
  75627. */
  75628. getReflectionTextureMatrix(): Matrix;
  75629. /**
  75630. * Sets the reflection texture matrix
  75631. * @param value Reflection texture matrix
  75632. */
  75633. setReflectionTextureMatrix(value: Matrix): void;
  75634. /**
  75635. * Parses text to create a cube texture
  75636. * @param parsedTexture define the serialized text to read from
  75637. * @param scene defines the hosting scene
  75638. * @param rootUrl defines the root url of the cube texture
  75639. * @returns a cube texture
  75640. */
  75641. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75642. /**
  75643. * Makes a clone, or deep copy, of the cube texture
  75644. * @returns a new cube texture
  75645. */
  75646. clone(): CubeTexture;
  75647. }
  75648. }
  75649. declare module BABYLON {
  75650. /**
  75651. * Manages the defines for the Material
  75652. */
  75653. export class MaterialDefines {
  75654. /** @hidden */
  75655. protected _keys: string[];
  75656. private _isDirty;
  75657. /** @hidden */
  75658. _renderId: number;
  75659. /** @hidden */
  75660. _areLightsDirty: boolean;
  75661. /** @hidden */
  75662. _areLightsDisposed: boolean;
  75663. /** @hidden */
  75664. _areAttributesDirty: boolean;
  75665. /** @hidden */
  75666. _areTexturesDirty: boolean;
  75667. /** @hidden */
  75668. _areFresnelDirty: boolean;
  75669. /** @hidden */
  75670. _areMiscDirty: boolean;
  75671. /** @hidden */
  75672. _areImageProcessingDirty: boolean;
  75673. /** @hidden */
  75674. _normals: boolean;
  75675. /** @hidden */
  75676. _uvs: boolean;
  75677. /** @hidden */
  75678. _needNormals: boolean;
  75679. /** @hidden */
  75680. _needUVs: boolean;
  75681. [id: string]: any;
  75682. /**
  75683. * Specifies if the material needs to be re-calculated
  75684. */
  75685. readonly isDirty: boolean;
  75686. /**
  75687. * Marks the material to indicate that it has been re-calculated
  75688. */
  75689. markAsProcessed(): void;
  75690. /**
  75691. * Marks the material to indicate that it needs to be re-calculated
  75692. */
  75693. markAsUnprocessed(): void;
  75694. /**
  75695. * Marks the material to indicate all of its defines need to be re-calculated
  75696. */
  75697. markAllAsDirty(): void;
  75698. /**
  75699. * Marks the material to indicate that image processing needs to be re-calculated
  75700. */
  75701. markAsImageProcessingDirty(): void;
  75702. /**
  75703. * Marks the material to indicate the lights need to be re-calculated
  75704. * @param disposed Defines whether the light is dirty due to dispose or not
  75705. */
  75706. markAsLightDirty(disposed?: boolean): void;
  75707. /**
  75708. * Marks the attribute state as changed
  75709. */
  75710. markAsAttributesDirty(): void;
  75711. /**
  75712. * Marks the texture state as changed
  75713. */
  75714. markAsTexturesDirty(): void;
  75715. /**
  75716. * Marks the fresnel state as changed
  75717. */
  75718. markAsFresnelDirty(): void;
  75719. /**
  75720. * Marks the misc state as changed
  75721. */
  75722. markAsMiscDirty(): void;
  75723. /**
  75724. * Rebuilds the material defines
  75725. */
  75726. rebuild(): void;
  75727. /**
  75728. * Specifies if two material defines are equal
  75729. * @param other - A material define instance to compare to
  75730. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75731. */
  75732. isEqual(other: MaterialDefines): boolean;
  75733. /**
  75734. * Clones this instance's defines to another instance
  75735. * @param other - material defines to clone values to
  75736. */
  75737. cloneTo(other: MaterialDefines): void;
  75738. /**
  75739. * Resets the material define values
  75740. */
  75741. reset(): void;
  75742. /**
  75743. * Converts the material define values to a string
  75744. * @returns - String of material define information
  75745. */
  75746. toString(): string;
  75747. }
  75748. }
  75749. declare module BABYLON {
  75750. /**
  75751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75753. * 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;
  75754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75755. */
  75756. export class ColorCurves {
  75757. private _dirty;
  75758. private _tempColor;
  75759. private _globalCurve;
  75760. private _highlightsCurve;
  75761. private _midtonesCurve;
  75762. private _shadowsCurve;
  75763. private _positiveCurve;
  75764. private _negativeCurve;
  75765. private _globalHue;
  75766. private _globalDensity;
  75767. private _globalSaturation;
  75768. private _globalExposure;
  75769. /**
  75770. * Gets the global Hue value.
  75771. * 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).
  75772. */
  75773. /**
  75774. * Sets the global Hue value.
  75775. * 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).
  75776. */
  75777. globalHue: number;
  75778. /**
  75779. * Gets the global Density value.
  75780. * 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.
  75781. * Values less than zero provide a filter of opposite hue.
  75782. */
  75783. /**
  75784. * Sets the global Density value.
  75785. * 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.
  75786. * Values less than zero provide a filter of opposite hue.
  75787. */
  75788. globalDensity: number;
  75789. /**
  75790. * Gets the global Saturation value.
  75791. * 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.
  75792. */
  75793. /**
  75794. * Sets the global Saturation value.
  75795. * 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.
  75796. */
  75797. globalSaturation: number;
  75798. /**
  75799. * Gets the global Exposure value.
  75800. * 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.
  75801. */
  75802. /**
  75803. * Sets the global Exposure value.
  75804. * 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.
  75805. */
  75806. globalExposure: number;
  75807. private _highlightsHue;
  75808. private _highlightsDensity;
  75809. private _highlightsSaturation;
  75810. private _highlightsExposure;
  75811. /**
  75812. * Gets the highlights Hue value.
  75813. * 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).
  75814. */
  75815. /**
  75816. * Sets the highlights Hue value.
  75817. * 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).
  75818. */
  75819. highlightsHue: number;
  75820. /**
  75821. * Gets the highlights Density value.
  75822. * 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.
  75823. * Values less than zero provide a filter of opposite hue.
  75824. */
  75825. /**
  75826. * Sets the highlights Density value.
  75827. * 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.
  75828. * Values less than zero provide a filter of opposite hue.
  75829. */
  75830. highlightsDensity: number;
  75831. /**
  75832. * Gets the highlights Saturation value.
  75833. * 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.
  75834. */
  75835. /**
  75836. * Sets the highlights Saturation value.
  75837. * 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.
  75838. */
  75839. highlightsSaturation: number;
  75840. /**
  75841. * Gets the highlights Exposure value.
  75842. * 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.
  75843. */
  75844. /**
  75845. * Sets the highlights Exposure value.
  75846. * 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.
  75847. */
  75848. highlightsExposure: number;
  75849. private _midtonesHue;
  75850. private _midtonesDensity;
  75851. private _midtonesSaturation;
  75852. private _midtonesExposure;
  75853. /**
  75854. * Gets the midtones Hue value.
  75855. * 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).
  75856. */
  75857. /**
  75858. * Sets the midtones Hue value.
  75859. * 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).
  75860. */
  75861. midtonesHue: number;
  75862. /**
  75863. * Gets the midtones Density value.
  75864. * 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.
  75865. * Values less than zero provide a filter of opposite hue.
  75866. */
  75867. /**
  75868. * Sets the midtones Density value.
  75869. * 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.
  75870. * Values less than zero provide a filter of opposite hue.
  75871. */
  75872. midtonesDensity: number;
  75873. /**
  75874. * Gets the midtones Saturation value.
  75875. * 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.
  75876. */
  75877. /**
  75878. * Sets the midtones Saturation value.
  75879. * 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.
  75880. */
  75881. midtonesSaturation: number;
  75882. /**
  75883. * Gets the midtones Exposure value.
  75884. * 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.
  75885. */
  75886. /**
  75887. * Sets the midtones Exposure value.
  75888. * 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.
  75889. */
  75890. midtonesExposure: number;
  75891. private _shadowsHue;
  75892. private _shadowsDensity;
  75893. private _shadowsSaturation;
  75894. private _shadowsExposure;
  75895. /**
  75896. * Gets the shadows Hue value.
  75897. * 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).
  75898. */
  75899. /**
  75900. * Sets the shadows Hue value.
  75901. * 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).
  75902. */
  75903. shadowsHue: number;
  75904. /**
  75905. * Gets the shadows Density value.
  75906. * 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.
  75907. * Values less than zero provide a filter of opposite hue.
  75908. */
  75909. /**
  75910. * Sets the shadows Density value.
  75911. * 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.
  75912. * Values less than zero provide a filter of opposite hue.
  75913. */
  75914. shadowsDensity: number;
  75915. /**
  75916. * Gets the shadows Saturation value.
  75917. * 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.
  75918. */
  75919. /**
  75920. * Sets the shadows Saturation value.
  75921. * 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.
  75922. */
  75923. shadowsSaturation: number;
  75924. /**
  75925. * Gets the shadows Exposure value.
  75926. * 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.
  75927. */
  75928. /**
  75929. * Sets the shadows Exposure value.
  75930. * 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.
  75931. */
  75932. shadowsExposure: number;
  75933. /**
  75934. * Returns the class name
  75935. * @returns The class name
  75936. */
  75937. getClassName(): string;
  75938. /**
  75939. * Binds the color curves to the shader.
  75940. * @param colorCurves The color curve to bind
  75941. * @param effect The effect to bind to
  75942. * @param positiveUniform The positive uniform shader parameter
  75943. * @param neutralUniform The neutral uniform shader parameter
  75944. * @param negativeUniform The negative uniform shader parameter
  75945. */
  75946. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75947. /**
  75948. * Prepare the list of uniforms associated with the ColorCurves effects.
  75949. * @param uniformsList The list of uniforms used in the effect
  75950. */
  75951. static PrepareUniforms(uniformsList: string[]): void;
  75952. /**
  75953. * Returns color grading data based on a hue, density, saturation and exposure value.
  75954. * @param filterHue The hue of the color filter.
  75955. * @param filterDensity The density of the color filter.
  75956. * @param saturation The saturation.
  75957. * @param exposure The exposure.
  75958. * @param result The result data container.
  75959. */
  75960. private getColorGradingDataToRef;
  75961. /**
  75962. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75963. * @param value The input slider value in range [-100,100].
  75964. * @returns Adjusted value.
  75965. */
  75966. private static applyColorGradingSliderNonlinear;
  75967. /**
  75968. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75969. * @param hue The hue (H) input.
  75970. * @param saturation The saturation (S) input.
  75971. * @param brightness The brightness (B) input.
  75972. * @result An RGBA color represented as Vector4.
  75973. */
  75974. private static fromHSBToRef;
  75975. /**
  75976. * Returns a value clamped between min and max
  75977. * @param value The value to clamp
  75978. * @param min The minimum of value
  75979. * @param max The maximum of value
  75980. * @returns The clamped value.
  75981. */
  75982. private static clamp;
  75983. /**
  75984. * Clones the current color curve instance.
  75985. * @return The cloned curves
  75986. */
  75987. clone(): ColorCurves;
  75988. /**
  75989. * Serializes the current color curve instance to a json representation.
  75990. * @return a JSON representation
  75991. */
  75992. serialize(): any;
  75993. /**
  75994. * Parses the color curve from a json representation.
  75995. * @param source the JSON source to parse
  75996. * @return The parsed curves
  75997. */
  75998. static Parse(source: any): ColorCurves;
  75999. }
  76000. }
  76001. declare module BABYLON {
  76002. /**
  76003. * Interface to follow in your material defines to integrate easily the
  76004. * Image proccessing functions.
  76005. * @hidden
  76006. */
  76007. export interface IImageProcessingConfigurationDefines {
  76008. IMAGEPROCESSING: boolean;
  76009. VIGNETTE: boolean;
  76010. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76011. VIGNETTEBLENDMODEOPAQUE: boolean;
  76012. TONEMAPPING: boolean;
  76013. TONEMAPPING_ACES: boolean;
  76014. CONTRAST: boolean;
  76015. EXPOSURE: boolean;
  76016. COLORCURVES: boolean;
  76017. COLORGRADING: boolean;
  76018. COLORGRADING3D: boolean;
  76019. SAMPLER3DGREENDEPTH: boolean;
  76020. SAMPLER3DBGRMAP: boolean;
  76021. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76022. }
  76023. /**
  76024. * @hidden
  76025. */
  76026. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76027. IMAGEPROCESSING: boolean;
  76028. VIGNETTE: boolean;
  76029. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76030. VIGNETTEBLENDMODEOPAQUE: boolean;
  76031. TONEMAPPING: boolean;
  76032. TONEMAPPING_ACES: boolean;
  76033. CONTRAST: boolean;
  76034. COLORCURVES: boolean;
  76035. COLORGRADING: boolean;
  76036. COLORGRADING3D: boolean;
  76037. SAMPLER3DGREENDEPTH: boolean;
  76038. SAMPLER3DBGRMAP: boolean;
  76039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76040. EXPOSURE: boolean;
  76041. constructor();
  76042. }
  76043. /**
  76044. * This groups together the common properties used for image processing either in direct forward pass
  76045. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76046. * or not.
  76047. */
  76048. export class ImageProcessingConfiguration {
  76049. /**
  76050. * Default tone mapping applied in BabylonJS.
  76051. */
  76052. static readonly TONEMAPPING_STANDARD: number;
  76053. /**
  76054. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76055. * to other engines rendering to increase portability.
  76056. */
  76057. static readonly TONEMAPPING_ACES: number;
  76058. /**
  76059. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76060. */
  76061. colorCurves: Nullable<ColorCurves>;
  76062. private _colorCurvesEnabled;
  76063. /**
  76064. * Gets wether the color curves effect is enabled.
  76065. */
  76066. /**
  76067. * Sets wether the color curves effect is enabled.
  76068. */
  76069. colorCurvesEnabled: boolean;
  76070. private _colorGradingTexture;
  76071. /**
  76072. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76073. */
  76074. /**
  76075. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76076. */
  76077. colorGradingTexture: Nullable<BaseTexture>;
  76078. private _colorGradingEnabled;
  76079. /**
  76080. * Gets wether the color grading effect is enabled.
  76081. */
  76082. /**
  76083. * Sets wether the color grading effect is enabled.
  76084. */
  76085. colorGradingEnabled: boolean;
  76086. private _colorGradingWithGreenDepth;
  76087. /**
  76088. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76089. */
  76090. /**
  76091. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76092. */
  76093. colorGradingWithGreenDepth: boolean;
  76094. private _colorGradingBGR;
  76095. /**
  76096. * Gets wether the color grading texture contains BGR values.
  76097. */
  76098. /**
  76099. * Sets wether the color grading texture contains BGR values.
  76100. */
  76101. colorGradingBGR: boolean;
  76102. /** @hidden */
  76103. _exposure: number;
  76104. /**
  76105. * Gets the Exposure used in the effect.
  76106. */
  76107. /**
  76108. * Sets the Exposure used in the effect.
  76109. */
  76110. exposure: number;
  76111. private _toneMappingEnabled;
  76112. /**
  76113. * Gets wether the tone mapping effect is enabled.
  76114. */
  76115. /**
  76116. * Sets wether the tone mapping effect is enabled.
  76117. */
  76118. toneMappingEnabled: boolean;
  76119. private _toneMappingType;
  76120. /**
  76121. * Gets the type of tone mapping effect.
  76122. */
  76123. /**
  76124. * Sets the type of tone mapping effect used in BabylonJS.
  76125. */
  76126. toneMappingType: number;
  76127. protected _contrast: number;
  76128. /**
  76129. * Gets the contrast used in the effect.
  76130. */
  76131. /**
  76132. * Sets the contrast used in the effect.
  76133. */
  76134. contrast: number;
  76135. /**
  76136. * Vignette stretch size.
  76137. */
  76138. vignetteStretch: number;
  76139. /**
  76140. * Vignette centre X Offset.
  76141. */
  76142. vignetteCentreX: number;
  76143. /**
  76144. * Vignette centre Y Offset.
  76145. */
  76146. vignetteCentreY: number;
  76147. /**
  76148. * Vignette weight or intensity of the vignette effect.
  76149. */
  76150. vignetteWeight: number;
  76151. /**
  76152. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76153. * if vignetteEnabled is set to true.
  76154. */
  76155. vignetteColor: Color4;
  76156. /**
  76157. * Camera field of view used by the Vignette effect.
  76158. */
  76159. vignetteCameraFov: number;
  76160. private _vignetteBlendMode;
  76161. /**
  76162. * Gets the vignette blend mode allowing different kind of effect.
  76163. */
  76164. /**
  76165. * Sets the vignette blend mode allowing different kind of effect.
  76166. */
  76167. vignetteBlendMode: number;
  76168. private _vignetteEnabled;
  76169. /**
  76170. * Gets wether the vignette effect is enabled.
  76171. */
  76172. /**
  76173. * Sets wether the vignette effect is enabled.
  76174. */
  76175. vignetteEnabled: boolean;
  76176. private _applyByPostProcess;
  76177. /**
  76178. * Gets wether the image processing is applied through a post process or not.
  76179. */
  76180. /**
  76181. * Sets wether the image processing is applied through a post process or not.
  76182. */
  76183. applyByPostProcess: boolean;
  76184. private _isEnabled;
  76185. /**
  76186. * Gets wether the image processing is enabled or not.
  76187. */
  76188. /**
  76189. * Sets wether the image processing is enabled or not.
  76190. */
  76191. isEnabled: boolean;
  76192. /**
  76193. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76194. */
  76195. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76196. /**
  76197. * Method called each time the image processing information changes requires to recompile the effect.
  76198. */
  76199. protected _updateParameters(): void;
  76200. /**
  76201. * Gets the current class name.
  76202. * @return "ImageProcessingConfiguration"
  76203. */
  76204. getClassName(): string;
  76205. /**
  76206. * Prepare the list of uniforms associated with the Image Processing effects.
  76207. * @param uniforms The list of uniforms used in the effect
  76208. * @param defines the list of defines currently in use
  76209. */
  76210. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76211. /**
  76212. * Prepare the list of samplers associated with the Image Processing effects.
  76213. * @param samplersList The list of uniforms used in the effect
  76214. * @param defines the list of defines currently in use
  76215. */
  76216. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76217. /**
  76218. * Prepare the list of defines associated to the shader.
  76219. * @param defines the list of defines to complete
  76220. * @param forPostProcess Define if we are currently in post process mode or not
  76221. */
  76222. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76223. /**
  76224. * Returns true if all the image processing information are ready.
  76225. * @returns True if ready, otherwise, false
  76226. */
  76227. isReady(): boolean;
  76228. /**
  76229. * Binds the image processing to the shader.
  76230. * @param effect The effect to bind to
  76231. * @param overrideAspectRatio Override the aspect ratio of the effect
  76232. */
  76233. bind(effect: Effect, overrideAspectRatio?: number): void;
  76234. /**
  76235. * Clones the current image processing instance.
  76236. * @return The cloned image processing
  76237. */
  76238. clone(): ImageProcessingConfiguration;
  76239. /**
  76240. * Serializes the current image processing instance to a json representation.
  76241. * @return a JSON representation
  76242. */
  76243. serialize(): any;
  76244. /**
  76245. * Parses the image processing from a json representation.
  76246. * @param source the JSON source to parse
  76247. * @return The parsed image processing
  76248. */
  76249. static Parse(source: any): ImageProcessingConfiguration;
  76250. private static _VIGNETTEMODE_MULTIPLY;
  76251. private static _VIGNETTEMODE_OPAQUE;
  76252. /**
  76253. * Used to apply the vignette as a mix with the pixel color.
  76254. */
  76255. static readonly VIGNETTEMODE_MULTIPLY: number;
  76256. /**
  76257. * Used to apply the vignette as a replacement of the pixel color.
  76258. */
  76259. static readonly VIGNETTEMODE_OPAQUE: number;
  76260. }
  76261. }
  76262. declare module BABYLON {
  76263. /** @hidden */
  76264. export var postprocessVertexShader: {
  76265. name: string;
  76266. shader: string;
  76267. };
  76268. }
  76269. declare module BABYLON {
  76270. interface ThinEngine {
  76271. /**
  76272. * Creates a new render target texture
  76273. * @param size defines the size of the texture
  76274. * @param options defines the options used to create the texture
  76275. * @returns a new render target texture stored in an InternalTexture
  76276. */
  76277. createRenderTargetTexture(size: number | {
  76278. width: number;
  76279. height: number;
  76280. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76281. /**
  76282. * Creates a depth stencil texture.
  76283. * This is only available in WebGL 2 or with the depth texture extension available.
  76284. * @param size The size of face edge in the texture.
  76285. * @param options The options defining the texture.
  76286. * @returns The texture
  76287. */
  76288. createDepthStencilTexture(size: number | {
  76289. width: number;
  76290. height: number;
  76291. }, options: DepthTextureCreationOptions): InternalTexture;
  76292. /** @hidden */
  76293. _createDepthStencilTexture(size: number | {
  76294. width: number;
  76295. height: number;
  76296. }, options: DepthTextureCreationOptions): InternalTexture;
  76297. }
  76298. }
  76299. declare module BABYLON {
  76300. /** Defines supported spaces */
  76301. export enum Space {
  76302. /** Local (object) space */
  76303. LOCAL = 0,
  76304. /** World space */
  76305. WORLD = 1,
  76306. /** Bone space */
  76307. BONE = 2
  76308. }
  76309. /** Defines the 3 main axes */
  76310. export class Axis {
  76311. /** X axis */
  76312. static X: Vector3;
  76313. /** Y axis */
  76314. static Y: Vector3;
  76315. /** Z axis */
  76316. static Z: Vector3;
  76317. }
  76318. }
  76319. declare module BABYLON {
  76320. /**
  76321. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76322. * This is the base of the follow, arc rotate cameras and Free camera
  76323. * @see http://doc.babylonjs.com/features/cameras
  76324. */
  76325. export class TargetCamera extends Camera {
  76326. private static _RigCamTransformMatrix;
  76327. private static _TargetTransformMatrix;
  76328. private static _TargetFocalPoint;
  76329. /**
  76330. * Define the current direction the camera is moving to
  76331. */
  76332. cameraDirection: Vector3;
  76333. /**
  76334. * Define the current rotation the camera is rotating to
  76335. */
  76336. cameraRotation: Vector2;
  76337. /**
  76338. * When set, the up vector of the camera will be updated by the rotation of the camera
  76339. */
  76340. updateUpVectorFromRotation: boolean;
  76341. private _tmpQuaternion;
  76342. /**
  76343. * Define the current rotation of the camera
  76344. */
  76345. rotation: Vector3;
  76346. /**
  76347. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76348. */
  76349. rotationQuaternion: Quaternion;
  76350. /**
  76351. * Define the current speed of the camera
  76352. */
  76353. speed: number;
  76354. /**
  76355. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76356. * around all axis.
  76357. */
  76358. noRotationConstraint: boolean;
  76359. /**
  76360. * Define the current target of the camera as an object or a position.
  76361. */
  76362. lockedTarget: any;
  76363. /** @hidden */
  76364. _currentTarget: Vector3;
  76365. /** @hidden */
  76366. _initialFocalDistance: number;
  76367. /** @hidden */
  76368. _viewMatrix: Matrix;
  76369. /** @hidden */
  76370. _camMatrix: Matrix;
  76371. /** @hidden */
  76372. _cameraTransformMatrix: Matrix;
  76373. /** @hidden */
  76374. _cameraRotationMatrix: Matrix;
  76375. /** @hidden */
  76376. _referencePoint: Vector3;
  76377. /** @hidden */
  76378. _transformedReferencePoint: Vector3;
  76379. protected _globalCurrentTarget: Vector3;
  76380. protected _globalCurrentUpVector: Vector3;
  76381. /** @hidden */
  76382. _reset: () => void;
  76383. private _defaultUp;
  76384. /**
  76385. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76386. * This is the base of the follow, arc rotate cameras and Free camera
  76387. * @see http://doc.babylonjs.com/features/cameras
  76388. * @param name Defines the name of the camera in the scene
  76389. * @param position Defines the start position of the camera in the scene
  76390. * @param scene Defines the scene the camera belongs to
  76391. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76392. */
  76393. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76394. /**
  76395. * Gets the position in front of the camera at a given distance.
  76396. * @param distance The distance from the camera we want the position to be
  76397. * @returns the position
  76398. */
  76399. getFrontPosition(distance: number): Vector3;
  76400. /** @hidden */
  76401. _getLockedTargetPosition(): Nullable<Vector3>;
  76402. private _storedPosition;
  76403. private _storedRotation;
  76404. private _storedRotationQuaternion;
  76405. /**
  76406. * Store current camera state of the camera (fov, position, rotation, etc..)
  76407. * @returns the camera
  76408. */
  76409. storeState(): Camera;
  76410. /**
  76411. * Restored camera state. You must call storeState() first
  76412. * @returns whether it was successful or not
  76413. * @hidden
  76414. */
  76415. _restoreStateValues(): boolean;
  76416. /** @hidden */
  76417. _initCache(): void;
  76418. /** @hidden */
  76419. _updateCache(ignoreParentClass?: boolean): void;
  76420. /** @hidden */
  76421. _isSynchronizedViewMatrix(): boolean;
  76422. /** @hidden */
  76423. _computeLocalCameraSpeed(): number;
  76424. /**
  76425. * Defines the target the camera should look at.
  76426. * @param target Defines the new target as a Vector or a mesh
  76427. */
  76428. setTarget(target: Vector3): void;
  76429. /**
  76430. * Return the current target position of the camera. This value is expressed in local space.
  76431. * @returns the target position
  76432. */
  76433. getTarget(): Vector3;
  76434. /** @hidden */
  76435. _decideIfNeedsToMove(): boolean;
  76436. /** @hidden */
  76437. _updatePosition(): void;
  76438. /** @hidden */
  76439. _checkInputs(): void;
  76440. protected _updateCameraRotationMatrix(): void;
  76441. /**
  76442. * 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)
  76443. * @returns the current camera
  76444. */
  76445. private _rotateUpVectorWithCameraRotationMatrix;
  76446. private _cachedRotationZ;
  76447. private _cachedQuaternionRotationZ;
  76448. /** @hidden */
  76449. _getViewMatrix(): Matrix;
  76450. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76451. /**
  76452. * @hidden
  76453. */
  76454. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76455. /**
  76456. * @hidden
  76457. */
  76458. _updateRigCameras(): void;
  76459. private _getRigCamPositionAndTarget;
  76460. /**
  76461. * Gets the current object class name.
  76462. * @return the class name
  76463. */
  76464. getClassName(): string;
  76465. }
  76466. }
  76467. declare module BABYLON {
  76468. /**
  76469. * Gather the list of keyboard event types as constants.
  76470. */
  76471. export class KeyboardEventTypes {
  76472. /**
  76473. * The keydown event is fired when a key becomes active (pressed).
  76474. */
  76475. static readonly KEYDOWN: number;
  76476. /**
  76477. * The keyup event is fired when a key has been released.
  76478. */
  76479. static readonly KEYUP: number;
  76480. }
  76481. /**
  76482. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76483. */
  76484. export class KeyboardInfo {
  76485. /**
  76486. * Defines the type of event (KeyboardEventTypes)
  76487. */
  76488. type: number;
  76489. /**
  76490. * Defines the related dom event
  76491. */
  76492. event: KeyboardEvent;
  76493. /**
  76494. * Instantiates a new keyboard info.
  76495. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76496. * @param type Defines the type of event (KeyboardEventTypes)
  76497. * @param event Defines the related dom event
  76498. */
  76499. constructor(
  76500. /**
  76501. * Defines the type of event (KeyboardEventTypes)
  76502. */
  76503. type: number,
  76504. /**
  76505. * Defines the related dom event
  76506. */
  76507. event: KeyboardEvent);
  76508. }
  76509. /**
  76510. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76511. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76512. */
  76513. export class KeyboardInfoPre extends KeyboardInfo {
  76514. /**
  76515. * Defines the type of event (KeyboardEventTypes)
  76516. */
  76517. type: number;
  76518. /**
  76519. * Defines the related dom event
  76520. */
  76521. event: KeyboardEvent;
  76522. /**
  76523. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76524. */
  76525. skipOnPointerObservable: boolean;
  76526. /**
  76527. * Instantiates a new keyboard pre info.
  76528. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76529. * @param type Defines the type of event (KeyboardEventTypes)
  76530. * @param event Defines the related dom event
  76531. */
  76532. constructor(
  76533. /**
  76534. * Defines the type of event (KeyboardEventTypes)
  76535. */
  76536. type: number,
  76537. /**
  76538. * Defines the related dom event
  76539. */
  76540. event: KeyboardEvent);
  76541. }
  76542. }
  76543. declare module BABYLON {
  76544. /**
  76545. * Manage the keyboard inputs to control the movement of a free camera.
  76546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76547. */
  76548. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76549. /**
  76550. * Defines the camera the input is attached to.
  76551. */
  76552. camera: FreeCamera;
  76553. /**
  76554. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76555. */
  76556. keysUp: number[];
  76557. /**
  76558. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76559. */
  76560. keysDown: number[];
  76561. /**
  76562. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76563. */
  76564. keysLeft: number[];
  76565. /**
  76566. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76567. */
  76568. keysRight: number[];
  76569. private _keys;
  76570. private _onCanvasBlurObserver;
  76571. private _onKeyboardObserver;
  76572. private _engine;
  76573. private _scene;
  76574. /**
  76575. * Attach the input controls to a specific dom element to get the input from.
  76576. * @param element Defines the element the controls should be listened from
  76577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76578. */
  76579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76580. /**
  76581. * Detach the current controls from the specified dom element.
  76582. * @param element Defines the element to stop listening the inputs from
  76583. */
  76584. detachControl(element: Nullable<HTMLElement>): void;
  76585. /**
  76586. * Update the current camera state depending on the inputs that have been used this frame.
  76587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76588. */
  76589. checkInputs(): void;
  76590. /**
  76591. * Gets the class name of the current intput.
  76592. * @returns the class name
  76593. */
  76594. getClassName(): string;
  76595. /** @hidden */
  76596. _onLostFocus(): void;
  76597. /**
  76598. * Get the friendly name associated with the input class.
  76599. * @returns the input friendly name
  76600. */
  76601. getSimpleName(): string;
  76602. }
  76603. }
  76604. declare module BABYLON {
  76605. /**
  76606. * Interface describing all the common properties and methods a shadow light needs to implement.
  76607. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76608. * as well as binding the different shadow properties to the effects.
  76609. */
  76610. export interface IShadowLight extends Light {
  76611. /**
  76612. * The light id in the scene (used in scene.findLighById for instance)
  76613. */
  76614. id: string;
  76615. /**
  76616. * The position the shdow will be casted from.
  76617. */
  76618. position: Vector3;
  76619. /**
  76620. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76621. */
  76622. direction: Vector3;
  76623. /**
  76624. * The transformed position. Position of the light in world space taking parenting in account.
  76625. */
  76626. transformedPosition: Vector3;
  76627. /**
  76628. * The transformed direction. Direction of the light in world space taking parenting in account.
  76629. */
  76630. transformedDirection: Vector3;
  76631. /**
  76632. * The friendly name of the light in the scene.
  76633. */
  76634. name: string;
  76635. /**
  76636. * Defines the shadow projection clipping minimum z value.
  76637. */
  76638. shadowMinZ: number;
  76639. /**
  76640. * Defines the shadow projection clipping maximum z value.
  76641. */
  76642. shadowMaxZ: number;
  76643. /**
  76644. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76645. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76646. */
  76647. computeTransformedInformation(): boolean;
  76648. /**
  76649. * Gets the scene the light belongs to.
  76650. * @returns The scene
  76651. */
  76652. getScene(): Scene;
  76653. /**
  76654. * Callback defining a custom Projection Matrix Builder.
  76655. * This can be used to override the default projection matrix computation.
  76656. */
  76657. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76658. /**
  76659. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76660. * @param matrix The materix to updated with the projection information
  76661. * @param viewMatrix The transform matrix of the light
  76662. * @param renderList The list of mesh to render in the map
  76663. * @returns The current light
  76664. */
  76665. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76666. /**
  76667. * Gets the current depth scale used in ESM.
  76668. * @returns The scale
  76669. */
  76670. getDepthScale(): number;
  76671. /**
  76672. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76673. * @returns true if a cube texture needs to be use
  76674. */
  76675. needCube(): boolean;
  76676. /**
  76677. * Detects if the projection matrix requires to be recomputed this frame.
  76678. * @returns true if it requires to be recomputed otherwise, false.
  76679. */
  76680. needProjectionMatrixCompute(): boolean;
  76681. /**
  76682. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76683. */
  76684. forceProjectionMatrixCompute(): void;
  76685. /**
  76686. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76687. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76688. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76689. */
  76690. getShadowDirection(faceIndex?: number): Vector3;
  76691. /**
  76692. * Gets the minZ used for shadow according to both the scene and the light.
  76693. * @param activeCamera The camera we are returning the min for
  76694. * @returns the depth min z
  76695. */
  76696. getDepthMinZ(activeCamera: Camera): number;
  76697. /**
  76698. * Gets the maxZ used for shadow according to both the scene and the light.
  76699. * @param activeCamera The camera we are returning the max for
  76700. * @returns the depth max z
  76701. */
  76702. getDepthMaxZ(activeCamera: Camera): number;
  76703. }
  76704. /**
  76705. * Base implementation IShadowLight
  76706. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76707. */
  76708. export abstract class ShadowLight extends Light implements IShadowLight {
  76709. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76710. protected _position: Vector3;
  76711. protected _setPosition(value: Vector3): void;
  76712. /**
  76713. * Sets the position the shadow will be casted from. Also use as the light position for both
  76714. * point and spot lights.
  76715. */
  76716. /**
  76717. * Sets the position the shadow will be casted from. Also use as the light position for both
  76718. * point and spot lights.
  76719. */
  76720. position: Vector3;
  76721. protected _direction: Vector3;
  76722. protected _setDirection(value: Vector3): void;
  76723. /**
  76724. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76725. * Also use as the light direction on spot and directional lights.
  76726. */
  76727. /**
  76728. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76729. * Also use as the light direction on spot and directional lights.
  76730. */
  76731. direction: Vector3;
  76732. private _shadowMinZ;
  76733. /**
  76734. * Gets the shadow projection clipping minimum z value.
  76735. */
  76736. /**
  76737. * Sets the shadow projection clipping minimum z value.
  76738. */
  76739. shadowMinZ: number;
  76740. private _shadowMaxZ;
  76741. /**
  76742. * Sets the shadow projection clipping maximum z value.
  76743. */
  76744. /**
  76745. * Gets the shadow projection clipping maximum z value.
  76746. */
  76747. shadowMaxZ: number;
  76748. /**
  76749. * Callback defining a custom Projection Matrix Builder.
  76750. * This can be used to override the default projection matrix computation.
  76751. */
  76752. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76753. /**
  76754. * The transformed position. Position of the light in world space taking parenting in account.
  76755. */
  76756. transformedPosition: Vector3;
  76757. /**
  76758. * The transformed direction. Direction of the light in world space taking parenting in account.
  76759. */
  76760. transformedDirection: Vector3;
  76761. private _needProjectionMatrixCompute;
  76762. /**
  76763. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76764. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76765. */
  76766. computeTransformedInformation(): boolean;
  76767. /**
  76768. * Return the depth scale used for the shadow map.
  76769. * @returns the depth scale.
  76770. */
  76771. getDepthScale(): number;
  76772. /**
  76773. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76774. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76775. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76776. */
  76777. getShadowDirection(faceIndex?: number): Vector3;
  76778. /**
  76779. * Returns the ShadowLight absolute position in the World.
  76780. * @returns the position vector in world space
  76781. */
  76782. getAbsolutePosition(): Vector3;
  76783. /**
  76784. * Sets the ShadowLight direction toward the passed target.
  76785. * @param target The point to target in local space
  76786. * @returns the updated ShadowLight direction
  76787. */
  76788. setDirectionToTarget(target: Vector3): Vector3;
  76789. /**
  76790. * Returns the light rotation in euler definition.
  76791. * @returns the x y z rotation in local space.
  76792. */
  76793. getRotation(): Vector3;
  76794. /**
  76795. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76796. * @returns true if a cube texture needs to be use
  76797. */
  76798. needCube(): boolean;
  76799. /**
  76800. * Detects if the projection matrix requires to be recomputed this frame.
  76801. * @returns true if it requires to be recomputed otherwise, false.
  76802. */
  76803. needProjectionMatrixCompute(): boolean;
  76804. /**
  76805. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76806. */
  76807. forceProjectionMatrixCompute(): void;
  76808. /** @hidden */
  76809. _initCache(): void;
  76810. /** @hidden */
  76811. _isSynchronized(): boolean;
  76812. /**
  76813. * Computes the world matrix of the node
  76814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76815. * @returns the world matrix
  76816. */
  76817. computeWorldMatrix(force?: boolean): Matrix;
  76818. /**
  76819. * Gets the minZ used for shadow according to both the scene and the light.
  76820. * @param activeCamera The camera we are returning the min for
  76821. * @returns the depth min z
  76822. */
  76823. getDepthMinZ(activeCamera: Camera): number;
  76824. /**
  76825. * Gets the maxZ used for shadow according to both the scene and the light.
  76826. * @param activeCamera The camera we are returning the max for
  76827. * @returns the depth max z
  76828. */
  76829. getDepthMaxZ(activeCamera: Camera): number;
  76830. /**
  76831. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76832. * @param matrix The materix to updated with the projection information
  76833. * @param viewMatrix The transform matrix of the light
  76834. * @param renderList The list of mesh to render in the map
  76835. * @returns The current light
  76836. */
  76837. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76838. }
  76839. }
  76840. declare module BABYLON {
  76841. /**
  76842. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76843. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76844. */
  76845. export class EffectFallbacks implements IEffectFallbacks {
  76846. private _defines;
  76847. private _currentRank;
  76848. private _maxRank;
  76849. private _mesh;
  76850. /**
  76851. * Removes the fallback from the bound mesh.
  76852. */
  76853. unBindMesh(): void;
  76854. /**
  76855. * Adds a fallback on the specified property.
  76856. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76857. * @param define The name of the define in the shader
  76858. */
  76859. addFallback(rank: number, define: string): void;
  76860. /**
  76861. * Sets the mesh to use CPU skinning when needing to fallback.
  76862. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76863. * @param mesh The mesh to use the fallbacks.
  76864. */
  76865. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76866. /**
  76867. * Checks to see if more fallbacks are still availible.
  76868. */
  76869. readonly hasMoreFallbacks: boolean;
  76870. /**
  76871. * Removes the defines that should be removed when falling back.
  76872. * @param currentDefines defines the current define statements for the shader.
  76873. * @param effect defines the current effect we try to compile
  76874. * @returns The resulting defines with defines of the current rank removed.
  76875. */
  76876. reduce(currentDefines: string, effect: Effect): string;
  76877. }
  76878. }
  76879. declare module BABYLON {
  76880. /**
  76881. * "Static Class" containing the most commonly used helper while dealing with material for
  76882. * rendering purpose.
  76883. *
  76884. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76885. *
  76886. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76887. */
  76888. export class MaterialHelper {
  76889. /**
  76890. * Bind the current view position to an effect.
  76891. * @param effect The effect to be bound
  76892. * @param scene The scene the eyes position is used from
  76893. */
  76894. static BindEyePosition(effect: Effect, scene: Scene): void;
  76895. /**
  76896. * Helps preparing the defines values about the UVs in used in the effect.
  76897. * UVs are shared as much as we can accross channels in the shaders.
  76898. * @param texture The texture we are preparing the UVs for
  76899. * @param defines The defines to update
  76900. * @param key The channel key "diffuse", "specular"... used in the shader
  76901. */
  76902. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76903. /**
  76904. * Binds a texture matrix value to its corrsponding uniform
  76905. * @param texture The texture to bind the matrix for
  76906. * @param uniformBuffer The uniform buffer receivin the data
  76907. * @param key The channel key "diffuse", "specular"... used in the shader
  76908. */
  76909. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76910. /**
  76911. * Gets the current status of the fog (should it be enabled?)
  76912. * @param mesh defines the mesh to evaluate for fog support
  76913. * @param scene defines the hosting scene
  76914. * @returns true if fog must be enabled
  76915. */
  76916. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76917. /**
  76918. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76919. * @param mesh defines the current mesh
  76920. * @param scene defines the current scene
  76921. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76922. * @param pointsCloud defines if point cloud rendering has to be turned on
  76923. * @param fogEnabled defines if fog has to be turned on
  76924. * @param alphaTest defines if alpha testing has to be turned on
  76925. * @param defines defines the current list of defines
  76926. */
  76927. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76928. /**
  76929. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76930. * @param scene defines the current scene
  76931. * @param engine defines the current engine
  76932. * @param defines specifies the list of active defines
  76933. * @param useInstances defines if instances have to be turned on
  76934. * @param useClipPlane defines if clip plane have to be turned on
  76935. */
  76936. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76937. /**
  76938. * Prepares the defines for bones
  76939. * @param mesh The mesh containing the geometry data we will draw
  76940. * @param defines The defines to update
  76941. */
  76942. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76943. /**
  76944. * Prepares the defines for morph targets
  76945. * @param mesh The mesh containing the geometry data we will draw
  76946. * @param defines The defines to update
  76947. */
  76948. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76949. /**
  76950. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76951. * @param mesh The mesh containing the geometry data we will draw
  76952. * @param defines The defines to update
  76953. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76954. * @param useBones Precise whether bones should be used or not (override mesh info)
  76955. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76956. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76957. * @returns false if defines are considered not dirty and have not been checked
  76958. */
  76959. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76960. /**
  76961. * Prepares the defines related to multiview
  76962. * @param scene The scene we are intending to draw
  76963. * @param defines The defines to update
  76964. */
  76965. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76966. /**
  76967. * Prepares the defines related to the light information passed in parameter
  76968. * @param scene The scene we are intending to draw
  76969. * @param mesh The mesh the effect is compiling for
  76970. * @param light The light the effect is compiling for
  76971. * @param lightIndex The index of the light
  76972. * @param defines The defines to update
  76973. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76974. * @param state Defines the current state regarding what is needed (normals, etc...)
  76975. */
  76976. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76977. needNormals: boolean;
  76978. needRebuild: boolean;
  76979. shadowEnabled: boolean;
  76980. specularEnabled: boolean;
  76981. lightmapMode: boolean;
  76982. }): void;
  76983. /**
  76984. * Prepares the defines related to the light information passed in parameter
  76985. * @param scene The scene we are intending to draw
  76986. * @param mesh The mesh the effect is compiling for
  76987. * @param defines The defines to update
  76988. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76989. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76990. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76991. * @returns true if normals will be required for the rest of the effect
  76992. */
  76993. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76994. /**
  76995. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76996. * @param lightIndex defines the light index
  76997. * @param uniformsList The uniform list
  76998. * @param samplersList The sampler list
  76999. * @param projectedLightTexture defines if projected texture must be used
  77000. * @param uniformBuffersList defines an optional list of uniform buffers
  77001. */
  77002. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77003. /**
  77004. * Prepares the uniforms and samplers list to be used in the effect
  77005. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77006. * @param samplersList The sampler list
  77007. * @param defines The defines helping in the list generation
  77008. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77009. */
  77010. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77011. /**
  77012. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77013. * @param defines The defines to update while falling back
  77014. * @param fallbacks The authorized effect fallbacks
  77015. * @param maxSimultaneousLights The maximum number of lights allowed
  77016. * @param rank the current rank of the Effect
  77017. * @returns The newly affected rank
  77018. */
  77019. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77020. private static _TmpMorphInfluencers;
  77021. /**
  77022. * Prepares the list of attributes required for morph targets according to the effect defines.
  77023. * @param attribs The current list of supported attribs
  77024. * @param mesh The mesh to prepare the morph targets attributes for
  77025. * @param influencers The number of influencers
  77026. */
  77027. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77028. /**
  77029. * Prepares the list of attributes required for morph targets according to the effect defines.
  77030. * @param attribs The current list of supported attribs
  77031. * @param mesh The mesh to prepare the morph targets attributes for
  77032. * @param defines The current Defines of the effect
  77033. */
  77034. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77035. /**
  77036. * Prepares the list of attributes required for bones according to the effect defines.
  77037. * @param attribs The current list of supported attribs
  77038. * @param mesh The mesh to prepare the bones attributes for
  77039. * @param defines The current Defines of the effect
  77040. * @param fallbacks The current efffect fallback strategy
  77041. */
  77042. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77043. /**
  77044. * Check and prepare the list of attributes required for instances according to the effect defines.
  77045. * @param attribs The current list of supported attribs
  77046. * @param defines The current MaterialDefines of the effect
  77047. */
  77048. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77049. /**
  77050. * Add the list of attributes required for instances to the attribs array.
  77051. * @param attribs The current list of supported attribs
  77052. */
  77053. static PushAttributesForInstances(attribs: string[]): void;
  77054. /**
  77055. * Binds the light information to the effect.
  77056. * @param light The light containing the generator
  77057. * @param effect The effect we are binding the data to
  77058. * @param lightIndex The light index in the effect used to render
  77059. */
  77060. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77061. /**
  77062. * Binds the lights information from the scene to the effect for the given mesh.
  77063. * @param light Light to bind
  77064. * @param lightIndex Light index
  77065. * @param scene The scene where the light belongs to
  77066. * @param effect The effect we are binding the data to
  77067. * @param useSpecular Defines if specular is supported
  77068. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77070. */
  77071. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77072. /**
  77073. * Binds the lights information from the scene to the effect for the given mesh.
  77074. * @param scene The scene the lights belongs to
  77075. * @param mesh The mesh we are binding the information to render
  77076. * @param effect The effect we are binding the data to
  77077. * @param defines The generated defines for the effect
  77078. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77079. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77080. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77081. */
  77082. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77083. private static _tempFogColor;
  77084. /**
  77085. * Binds the fog information from the scene to the effect for the given mesh.
  77086. * @param scene The scene the lights belongs to
  77087. * @param mesh The mesh we are binding the information to render
  77088. * @param effect The effect we are binding the data to
  77089. * @param linearSpace Defines if the fog effect is applied in linear space
  77090. */
  77091. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77092. /**
  77093. * Binds the bones information from the mesh to the effect.
  77094. * @param mesh The mesh we are binding the information to render
  77095. * @param effect The effect we are binding the data to
  77096. */
  77097. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77098. /**
  77099. * Binds the morph targets information from the mesh to the effect.
  77100. * @param abstractMesh The mesh we are binding the information to render
  77101. * @param effect The effect we are binding the data to
  77102. */
  77103. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77104. /**
  77105. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77106. * @param defines The generated defines used in the effect
  77107. * @param effect The effect we are binding the data to
  77108. * @param scene The scene we are willing to render with logarithmic scale for
  77109. */
  77110. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77111. /**
  77112. * Binds the clip plane information from the scene to the effect.
  77113. * @param scene The scene the clip plane information are extracted from
  77114. * @param effect The effect we are binding the data to
  77115. */
  77116. static BindClipPlane(effect: Effect, scene: Scene): void;
  77117. }
  77118. }
  77119. declare module BABYLON {
  77120. /** @hidden */
  77121. export var packingFunctions: {
  77122. name: string;
  77123. shader: string;
  77124. };
  77125. }
  77126. declare module BABYLON {
  77127. /** @hidden */
  77128. export var shadowMapPixelShader: {
  77129. name: string;
  77130. shader: string;
  77131. };
  77132. }
  77133. declare module BABYLON {
  77134. /** @hidden */
  77135. export var bonesDeclaration: {
  77136. name: string;
  77137. shader: string;
  77138. };
  77139. }
  77140. declare module BABYLON {
  77141. /** @hidden */
  77142. export var morphTargetsVertexGlobalDeclaration: {
  77143. name: string;
  77144. shader: string;
  77145. };
  77146. }
  77147. declare module BABYLON {
  77148. /** @hidden */
  77149. export var morphTargetsVertexDeclaration: {
  77150. name: string;
  77151. shader: string;
  77152. };
  77153. }
  77154. declare module BABYLON {
  77155. /** @hidden */
  77156. export var instancesDeclaration: {
  77157. name: string;
  77158. shader: string;
  77159. };
  77160. }
  77161. declare module BABYLON {
  77162. /** @hidden */
  77163. export var helperFunctions: {
  77164. name: string;
  77165. shader: string;
  77166. };
  77167. }
  77168. declare module BABYLON {
  77169. /** @hidden */
  77170. export var morphTargetsVertex: {
  77171. name: string;
  77172. shader: string;
  77173. };
  77174. }
  77175. declare module BABYLON {
  77176. /** @hidden */
  77177. export var instancesVertex: {
  77178. name: string;
  77179. shader: string;
  77180. };
  77181. }
  77182. declare module BABYLON {
  77183. /** @hidden */
  77184. export var bonesVertex: {
  77185. name: string;
  77186. shader: string;
  77187. };
  77188. }
  77189. declare module BABYLON {
  77190. /** @hidden */
  77191. export var shadowMapVertexShader: {
  77192. name: string;
  77193. shader: string;
  77194. };
  77195. }
  77196. declare module BABYLON {
  77197. /** @hidden */
  77198. export var depthBoxBlurPixelShader: {
  77199. name: string;
  77200. shader: string;
  77201. };
  77202. }
  77203. declare module BABYLON {
  77204. /**
  77205. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77206. */
  77207. export interface ICustomShaderOptions {
  77208. /**
  77209. * Gets or sets the custom shader name to use
  77210. */
  77211. shaderName: string;
  77212. /**
  77213. * The list of attribute names used in the shader
  77214. */
  77215. attributes?: string[];
  77216. /**
  77217. * The list of unifrom names used in the shader
  77218. */
  77219. uniforms?: string[];
  77220. /**
  77221. * The list of sampler names used in the shader
  77222. */
  77223. samplers?: string[];
  77224. /**
  77225. * The list of defines used in the shader
  77226. */
  77227. defines?: string[];
  77228. }
  77229. /**
  77230. * Interface to implement to create a shadow generator compatible with BJS.
  77231. */
  77232. export interface IShadowGenerator {
  77233. /**
  77234. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77235. * @returns The render target texture if present otherwise, null
  77236. */
  77237. getShadowMap(): Nullable<RenderTargetTexture>;
  77238. /**
  77239. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77240. * @returns The render target texture if the shadow map is present otherwise, null
  77241. */
  77242. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77243. /**
  77244. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77245. * @param subMesh The submesh we want to render in the shadow map
  77246. * @param useInstances Defines wether will draw in the map using instances
  77247. * @returns true if ready otherwise, false
  77248. */
  77249. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77250. /**
  77251. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77252. * @param defines Defines of the material we want to update
  77253. * @param lightIndex Index of the light in the enabled light list of the material
  77254. */
  77255. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77256. /**
  77257. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77258. * defined in the generator but impacting the effect).
  77259. * It implies the unifroms available on the materials are the standard BJS ones.
  77260. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77261. * @param effect The effect we are binfing the information for
  77262. */
  77263. bindShadowLight(lightIndex: string, effect: Effect): void;
  77264. /**
  77265. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77266. * (eq to shadow prjection matrix * light transform matrix)
  77267. * @returns The transform matrix used to create the shadow map
  77268. */
  77269. getTransformMatrix(): Matrix;
  77270. /**
  77271. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77272. * Cube and 2D textures for instance.
  77273. */
  77274. recreateShadowMap(): void;
  77275. /**
  77276. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77277. * @param onCompiled Callback triggered at the and of the effects compilation
  77278. * @param options Sets of optional options forcing the compilation with different modes
  77279. */
  77280. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77281. useInstances: boolean;
  77282. }>): void;
  77283. /**
  77284. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77285. * @param options Sets of optional options forcing the compilation with different modes
  77286. * @returns A promise that resolves when the compilation completes
  77287. */
  77288. forceCompilationAsync(options?: Partial<{
  77289. useInstances: boolean;
  77290. }>): Promise<void>;
  77291. /**
  77292. * Serializes the shadow generator setup to a json object.
  77293. * @returns The serialized JSON object
  77294. */
  77295. serialize(): any;
  77296. /**
  77297. * Disposes the Shadow map and related Textures and effects.
  77298. */
  77299. dispose(): void;
  77300. }
  77301. /**
  77302. * Default implementation IShadowGenerator.
  77303. * This is the main object responsible of generating shadows in the framework.
  77304. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77305. */
  77306. export class ShadowGenerator implements IShadowGenerator {
  77307. /**
  77308. * Shadow generator mode None: no filtering applied.
  77309. */
  77310. static readonly FILTER_NONE: number;
  77311. /**
  77312. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77313. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77314. */
  77315. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77316. /**
  77317. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77318. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77319. */
  77320. static readonly FILTER_POISSONSAMPLING: number;
  77321. /**
  77322. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77323. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77324. */
  77325. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77326. /**
  77327. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77328. * edge artifacts on steep falloff.
  77329. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77330. */
  77331. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77332. /**
  77333. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77334. * edge artifacts on steep falloff.
  77335. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77336. */
  77337. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77338. /**
  77339. * Shadow generator mode PCF: Percentage Closer Filtering
  77340. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77341. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77342. */
  77343. static readonly FILTER_PCF: number;
  77344. /**
  77345. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77346. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77347. * Contact Hardening
  77348. */
  77349. static readonly FILTER_PCSS: number;
  77350. /**
  77351. * Reserved for PCF and PCSS
  77352. * Highest Quality.
  77353. *
  77354. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77355. *
  77356. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77357. */
  77358. static readonly QUALITY_HIGH: number;
  77359. /**
  77360. * Reserved for PCF and PCSS
  77361. * Good tradeoff for quality/perf cross devices
  77362. *
  77363. * Execute PCF on a 3*3 kernel.
  77364. *
  77365. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77366. */
  77367. static readonly QUALITY_MEDIUM: number;
  77368. /**
  77369. * Reserved for PCF and PCSS
  77370. * The lowest quality but the fastest.
  77371. *
  77372. * Execute PCF on a 1*1 kernel.
  77373. *
  77374. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77375. */
  77376. static readonly QUALITY_LOW: number;
  77377. /** Gets or sets the custom shader name to use */
  77378. customShaderOptions: ICustomShaderOptions;
  77379. /**
  77380. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77381. */
  77382. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77383. /**
  77384. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77385. */
  77386. onAfterShadowMapRenderObservable: Observable<Effect>;
  77387. /**
  77388. * Observable triggered before a mesh is rendered in the shadow map.
  77389. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77390. */
  77391. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77392. /**
  77393. * Observable triggered after a mesh is rendered in the shadow map.
  77394. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77395. */
  77396. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77397. private _bias;
  77398. /**
  77399. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77400. */
  77401. /**
  77402. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77403. */
  77404. bias: number;
  77405. private _normalBias;
  77406. /**
  77407. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77408. */
  77409. /**
  77410. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77411. */
  77412. normalBias: number;
  77413. private _blurBoxOffset;
  77414. /**
  77415. * Gets the blur box offset: offset applied during the blur pass.
  77416. * Only useful if useKernelBlur = false
  77417. */
  77418. /**
  77419. * Sets the blur box offset: offset applied during the blur pass.
  77420. * Only useful if useKernelBlur = false
  77421. */
  77422. blurBoxOffset: number;
  77423. private _blurScale;
  77424. /**
  77425. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77426. * 2 means half of the size.
  77427. */
  77428. /**
  77429. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77430. * 2 means half of the size.
  77431. */
  77432. blurScale: number;
  77433. private _blurKernel;
  77434. /**
  77435. * Gets the blur kernel: kernel size of the blur pass.
  77436. * Only useful if useKernelBlur = true
  77437. */
  77438. /**
  77439. * Sets the blur kernel: kernel size of the blur pass.
  77440. * Only useful if useKernelBlur = true
  77441. */
  77442. blurKernel: number;
  77443. private _useKernelBlur;
  77444. /**
  77445. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77446. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77447. */
  77448. /**
  77449. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77450. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77451. */
  77452. useKernelBlur: boolean;
  77453. private _depthScale;
  77454. /**
  77455. * Gets the depth scale used in ESM mode.
  77456. */
  77457. /**
  77458. * Sets the depth scale used in ESM mode.
  77459. * This can override the scale stored on the light.
  77460. */
  77461. depthScale: number;
  77462. private _filter;
  77463. /**
  77464. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77465. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77466. */
  77467. /**
  77468. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77469. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77470. */
  77471. filter: number;
  77472. /**
  77473. * Gets if the current filter is set to Poisson Sampling.
  77474. */
  77475. /**
  77476. * Sets the current filter to Poisson Sampling.
  77477. */
  77478. usePoissonSampling: boolean;
  77479. /**
  77480. * Gets if the current filter is set to ESM.
  77481. */
  77482. /**
  77483. * Sets the current filter is to ESM.
  77484. */
  77485. useExponentialShadowMap: boolean;
  77486. /**
  77487. * Gets if the current filter is set to filtered ESM.
  77488. */
  77489. /**
  77490. * Gets if the current filter is set to filtered ESM.
  77491. */
  77492. useBlurExponentialShadowMap: boolean;
  77493. /**
  77494. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77495. * exponential to prevent steep falloff artifacts).
  77496. */
  77497. /**
  77498. * Sets the current filter to "close ESM" (using the inverse of the
  77499. * exponential to prevent steep falloff artifacts).
  77500. */
  77501. useCloseExponentialShadowMap: boolean;
  77502. /**
  77503. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77504. * exponential to prevent steep falloff artifacts).
  77505. */
  77506. /**
  77507. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77508. * exponential to prevent steep falloff artifacts).
  77509. */
  77510. useBlurCloseExponentialShadowMap: boolean;
  77511. /**
  77512. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77513. */
  77514. /**
  77515. * Sets the current filter to "PCF" (percentage closer filtering).
  77516. */
  77517. usePercentageCloserFiltering: boolean;
  77518. private _filteringQuality;
  77519. /**
  77520. * Gets the PCF or PCSS Quality.
  77521. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77522. */
  77523. /**
  77524. * Sets the PCF or PCSS Quality.
  77525. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77526. */
  77527. filteringQuality: number;
  77528. /**
  77529. * Gets if the current filter is set to "PCSS" (contact hardening).
  77530. */
  77531. /**
  77532. * Sets the current filter to "PCSS" (contact hardening).
  77533. */
  77534. useContactHardeningShadow: boolean;
  77535. private _contactHardeningLightSizeUVRatio;
  77536. /**
  77537. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77538. * Using a ratio helps keeping shape stability independently of the map size.
  77539. *
  77540. * It does not account for the light projection as it was having too much
  77541. * instability during the light setup or during light position changes.
  77542. *
  77543. * Only valid if useContactHardeningShadow is true.
  77544. */
  77545. /**
  77546. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77547. * Using a ratio helps keeping shape stability independently of the map size.
  77548. *
  77549. * It does not account for the light projection as it was having too much
  77550. * instability during the light setup or during light position changes.
  77551. *
  77552. * Only valid if useContactHardeningShadow is true.
  77553. */
  77554. contactHardeningLightSizeUVRatio: number;
  77555. private _darkness;
  77556. /** Gets or sets the actual darkness of a shadow */
  77557. darkness: number;
  77558. /**
  77559. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77560. * 0 means strongest and 1 would means no shadow.
  77561. * @returns the darkness.
  77562. */
  77563. getDarkness(): number;
  77564. /**
  77565. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77566. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77567. * @returns the shadow generator allowing fluent coding.
  77568. */
  77569. setDarkness(darkness: number): ShadowGenerator;
  77570. private _transparencyShadow;
  77571. /** Gets or sets the ability to have transparent shadow */
  77572. transparencyShadow: boolean;
  77573. /**
  77574. * Sets the ability to have transparent shadow (boolean).
  77575. * @param transparent True if transparent else False
  77576. * @returns the shadow generator allowing fluent coding
  77577. */
  77578. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77579. private _shadowMap;
  77580. private _shadowMap2;
  77581. /**
  77582. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77583. * @returns The render target texture if present otherwise, null
  77584. */
  77585. getShadowMap(): Nullable<RenderTargetTexture>;
  77586. /**
  77587. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77588. * @returns The render target texture if the shadow map is present otherwise, null
  77589. */
  77590. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77591. /**
  77592. * Gets the class name of that object
  77593. * @returns "ShadowGenerator"
  77594. */
  77595. getClassName(): string;
  77596. /**
  77597. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77598. * @param mesh Mesh to add
  77599. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77600. * @returns the Shadow Generator itself
  77601. */
  77602. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77603. /**
  77604. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77605. * @param mesh Mesh to remove
  77606. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77607. * @returns the Shadow Generator itself
  77608. */
  77609. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77610. /**
  77611. * Controls the extent to which the shadows fade out at the edge of the frustum
  77612. * Used only by directionals and spots
  77613. */
  77614. frustumEdgeFalloff: number;
  77615. private _light;
  77616. /**
  77617. * Returns the associated light object.
  77618. * @returns the light generating the shadow
  77619. */
  77620. getLight(): IShadowLight;
  77621. /**
  77622. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77623. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77624. * It might on the other hand introduce peter panning.
  77625. */
  77626. forceBackFacesOnly: boolean;
  77627. private _scene;
  77628. private _lightDirection;
  77629. private _effect;
  77630. private _viewMatrix;
  77631. private _projectionMatrix;
  77632. private _transformMatrix;
  77633. private _cachedPosition;
  77634. private _cachedDirection;
  77635. private _cachedDefines;
  77636. private _currentRenderID;
  77637. private _boxBlurPostprocess;
  77638. private _kernelBlurXPostprocess;
  77639. private _kernelBlurYPostprocess;
  77640. private _blurPostProcesses;
  77641. private _mapSize;
  77642. private _currentFaceIndex;
  77643. private _currentFaceIndexCache;
  77644. private _textureType;
  77645. private _defaultTextureMatrix;
  77646. private _storedUniqueId;
  77647. /** @hidden */
  77648. static _SceneComponentInitialization: (scene: Scene) => void;
  77649. /**
  77650. * Creates a ShadowGenerator object.
  77651. * A ShadowGenerator is the required tool to use the shadows.
  77652. * Each light casting shadows needs to use its own ShadowGenerator.
  77653. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77654. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77655. * @param light The light object generating the shadows.
  77656. * @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.
  77657. */
  77658. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77659. private _initializeGenerator;
  77660. private _initializeShadowMap;
  77661. private _initializeBlurRTTAndPostProcesses;
  77662. private _renderForShadowMap;
  77663. private _renderSubMeshForShadowMap;
  77664. private _applyFilterValues;
  77665. /**
  77666. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77667. * @param onCompiled Callback triggered at the and of the effects compilation
  77668. * @param options Sets of optional options forcing the compilation with different modes
  77669. */
  77670. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77671. useInstances: boolean;
  77672. }>): void;
  77673. /**
  77674. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77675. * @param options Sets of optional options forcing the compilation with different modes
  77676. * @returns A promise that resolves when the compilation completes
  77677. */
  77678. forceCompilationAsync(options?: Partial<{
  77679. useInstances: boolean;
  77680. }>): Promise<void>;
  77681. /**
  77682. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77683. * @param subMesh The submesh we want to render in the shadow map
  77684. * @param useInstances Defines wether will draw in the map using instances
  77685. * @returns true if ready otherwise, false
  77686. */
  77687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77688. /**
  77689. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77690. * @param defines Defines of the material we want to update
  77691. * @param lightIndex Index of the light in the enabled light list of the material
  77692. */
  77693. prepareDefines(defines: any, lightIndex: number): void;
  77694. /**
  77695. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77696. * defined in the generator but impacting the effect).
  77697. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77698. * @param effect The effect we are binfing the information for
  77699. */
  77700. bindShadowLight(lightIndex: string, effect: Effect): void;
  77701. /**
  77702. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77703. * (eq to shadow prjection matrix * light transform matrix)
  77704. * @returns The transform matrix used to create the shadow map
  77705. */
  77706. getTransformMatrix(): Matrix;
  77707. /**
  77708. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77709. * Cube and 2D textures for instance.
  77710. */
  77711. recreateShadowMap(): void;
  77712. private _disposeBlurPostProcesses;
  77713. private _disposeRTTandPostProcesses;
  77714. /**
  77715. * Disposes the ShadowGenerator.
  77716. * Returns nothing.
  77717. */
  77718. dispose(): void;
  77719. /**
  77720. * Serializes the shadow generator setup to a json object.
  77721. * @returns The serialized JSON object
  77722. */
  77723. serialize(): any;
  77724. /**
  77725. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77726. * @param parsedShadowGenerator The JSON object to parse
  77727. * @param scene The scene to create the shadow map for
  77728. * @returns The parsed shadow generator
  77729. */
  77730. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77731. }
  77732. }
  77733. declare module BABYLON {
  77734. /**
  77735. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77736. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77737. * 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.
  77738. */
  77739. export abstract class Light extends Node {
  77740. /**
  77741. * Falloff Default: light is falling off following the material specification:
  77742. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77743. */
  77744. static readonly FALLOFF_DEFAULT: number;
  77745. /**
  77746. * Falloff Physical: light is falling off following the inverse squared distance law.
  77747. */
  77748. static readonly FALLOFF_PHYSICAL: number;
  77749. /**
  77750. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77751. * to enhance interoperability with other engines.
  77752. */
  77753. static readonly FALLOFF_GLTF: number;
  77754. /**
  77755. * Falloff Standard: light is falling off like in the standard material
  77756. * to enhance interoperability with other materials.
  77757. */
  77758. static readonly FALLOFF_STANDARD: number;
  77759. /**
  77760. * If every light affecting the material is in this lightmapMode,
  77761. * material.lightmapTexture adds or multiplies
  77762. * (depends on material.useLightmapAsShadowmap)
  77763. * after every other light calculations.
  77764. */
  77765. static readonly LIGHTMAP_DEFAULT: number;
  77766. /**
  77767. * material.lightmapTexture as only diffuse lighting from this light
  77768. * adds only specular lighting from this light
  77769. * adds dynamic shadows
  77770. */
  77771. static readonly LIGHTMAP_SPECULAR: number;
  77772. /**
  77773. * material.lightmapTexture as only lighting
  77774. * no light calculation from this light
  77775. * only adds dynamic shadows from this light
  77776. */
  77777. static readonly LIGHTMAP_SHADOWSONLY: number;
  77778. /**
  77779. * Each light type uses the default quantity according to its type:
  77780. * point/spot lights use luminous intensity
  77781. * directional lights use illuminance
  77782. */
  77783. static readonly INTENSITYMODE_AUTOMATIC: number;
  77784. /**
  77785. * lumen (lm)
  77786. */
  77787. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77788. /**
  77789. * candela (lm/sr)
  77790. */
  77791. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77792. /**
  77793. * lux (lm/m^2)
  77794. */
  77795. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77796. /**
  77797. * nit (cd/m^2)
  77798. */
  77799. static readonly INTENSITYMODE_LUMINANCE: number;
  77800. /**
  77801. * Light type const id of the point light.
  77802. */
  77803. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77804. /**
  77805. * Light type const id of the directional light.
  77806. */
  77807. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77808. /**
  77809. * Light type const id of the spot light.
  77810. */
  77811. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77812. /**
  77813. * Light type const id of the hemispheric light.
  77814. */
  77815. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77816. /**
  77817. * Diffuse gives the basic color to an object.
  77818. */
  77819. diffuse: Color3;
  77820. /**
  77821. * Specular produces a highlight color on an object.
  77822. * Note: This is note affecting PBR materials.
  77823. */
  77824. specular: Color3;
  77825. /**
  77826. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77827. * falling off base on range or angle.
  77828. * This can be set to any values in Light.FALLOFF_x.
  77829. *
  77830. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77831. * other types of materials.
  77832. */
  77833. falloffType: number;
  77834. /**
  77835. * Strength of the light.
  77836. * Note: By default it is define in the framework own unit.
  77837. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77838. */
  77839. intensity: number;
  77840. private _range;
  77841. protected _inverseSquaredRange: number;
  77842. /**
  77843. * Defines how far from the source the light is impacting in scene units.
  77844. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77845. */
  77846. /**
  77847. * Defines how far from the source the light is impacting in scene units.
  77848. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77849. */
  77850. range: number;
  77851. /**
  77852. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77853. * of light.
  77854. */
  77855. private _photometricScale;
  77856. private _intensityMode;
  77857. /**
  77858. * Gets the photometric scale used to interpret the intensity.
  77859. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77860. */
  77861. /**
  77862. * Sets the photometric scale used to interpret the intensity.
  77863. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77864. */
  77865. intensityMode: number;
  77866. private _radius;
  77867. /**
  77868. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77869. */
  77870. /**
  77871. * sets the light radius used by PBR Materials to simulate soft area lights.
  77872. */
  77873. radius: number;
  77874. private _renderPriority;
  77875. /**
  77876. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77877. * exceeding the number allowed of the materials.
  77878. */
  77879. renderPriority: number;
  77880. private _shadowEnabled;
  77881. /**
  77882. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77883. * the current shadow generator.
  77884. */
  77885. /**
  77886. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77887. * the current shadow generator.
  77888. */
  77889. shadowEnabled: boolean;
  77890. private _includedOnlyMeshes;
  77891. /**
  77892. * Gets the only meshes impacted by this light.
  77893. */
  77894. /**
  77895. * Sets the only meshes impacted by this light.
  77896. */
  77897. includedOnlyMeshes: AbstractMesh[];
  77898. private _excludedMeshes;
  77899. /**
  77900. * Gets the meshes not impacted by this light.
  77901. */
  77902. /**
  77903. * Sets the meshes not impacted by this light.
  77904. */
  77905. excludedMeshes: AbstractMesh[];
  77906. private _excludeWithLayerMask;
  77907. /**
  77908. * Gets the layer id use to find what meshes are not impacted by the light.
  77909. * Inactive if 0
  77910. */
  77911. /**
  77912. * Sets the layer id use to find what meshes are not impacted by the light.
  77913. * Inactive if 0
  77914. */
  77915. excludeWithLayerMask: number;
  77916. private _includeOnlyWithLayerMask;
  77917. /**
  77918. * Gets the layer id use to find what meshes are impacted by the light.
  77919. * Inactive if 0
  77920. */
  77921. /**
  77922. * Sets the layer id use to find what meshes are impacted by the light.
  77923. * Inactive if 0
  77924. */
  77925. includeOnlyWithLayerMask: number;
  77926. private _lightmapMode;
  77927. /**
  77928. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77929. */
  77930. /**
  77931. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77932. */
  77933. lightmapMode: number;
  77934. /**
  77935. * Shadow generator associted to the light.
  77936. * @hidden Internal use only.
  77937. */
  77938. _shadowGenerator: Nullable<IShadowGenerator>;
  77939. /**
  77940. * @hidden Internal use only.
  77941. */
  77942. _excludedMeshesIds: string[];
  77943. /**
  77944. * @hidden Internal use only.
  77945. */
  77946. _includedOnlyMeshesIds: string[];
  77947. /**
  77948. * The current light unifom buffer.
  77949. * @hidden Internal use only.
  77950. */
  77951. _uniformBuffer: UniformBuffer;
  77952. /** @hidden */
  77953. _renderId: number;
  77954. /**
  77955. * Creates a Light object in the scene.
  77956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77957. * @param name The firendly name of the light
  77958. * @param scene The scene the light belongs too
  77959. */
  77960. constructor(name: string, scene: Scene);
  77961. protected abstract _buildUniformLayout(): void;
  77962. /**
  77963. * Sets the passed Effect "effect" with the Light information.
  77964. * @param effect The effect to update
  77965. * @param lightIndex The index of the light in the effect to update
  77966. * @returns The light
  77967. */
  77968. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77969. /**
  77970. * Sets the passed Effect "effect" with the Light information.
  77971. * @param effect The effect to update
  77972. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77973. * @returns The light
  77974. */
  77975. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77976. /**
  77977. * Returns the string "Light".
  77978. * @returns the class name
  77979. */
  77980. getClassName(): string;
  77981. /** @hidden */
  77982. readonly _isLight: boolean;
  77983. /**
  77984. * Converts the light information to a readable string for debug purpose.
  77985. * @param fullDetails Supports for multiple levels of logging within scene loading
  77986. * @returns the human readable light info
  77987. */
  77988. toString(fullDetails?: boolean): string;
  77989. /** @hidden */
  77990. protected _syncParentEnabledState(): void;
  77991. /**
  77992. * Set the enabled state of this node.
  77993. * @param value - the new enabled state
  77994. */
  77995. setEnabled(value: boolean): void;
  77996. /**
  77997. * Returns the Light associated shadow generator if any.
  77998. * @return the associated shadow generator.
  77999. */
  78000. getShadowGenerator(): Nullable<IShadowGenerator>;
  78001. /**
  78002. * Returns a Vector3, the absolute light position in the World.
  78003. * @returns the world space position of the light
  78004. */
  78005. getAbsolutePosition(): Vector3;
  78006. /**
  78007. * Specifies if the light will affect the passed mesh.
  78008. * @param mesh The mesh to test against the light
  78009. * @return true the mesh is affected otherwise, false.
  78010. */
  78011. canAffectMesh(mesh: AbstractMesh): boolean;
  78012. /**
  78013. * Sort function to order lights for rendering.
  78014. * @param a First Light object to compare to second.
  78015. * @param b Second Light object to compare first.
  78016. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78017. */
  78018. static CompareLightsPriority(a: Light, b: Light): number;
  78019. /**
  78020. * Releases resources associated with this node.
  78021. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78022. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78023. */
  78024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78025. /**
  78026. * Returns the light type ID (integer).
  78027. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78028. */
  78029. getTypeID(): number;
  78030. /**
  78031. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78032. * @returns the scaled intensity in intensity mode unit
  78033. */
  78034. getScaledIntensity(): number;
  78035. /**
  78036. * Returns a new Light object, named "name", from the current one.
  78037. * @param name The name of the cloned light
  78038. * @returns the new created light
  78039. */
  78040. clone(name: string): Nullable<Light>;
  78041. /**
  78042. * Serializes the current light into a Serialization object.
  78043. * @returns the serialized object.
  78044. */
  78045. serialize(): any;
  78046. /**
  78047. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78048. * This new light is named "name" and added to the passed scene.
  78049. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78050. * @param name The friendly name of the light
  78051. * @param scene The scene the new light will belong to
  78052. * @returns the constructor function
  78053. */
  78054. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78055. /**
  78056. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78057. * @param parsedLight The JSON representation of the light
  78058. * @param scene The scene to create the parsed light in
  78059. * @returns the created light after parsing
  78060. */
  78061. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78062. private _hookArrayForExcluded;
  78063. private _hookArrayForIncludedOnly;
  78064. private _resyncMeshes;
  78065. /**
  78066. * Forces the meshes to update their light related information in their rendering used effects
  78067. * @hidden Internal Use Only
  78068. */
  78069. _markMeshesAsLightDirty(): void;
  78070. /**
  78071. * Recomputes the cached photometric scale if needed.
  78072. */
  78073. private _computePhotometricScale;
  78074. /**
  78075. * Returns the Photometric Scale according to the light type and intensity mode.
  78076. */
  78077. private _getPhotometricScale;
  78078. /**
  78079. * Reorder the light in the scene according to their defined priority.
  78080. * @hidden Internal Use Only
  78081. */
  78082. _reorderLightsInScene(): void;
  78083. /**
  78084. * Prepares the list of defines specific to the light type.
  78085. * @param defines the list of defines
  78086. * @param lightIndex defines the index of the light for the effect
  78087. */
  78088. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78089. }
  78090. }
  78091. declare module BABYLON {
  78092. /**
  78093. * Interface used to define Action
  78094. */
  78095. export interface IAction {
  78096. /**
  78097. * Trigger for the action
  78098. */
  78099. trigger: number;
  78100. /** Options of the trigger */
  78101. triggerOptions: any;
  78102. /**
  78103. * Gets the trigger parameters
  78104. * @returns the trigger parameters
  78105. */
  78106. getTriggerParameter(): any;
  78107. /**
  78108. * Internal only - executes current action event
  78109. * @hidden
  78110. */
  78111. _executeCurrent(evt?: ActionEvent): void;
  78112. /**
  78113. * Serialize placeholder for child classes
  78114. * @param parent of child
  78115. * @returns the serialized object
  78116. */
  78117. serialize(parent: any): any;
  78118. /**
  78119. * Internal only
  78120. * @hidden
  78121. */
  78122. _prepare(): void;
  78123. /**
  78124. * Internal only - manager for action
  78125. * @hidden
  78126. */
  78127. _actionManager: AbstractActionManager;
  78128. /**
  78129. * Adds action to chain of actions, may be a DoNothingAction
  78130. * @param action defines the next action to execute
  78131. * @returns The action passed in
  78132. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78133. */
  78134. then(action: IAction): IAction;
  78135. }
  78136. /**
  78137. * The action to be carried out following a trigger
  78138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78139. */
  78140. export class Action implements IAction {
  78141. /** the trigger, with or without parameters, for the action */
  78142. triggerOptions: any;
  78143. /**
  78144. * Trigger for the action
  78145. */
  78146. trigger: number;
  78147. /**
  78148. * Internal only - manager for action
  78149. * @hidden
  78150. */
  78151. _actionManager: ActionManager;
  78152. private _nextActiveAction;
  78153. private _child;
  78154. private _condition?;
  78155. private _triggerParameter;
  78156. /**
  78157. * An event triggered prior to action being executed.
  78158. */
  78159. onBeforeExecuteObservable: Observable<Action>;
  78160. /**
  78161. * Creates a new Action
  78162. * @param triggerOptions the trigger, with or without parameters, for the action
  78163. * @param condition an optional determinant of action
  78164. */
  78165. constructor(
  78166. /** the trigger, with or without parameters, for the action */
  78167. triggerOptions: any, condition?: Condition);
  78168. /**
  78169. * Internal only
  78170. * @hidden
  78171. */
  78172. _prepare(): void;
  78173. /**
  78174. * Gets the trigger parameters
  78175. * @returns the trigger parameters
  78176. */
  78177. getTriggerParameter(): any;
  78178. /**
  78179. * Internal only - executes current action event
  78180. * @hidden
  78181. */
  78182. _executeCurrent(evt?: ActionEvent): void;
  78183. /**
  78184. * Execute placeholder for child classes
  78185. * @param evt optional action event
  78186. */
  78187. execute(evt?: ActionEvent): void;
  78188. /**
  78189. * Skips to next active action
  78190. */
  78191. skipToNextActiveAction(): void;
  78192. /**
  78193. * Adds action to chain of actions, may be a DoNothingAction
  78194. * @param action defines the next action to execute
  78195. * @returns The action passed in
  78196. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78197. */
  78198. then(action: Action): Action;
  78199. /**
  78200. * Internal only
  78201. * @hidden
  78202. */
  78203. _getProperty(propertyPath: string): string;
  78204. /**
  78205. * Internal only
  78206. * @hidden
  78207. */
  78208. _getEffectiveTarget(target: any, propertyPath: string): any;
  78209. /**
  78210. * Serialize placeholder for child classes
  78211. * @param parent of child
  78212. * @returns the serialized object
  78213. */
  78214. serialize(parent: any): any;
  78215. /**
  78216. * Internal only called by serialize
  78217. * @hidden
  78218. */
  78219. protected _serialize(serializedAction: any, parent?: any): any;
  78220. /**
  78221. * Internal only
  78222. * @hidden
  78223. */
  78224. static _SerializeValueAsString: (value: any) => string;
  78225. /**
  78226. * Internal only
  78227. * @hidden
  78228. */
  78229. static _GetTargetProperty: (target: Node | Scene) => {
  78230. name: string;
  78231. targetType: string;
  78232. value: string;
  78233. };
  78234. }
  78235. }
  78236. declare module BABYLON {
  78237. /**
  78238. * A Condition applied to an Action
  78239. */
  78240. export class Condition {
  78241. /**
  78242. * Internal only - manager for action
  78243. * @hidden
  78244. */
  78245. _actionManager: ActionManager;
  78246. /**
  78247. * Internal only
  78248. * @hidden
  78249. */
  78250. _evaluationId: number;
  78251. /**
  78252. * Internal only
  78253. * @hidden
  78254. */
  78255. _currentResult: boolean;
  78256. /**
  78257. * Creates a new Condition
  78258. * @param actionManager the manager of the action the condition is applied to
  78259. */
  78260. constructor(actionManager: ActionManager);
  78261. /**
  78262. * Check if the current condition is valid
  78263. * @returns a boolean
  78264. */
  78265. isValid(): boolean;
  78266. /**
  78267. * Internal only
  78268. * @hidden
  78269. */
  78270. _getProperty(propertyPath: string): string;
  78271. /**
  78272. * Internal only
  78273. * @hidden
  78274. */
  78275. _getEffectiveTarget(target: any, propertyPath: string): any;
  78276. /**
  78277. * Serialize placeholder for child classes
  78278. * @returns the serialized object
  78279. */
  78280. serialize(): any;
  78281. /**
  78282. * Internal only
  78283. * @hidden
  78284. */
  78285. protected _serialize(serializedCondition: any): any;
  78286. }
  78287. /**
  78288. * Defines specific conditional operators as extensions of Condition
  78289. */
  78290. export class ValueCondition extends Condition {
  78291. /** path to specify the property of the target the conditional operator uses */
  78292. propertyPath: string;
  78293. /** the value compared by the conditional operator against the current value of the property */
  78294. value: any;
  78295. /** the conditional operator, default ValueCondition.IsEqual */
  78296. operator: number;
  78297. /**
  78298. * Internal only
  78299. * @hidden
  78300. */
  78301. private static _IsEqual;
  78302. /**
  78303. * Internal only
  78304. * @hidden
  78305. */
  78306. private static _IsDifferent;
  78307. /**
  78308. * Internal only
  78309. * @hidden
  78310. */
  78311. private static _IsGreater;
  78312. /**
  78313. * Internal only
  78314. * @hidden
  78315. */
  78316. private static _IsLesser;
  78317. /**
  78318. * returns the number for IsEqual
  78319. */
  78320. static readonly IsEqual: number;
  78321. /**
  78322. * Returns the number for IsDifferent
  78323. */
  78324. static readonly IsDifferent: number;
  78325. /**
  78326. * Returns the number for IsGreater
  78327. */
  78328. static readonly IsGreater: number;
  78329. /**
  78330. * Returns the number for IsLesser
  78331. */
  78332. static readonly IsLesser: number;
  78333. /**
  78334. * Internal only The action manager for the condition
  78335. * @hidden
  78336. */
  78337. _actionManager: ActionManager;
  78338. /**
  78339. * Internal only
  78340. * @hidden
  78341. */
  78342. private _target;
  78343. /**
  78344. * Internal only
  78345. * @hidden
  78346. */
  78347. private _effectiveTarget;
  78348. /**
  78349. * Internal only
  78350. * @hidden
  78351. */
  78352. private _property;
  78353. /**
  78354. * Creates a new ValueCondition
  78355. * @param actionManager manager for the action the condition applies to
  78356. * @param target for the action
  78357. * @param propertyPath path to specify the property of the target the conditional operator uses
  78358. * @param value the value compared by the conditional operator against the current value of the property
  78359. * @param operator the conditional operator, default ValueCondition.IsEqual
  78360. */
  78361. constructor(actionManager: ActionManager, target: any,
  78362. /** path to specify the property of the target the conditional operator uses */
  78363. propertyPath: string,
  78364. /** the value compared by the conditional operator against the current value of the property */
  78365. value: any,
  78366. /** the conditional operator, default ValueCondition.IsEqual */
  78367. operator?: number);
  78368. /**
  78369. * Compares the given value with the property value for the specified conditional operator
  78370. * @returns the result of the comparison
  78371. */
  78372. isValid(): boolean;
  78373. /**
  78374. * Serialize the ValueCondition into a JSON compatible object
  78375. * @returns serialization object
  78376. */
  78377. serialize(): any;
  78378. /**
  78379. * Gets the name of the conditional operator for the ValueCondition
  78380. * @param operator the conditional operator
  78381. * @returns the name
  78382. */
  78383. static GetOperatorName(operator: number): string;
  78384. }
  78385. /**
  78386. * Defines a predicate condition as an extension of Condition
  78387. */
  78388. export class PredicateCondition extends Condition {
  78389. /** defines the predicate function used to validate the condition */
  78390. predicate: () => boolean;
  78391. /**
  78392. * Internal only - manager for action
  78393. * @hidden
  78394. */
  78395. _actionManager: ActionManager;
  78396. /**
  78397. * Creates a new PredicateCondition
  78398. * @param actionManager manager for the action the condition applies to
  78399. * @param predicate defines the predicate function used to validate the condition
  78400. */
  78401. constructor(actionManager: ActionManager,
  78402. /** defines the predicate function used to validate the condition */
  78403. predicate: () => boolean);
  78404. /**
  78405. * @returns the validity of the predicate condition
  78406. */
  78407. isValid(): boolean;
  78408. }
  78409. /**
  78410. * Defines a state condition as an extension of Condition
  78411. */
  78412. export class StateCondition extends Condition {
  78413. /** Value to compare with target state */
  78414. value: string;
  78415. /**
  78416. * Internal only - manager for action
  78417. * @hidden
  78418. */
  78419. _actionManager: ActionManager;
  78420. /**
  78421. * Internal only
  78422. * @hidden
  78423. */
  78424. private _target;
  78425. /**
  78426. * Creates a new StateCondition
  78427. * @param actionManager manager for the action the condition applies to
  78428. * @param target of the condition
  78429. * @param value to compare with target state
  78430. */
  78431. constructor(actionManager: ActionManager, target: any,
  78432. /** Value to compare with target state */
  78433. value: string);
  78434. /**
  78435. * Gets a boolean indicating if the current condition is met
  78436. * @returns the validity of the state
  78437. */
  78438. isValid(): boolean;
  78439. /**
  78440. * Serialize the StateCondition into a JSON compatible object
  78441. * @returns serialization object
  78442. */
  78443. serialize(): any;
  78444. }
  78445. }
  78446. declare module BABYLON {
  78447. /**
  78448. * This defines an action responsible to toggle a boolean once triggered.
  78449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78450. */
  78451. export class SwitchBooleanAction extends Action {
  78452. /**
  78453. * The path to the boolean property in the target object
  78454. */
  78455. propertyPath: string;
  78456. private _target;
  78457. private _effectiveTarget;
  78458. private _property;
  78459. /**
  78460. * Instantiate the action
  78461. * @param triggerOptions defines the trigger options
  78462. * @param target defines the object containing the boolean
  78463. * @param propertyPath defines the path to the boolean property in the target object
  78464. * @param condition defines the trigger related conditions
  78465. */
  78466. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78467. /** @hidden */
  78468. _prepare(): void;
  78469. /**
  78470. * Execute the action toggle the boolean value.
  78471. */
  78472. execute(): void;
  78473. /**
  78474. * Serializes the actions and its related information.
  78475. * @param parent defines the object to serialize in
  78476. * @returns the serialized object
  78477. */
  78478. serialize(parent: any): any;
  78479. }
  78480. /**
  78481. * This defines an action responsible to set a the state field of the target
  78482. * to a desired value once triggered.
  78483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78484. */
  78485. export class SetStateAction extends Action {
  78486. /**
  78487. * The value to store in the state field.
  78488. */
  78489. value: string;
  78490. private _target;
  78491. /**
  78492. * Instantiate the action
  78493. * @param triggerOptions defines the trigger options
  78494. * @param target defines the object containing the state property
  78495. * @param value defines the value to store in the state field
  78496. * @param condition defines the trigger related conditions
  78497. */
  78498. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78499. /**
  78500. * Execute the action and store the value on the target state property.
  78501. */
  78502. execute(): void;
  78503. /**
  78504. * Serializes the actions and its related information.
  78505. * @param parent defines the object to serialize in
  78506. * @returns the serialized object
  78507. */
  78508. serialize(parent: any): any;
  78509. }
  78510. /**
  78511. * This defines an action responsible to set a property of the target
  78512. * to a desired value once triggered.
  78513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78514. */
  78515. export class SetValueAction extends Action {
  78516. /**
  78517. * The path of the property to set in the target.
  78518. */
  78519. propertyPath: string;
  78520. /**
  78521. * The value to set in the property
  78522. */
  78523. value: any;
  78524. private _target;
  78525. private _effectiveTarget;
  78526. private _property;
  78527. /**
  78528. * Instantiate the action
  78529. * @param triggerOptions defines the trigger options
  78530. * @param target defines the object containing the property
  78531. * @param propertyPath defines the path of the property to set in the target
  78532. * @param value defines the value to set in the property
  78533. * @param condition defines the trigger related conditions
  78534. */
  78535. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78536. /** @hidden */
  78537. _prepare(): void;
  78538. /**
  78539. * Execute the action and set the targetted property to the desired value.
  78540. */
  78541. execute(): void;
  78542. /**
  78543. * Serializes the actions and its related information.
  78544. * @param parent defines the object to serialize in
  78545. * @returns the serialized object
  78546. */
  78547. serialize(parent: any): any;
  78548. }
  78549. /**
  78550. * This defines an action responsible to increment the target value
  78551. * to a desired value once triggered.
  78552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78553. */
  78554. export class IncrementValueAction extends Action {
  78555. /**
  78556. * The path of the property to increment in the target.
  78557. */
  78558. propertyPath: string;
  78559. /**
  78560. * The value we should increment the property by.
  78561. */
  78562. value: any;
  78563. private _target;
  78564. private _effectiveTarget;
  78565. private _property;
  78566. /**
  78567. * Instantiate the action
  78568. * @param triggerOptions defines the trigger options
  78569. * @param target defines the object containing the property
  78570. * @param propertyPath defines the path of the property to increment in the target
  78571. * @param value defines the value value we should increment the property by
  78572. * @param condition defines the trigger related conditions
  78573. */
  78574. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78575. /** @hidden */
  78576. _prepare(): void;
  78577. /**
  78578. * Execute the action and increment the target of the value amount.
  78579. */
  78580. execute(): void;
  78581. /**
  78582. * Serializes the actions and its related information.
  78583. * @param parent defines the object to serialize in
  78584. * @returns the serialized object
  78585. */
  78586. serialize(parent: any): any;
  78587. }
  78588. /**
  78589. * This defines an action responsible to start an animation once triggered.
  78590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78591. */
  78592. export class PlayAnimationAction extends Action {
  78593. /**
  78594. * Where the animation should start (animation frame)
  78595. */
  78596. from: number;
  78597. /**
  78598. * Where the animation should stop (animation frame)
  78599. */
  78600. to: number;
  78601. /**
  78602. * Define if the animation should loop or stop after the first play.
  78603. */
  78604. loop?: boolean;
  78605. private _target;
  78606. /**
  78607. * Instantiate the action
  78608. * @param triggerOptions defines the trigger options
  78609. * @param target defines the target animation or animation name
  78610. * @param from defines from where the animation should start (animation frame)
  78611. * @param end defines where the animation should stop (animation frame)
  78612. * @param loop defines if the animation should loop or stop after the first play
  78613. * @param condition defines the trigger related conditions
  78614. */
  78615. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78616. /** @hidden */
  78617. _prepare(): void;
  78618. /**
  78619. * Execute the action and play the animation.
  78620. */
  78621. execute(): void;
  78622. /**
  78623. * Serializes the actions and its related information.
  78624. * @param parent defines the object to serialize in
  78625. * @returns the serialized object
  78626. */
  78627. serialize(parent: any): any;
  78628. }
  78629. /**
  78630. * This defines an action responsible to stop an animation once triggered.
  78631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78632. */
  78633. export class StopAnimationAction extends Action {
  78634. private _target;
  78635. /**
  78636. * Instantiate the action
  78637. * @param triggerOptions defines the trigger options
  78638. * @param target defines the target animation or animation name
  78639. * @param condition defines the trigger related conditions
  78640. */
  78641. constructor(triggerOptions: any, target: any, condition?: Condition);
  78642. /** @hidden */
  78643. _prepare(): void;
  78644. /**
  78645. * Execute the action and stop the animation.
  78646. */
  78647. execute(): void;
  78648. /**
  78649. * Serializes the actions and its related information.
  78650. * @param parent defines the object to serialize in
  78651. * @returns the serialized object
  78652. */
  78653. serialize(parent: any): any;
  78654. }
  78655. /**
  78656. * This defines an action responsible that does nothing once triggered.
  78657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78658. */
  78659. export class DoNothingAction extends Action {
  78660. /**
  78661. * Instantiate the action
  78662. * @param triggerOptions defines the trigger options
  78663. * @param condition defines the trigger related conditions
  78664. */
  78665. constructor(triggerOptions?: any, condition?: Condition);
  78666. /**
  78667. * Execute the action and do nothing.
  78668. */
  78669. execute(): void;
  78670. /**
  78671. * Serializes the actions and its related information.
  78672. * @param parent defines the object to serialize in
  78673. * @returns the serialized object
  78674. */
  78675. serialize(parent: any): any;
  78676. }
  78677. /**
  78678. * This defines an action responsible to trigger several actions once triggered.
  78679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78680. */
  78681. export class CombineAction extends Action {
  78682. /**
  78683. * The list of aggregated animations to run.
  78684. */
  78685. children: Action[];
  78686. /**
  78687. * Instantiate the action
  78688. * @param triggerOptions defines the trigger options
  78689. * @param children defines the list of aggregated animations to run
  78690. * @param condition defines the trigger related conditions
  78691. */
  78692. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78693. /** @hidden */
  78694. _prepare(): void;
  78695. /**
  78696. * Execute the action and executes all the aggregated actions.
  78697. */
  78698. execute(evt: ActionEvent): void;
  78699. /**
  78700. * Serializes the actions and its related information.
  78701. * @param parent defines the object to serialize in
  78702. * @returns the serialized object
  78703. */
  78704. serialize(parent: any): any;
  78705. }
  78706. /**
  78707. * This defines an action responsible to run code (external event) once triggered.
  78708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78709. */
  78710. export class ExecuteCodeAction extends Action {
  78711. /**
  78712. * The callback function to run.
  78713. */
  78714. func: (evt: ActionEvent) => void;
  78715. /**
  78716. * Instantiate the action
  78717. * @param triggerOptions defines the trigger options
  78718. * @param func defines the callback function to run
  78719. * @param condition defines the trigger related conditions
  78720. */
  78721. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78722. /**
  78723. * Execute the action and run the attached code.
  78724. */
  78725. execute(evt: ActionEvent): void;
  78726. }
  78727. /**
  78728. * This defines an action responsible to set the parent property of the target once triggered.
  78729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78730. */
  78731. export class SetParentAction extends Action {
  78732. private _parent;
  78733. private _target;
  78734. /**
  78735. * Instantiate the action
  78736. * @param triggerOptions defines the trigger options
  78737. * @param target defines the target containing the parent property
  78738. * @param parent defines from where the animation should start (animation frame)
  78739. * @param condition defines the trigger related conditions
  78740. */
  78741. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78742. /** @hidden */
  78743. _prepare(): void;
  78744. /**
  78745. * Execute the action and set the parent property.
  78746. */
  78747. execute(): void;
  78748. /**
  78749. * Serializes the actions and its related information.
  78750. * @param parent defines the object to serialize in
  78751. * @returns the serialized object
  78752. */
  78753. serialize(parent: any): any;
  78754. }
  78755. }
  78756. declare module BABYLON {
  78757. /**
  78758. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78759. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78761. */
  78762. export class ActionManager extends AbstractActionManager {
  78763. /**
  78764. * Nothing
  78765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78766. */
  78767. static readonly NothingTrigger: number;
  78768. /**
  78769. * On pick
  78770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78771. */
  78772. static readonly OnPickTrigger: number;
  78773. /**
  78774. * On left pick
  78775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78776. */
  78777. static readonly OnLeftPickTrigger: number;
  78778. /**
  78779. * On right pick
  78780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78781. */
  78782. static readonly OnRightPickTrigger: number;
  78783. /**
  78784. * On center pick
  78785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78786. */
  78787. static readonly OnCenterPickTrigger: number;
  78788. /**
  78789. * On pick down
  78790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78791. */
  78792. static readonly OnPickDownTrigger: number;
  78793. /**
  78794. * On double pick
  78795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78796. */
  78797. static readonly OnDoublePickTrigger: number;
  78798. /**
  78799. * On pick up
  78800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78801. */
  78802. static readonly OnPickUpTrigger: number;
  78803. /**
  78804. * On pick out.
  78805. * This trigger will only be raised if you also declared a OnPickDown
  78806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78807. */
  78808. static readonly OnPickOutTrigger: number;
  78809. /**
  78810. * On long press
  78811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78812. */
  78813. static readonly OnLongPressTrigger: number;
  78814. /**
  78815. * On pointer over
  78816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78817. */
  78818. static readonly OnPointerOverTrigger: number;
  78819. /**
  78820. * On pointer out
  78821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78822. */
  78823. static readonly OnPointerOutTrigger: number;
  78824. /**
  78825. * On every frame
  78826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78827. */
  78828. static readonly OnEveryFrameTrigger: number;
  78829. /**
  78830. * On intersection enter
  78831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78832. */
  78833. static readonly OnIntersectionEnterTrigger: number;
  78834. /**
  78835. * On intersection exit
  78836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78837. */
  78838. static readonly OnIntersectionExitTrigger: number;
  78839. /**
  78840. * On key down
  78841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78842. */
  78843. static readonly OnKeyDownTrigger: number;
  78844. /**
  78845. * On key up
  78846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78847. */
  78848. static readonly OnKeyUpTrigger: number;
  78849. private _scene;
  78850. /**
  78851. * Creates a new action manager
  78852. * @param scene defines the hosting scene
  78853. */
  78854. constructor(scene: Scene);
  78855. /**
  78856. * Releases all associated resources
  78857. */
  78858. dispose(): void;
  78859. /**
  78860. * Gets hosting scene
  78861. * @returns the hosting scene
  78862. */
  78863. getScene(): Scene;
  78864. /**
  78865. * Does this action manager handles actions of any of the given triggers
  78866. * @param triggers defines the triggers to be tested
  78867. * @return a boolean indicating whether one (or more) of the triggers is handled
  78868. */
  78869. hasSpecificTriggers(triggers: number[]): boolean;
  78870. /**
  78871. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78872. * speed.
  78873. * @param triggerA defines the trigger to be tested
  78874. * @param triggerB defines the trigger to be tested
  78875. * @return a boolean indicating whether one (or more) of the triggers is handled
  78876. */
  78877. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78878. /**
  78879. * Does this action manager handles actions of a given trigger
  78880. * @param trigger defines the trigger to be tested
  78881. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78882. * @return whether the trigger is handled
  78883. */
  78884. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78885. /**
  78886. * Does this action manager has pointer triggers
  78887. */
  78888. readonly hasPointerTriggers: boolean;
  78889. /**
  78890. * Does this action manager has pick triggers
  78891. */
  78892. readonly hasPickTriggers: boolean;
  78893. /**
  78894. * Registers an action to this action manager
  78895. * @param action defines the action to be registered
  78896. * @return the action amended (prepared) after registration
  78897. */
  78898. registerAction(action: IAction): Nullable<IAction>;
  78899. /**
  78900. * Unregisters an action to this action manager
  78901. * @param action defines the action to be unregistered
  78902. * @return a boolean indicating whether the action has been unregistered
  78903. */
  78904. unregisterAction(action: IAction): Boolean;
  78905. /**
  78906. * Process a specific trigger
  78907. * @param trigger defines the trigger to process
  78908. * @param evt defines the event details to be processed
  78909. */
  78910. processTrigger(trigger: number, evt?: IActionEvent): void;
  78911. /** @hidden */
  78912. _getEffectiveTarget(target: any, propertyPath: string): any;
  78913. /** @hidden */
  78914. _getProperty(propertyPath: string): string;
  78915. /**
  78916. * Serialize this manager to a JSON object
  78917. * @param name defines the property name to store this manager
  78918. * @returns a JSON representation of this manager
  78919. */
  78920. serialize(name: string): any;
  78921. /**
  78922. * Creates a new ActionManager from a JSON data
  78923. * @param parsedActions defines the JSON data to read from
  78924. * @param object defines the hosting mesh
  78925. * @param scene defines the hosting scene
  78926. */
  78927. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78928. /**
  78929. * Get a trigger name by index
  78930. * @param trigger defines the trigger index
  78931. * @returns a trigger name
  78932. */
  78933. static GetTriggerName(trigger: number): string;
  78934. }
  78935. }
  78936. declare module BABYLON {
  78937. /**
  78938. * Class representing a ray with position and direction
  78939. */
  78940. export class Ray {
  78941. /** origin point */
  78942. origin: Vector3;
  78943. /** direction */
  78944. direction: Vector3;
  78945. /** length of the ray */
  78946. length: number;
  78947. private static readonly TmpVector3;
  78948. private _tmpRay;
  78949. /**
  78950. * Creates a new ray
  78951. * @param origin origin point
  78952. * @param direction direction
  78953. * @param length length of the ray
  78954. */
  78955. constructor(
  78956. /** origin point */
  78957. origin: Vector3,
  78958. /** direction */
  78959. direction: Vector3,
  78960. /** length of the ray */
  78961. length?: number);
  78962. /**
  78963. * Checks if the ray intersects a box
  78964. * @param minimum bound of the box
  78965. * @param maximum bound of the box
  78966. * @param intersectionTreshold extra extend to be added to the box in all direction
  78967. * @returns if the box was hit
  78968. */
  78969. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78970. /**
  78971. * Checks if the ray intersects a box
  78972. * @param box the bounding box to check
  78973. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78974. * @returns if the box was hit
  78975. */
  78976. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78977. /**
  78978. * If the ray hits a sphere
  78979. * @param sphere the bounding sphere to check
  78980. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78981. * @returns true if it hits the sphere
  78982. */
  78983. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78984. /**
  78985. * If the ray hits a triange
  78986. * @param vertex0 triangle vertex
  78987. * @param vertex1 triangle vertex
  78988. * @param vertex2 triangle vertex
  78989. * @returns intersection information if hit
  78990. */
  78991. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78992. /**
  78993. * Checks if ray intersects a plane
  78994. * @param plane the plane to check
  78995. * @returns the distance away it was hit
  78996. */
  78997. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78998. /**
  78999. * Calculate the intercept of a ray on a given axis
  79000. * @param axis to check 'x' | 'y' | 'z'
  79001. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79002. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79003. */
  79004. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79005. /**
  79006. * Checks if ray intersects a mesh
  79007. * @param mesh the mesh to check
  79008. * @param fastCheck if only the bounding box should checked
  79009. * @returns picking info of the intersecton
  79010. */
  79011. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79012. /**
  79013. * Checks if ray intersects a mesh
  79014. * @param meshes the meshes to check
  79015. * @param fastCheck if only the bounding box should checked
  79016. * @param results array to store result in
  79017. * @returns Array of picking infos
  79018. */
  79019. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79020. private _comparePickingInfo;
  79021. private static smallnum;
  79022. private static rayl;
  79023. /**
  79024. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79025. * @param sega the first point of the segment to test the intersection against
  79026. * @param segb the second point of the segment to test the intersection against
  79027. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79028. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79029. */
  79030. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79031. /**
  79032. * Update the ray from viewport position
  79033. * @param x position
  79034. * @param y y position
  79035. * @param viewportWidth viewport width
  79036. * @param viewportHeight viewport height
  79037. * @param world world matrix
  79038. * @param view view matrix
  79039. * @param projection projection matrix
  79040. * @returns this ray updated
  79041. */
  79042. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79043. /**
  79044. * Creates a ray with origin and direction of 0,0,0
  79045. * @returns the new ray
  79046. */
  79047. static Zero(): Ray;
  79048. /**
  79049. * Creates a new ray from screen space and viewport
  79050. * @param x position
  79051. * @param y y position
  79052. * @param viewportWidth viewport width
  79053. * @param viewportHeight viewport height
  79054. * @param world world matrix
  79055. * @param view view matrix
  79056. * @param projection projection matrix
  79057. * @returns new ray
  79058. */
  79059. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79060. /**
  79061. * 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
  79062. * transformed to the given world matrix.
  79063. * @param origin The origin point
  79064. * @param end The end point
  79065. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79066. * @returns the new ray
  79067. */
  79068. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79069. /**
  79070. * Transforms a ray by a matrix
  79071. * @param ray ray to transform
  79072. * @param matrix matrix to apply
  79073. * @returns the resulting new ray
  79074. */
  79075. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79076. /**
  79077. * Transforms a ray by a matrix
  79078. * @param ray ray to transform
  79079. * @param matrix matrix to apply
  79080. * @param result ray to store result in
  79081. */
  79082. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79083. /**
  79084. * Unproject a ray from screen space to object space
  79085. * @param sourceX defines the screen space x coordinate to use
  79086. * @param sourceY defines the screen space y coordinate to use
  79087. * @param viewportWidth defines the current width of the viewport
  79088. * @param viewportHeight defines the current height of the viewport
  79089. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79090. * @param view defines the view matrix to use
  79091. * @param projection defines the projection matrix to use
  79092. */
  79093. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79094. }
  79095. /**
  79096. * Type used to define predicate used to select faces when a mesh intersection is detected
  79097. */
  79098. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79099. interface Scene {
  79100. /** @hidden */
  79101. _tempPickingRay: Nullable<Ray>;
  79102. /** @hidden */
  79103. _cachedRayForTransform: Ray;
  79104. /** @hidden */
  79105. _pickWithRayInverseMatrix: Matrix;
  79106. /** @hidden */
  79107. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79108. /** @hidden */
  79109. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79110. }
  79111. }
  79112. declare module BABYLON {
  79113. /**
  79114. * Groups all the scene component constants in one place to ease maintenance.
  79115. * @hidden
  79116. */
  79117. export class SceneComponentConstants {
  79118. static readonly NAME_EFFECTLAYER: string;
  79119. static readonly NAME_LAYER: string;
  79120. static readonly NAME_LENSFLARESYSTEM: string;
  79121. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79122. static readonly NAME_PARTICLESYSTEM: string;
  79123. static readonly NAME_GAMEPAD: string;
  79124. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79125. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79126. static readonly NAME_DEPTHRENDERER: string;
  79127. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79128. static readonly NAME_SPRITE: string;
  79129. static readonly NAME_OUTLINERENDERER: string;
  79130. static readonly NAME_PROCEDURALTEXTURE: string;
  79131. static readonly NAME_SHADOWGENERATOR: string;
  79132. static readonly NAME_OCTREE: string;
  79133. static readonly NAME_PHYSICSENGINE: string;
  79134. static readonly NAME_AUDIO: string;
  79135. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79136. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79137. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79138. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79139. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79140. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79141. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79142. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79143. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79144. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79145. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79146. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79147. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79148. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79149. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79150. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79151. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79152. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79153. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79154. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79155. static readonly STEP_AFTERRENDER_AUDIO: number;
  79156. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79157. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79158. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79159. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79160. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79161. static readonly STEP_POINTERMOVE_SPRITE: number;
  79162. static readonly STEP_POINTERDOWN_SPRITE: number;
  79163. static readonly STEP_POINTERUP_SPRITE: number;
  79164. }
  79165. /**
  79166. * This represents a scene component.
  79167. *
  79168. * This is used to decouple the dependency the scene is having on the different workloads like
  79169. * layers, post processes...
  79170. */
  79171. export interface ISceneComponent {
  79172. /**
  79173. * The name of the component. Each component must have a unique name.
  79174. */
  79175. name: string;
  79176. /**
  79177. * The scene the component belongs to.
  79178. */
  79179. scene: Scene;
  79180. /**
  79181. * Register the component to one instance of a scene.
  79182. */
  79183. register(): void;
  79184. /**
  79185. * Rebuilds the elements related to this component in case of
  79186. * context lost for instance.
  79187. */
  79188. rebuild(): void;
  79189. /**
  79190. * Disposes the component and the associated ressources.
  79191. */
  79192. dispose(): void;
  79193. }
  79194. /**
  79195. * This represents a SERIALIZABLE scene component.
  79196. *
  79197. * This extends Scene Component to add Serialization methods on top.
  79198. */
  79199. export interface ISceneSerializableComponent extends ISceneComponent {
  79200. /**
  79201. * Adds all the elements from the container to the scene
  79202. * @param container the container holding the elements
  79203. */
  79204. addFromContainer(container: AbstractScene): void;
  79205. /**
  79206. * Removes all the elements in the container from the scene
  79207. * @param container contains the elements to remove
  79208. * @param dispose if the removed element should be disposed (default: false)
  79209. */
  79210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79211. /**
  79212. * Serializes the component data to the specified json object
  79213. * @param serializationObject The object to serialize to
  79214. */
  79215. serialize(serializationObject: any): void;
  79216. }
  79217. /**
  79218. * Strong typing of a Mesh related stage step action
  79219. */
  79220. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79221. /**
  79222. * Strong typing of a Evaluate Sub Mesh related stage step action
  79223. */
  79224. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79225. /**
  79226. * Strong typing of a Active Mesh related stage step action
  79227. */
  79228. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79229. /**
  79230. * Strong typing of a Camera related stage step action
  79231. */
  79232. export type CameraStageAction = (camera: Camera) => void;
  79233. /**
  79234. * Strong typing of a Camera Frame buffer related stage step action
  79235. */
  79236. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79237. /**
  79238. * Strong typing of a Render Target related stage step action
  79239. */
  79240. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79241. /**
  79242. * Strong typing of a RenderingGroup related stage step action
  79243. */
  79244. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79245. /**
  79246. * Strong typing of a Mesh Render related stage step action
  79247. */
  79248. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79249. /**
  79250. * Strong typing of a simple stage step action
  79251. */
  79252. export type SimpleStageAction = () => void;
  79253. /**
  79254. * Strong typing of a render target action.
  79255. */
  79256. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79257. /**
  79258. * Strong typing of a pointer move action.
  79259. */
  79260. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79261. /**
  79262. * Strong typing of a pointer up/down action.
  79263. */
  79264. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79265. /**
  79266. * Representation of a stage in the scene (Basically a list of ordered steps)
  79267. * @hidden
  79268. */
  79269. export class Stage<T extends Function> extends Array<{
  79270. index: number;
  79271. component: ISceneComponent;
  79272. action: T;
  79273. }> {
  79274. /**
  79275. * Hide ctor from the rest of the world.
  79276. * @param items The items to add.
  79277. */
  79278. private constructor();
  79279. /**
  79280. * Creates a new Stage.
  79281. * @returns A new instance of a Stage
  79282. */
  79283. static Create<T extends Function>(): Stage<T>;
  79284. /**
  79285. * Registers a step in an ordered way in the targeted stage.
  79286. * @param index Defines the position to register the step in
  79287. * @param component Defines the component attached to the step
  79288. * @param action Defines the action to launch during the step
  79289. */
  79290. registerStep(index: number, component: ISceneComponent, action: T): void;
  79291. /**
  79292. * Clears all the steps from the stage.
  79293. */
  79294. clear(): void;
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. interface Scene {
  79299. /** @hidden */
  79300. _pointerOverSprite: Nullable<Sprite>;
  79301. /** @hidden */
  79302. _pickedDownSprite: Nullable<Sprite>;
  79303. /** @hidden */
  79304. _tempSpritePickingRay: Nullable<Ray>;
  79305. /**
  79306. * All of the sprite managers added to this scene
  79307. * @see http://doc.babylonjs.com/babylon101/sprites
  79308. */
  79309. spriteManagers: Array<ISpriteManager>;
  79310. /**
  79311. * An event triggered when sprites rendering is about to start
  79312. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79313. */
  79314. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79315. /**
  79316. * An event triggered when sprites rendering is done
  79317. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79318. */
  79319. onAfterSpritesRenderingObservable: Observable<Scene>;
  79320. /** @hidden */
  79321. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79322. /** Launch a ray to try to pick a sprite in the scene
  79323. * @param x position on screen
  79324. * @param y position on screen
  79325. * @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
  79326. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79327. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79328. * @returns a PickingInfo
  79329. */
  79330. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79331. /** Use the given ray to pick a sprite in the scene
  79332. * @param ray The ray (in world space) to use to pick meshes
  79333. * @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
  79334. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79335. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79336. * @returns a PickingInfo
  79337. */
  79338. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79339. /** @hidden */
  79340. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79341. /** Launch a ray to try to pick sprites in the scene
  79342. * @param x position on screen
  79343. * @param y position on screen
  79344. * @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
  79345. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79346. * @returns a PickingInfo array
  79347. */
  79348. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79349. /** Use the given ray to pick sprites in the scene
  79350. * @param ray The ray (in world space) to use to pick meshes
  79351. * @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
  79352. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79353. * @returns a PickingInfo array
  79354. */
  79355. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79356. /**
  79357. * Force the sprite under the pointer
  79358. * @param sprite defines the sprite to use
  79359. */
  79360. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79361. /**
  79362. * Gets the sprite under the pointer
  79363. * @returns a Sprite or null if no sprite is under the pointer
  79364. */
  79365. getPointerOverSprite(): Nullable<Sprite>;
  79366. }
  79367. /**
  79368. * Defines the sprite scene component responsible to manage sprites
  79369. * in a given scene.
  79370. */
  79371. export class SpriteSceneComponent implements ISceneComponent {
  79372. /**
  79373. * The component name helpfull to identify the component in the list of scene components.
  79374. */
  79375. readonly name: string;
  79376. /**
  79377. * The scene the component belongs to.
  79378. */
  79379. scene: Scene;
  79380. /** @hidden */
  79381. private _spritePredicate;
  79382. /**
  79383. * Creates a new instance of the component for the given scene
  79384. * @param scene Defines the scene to register the component in
  79385. */
  79386. constructor(scene: Scene);
  79387. /**
  79388. * Registers the component in a given scene
  79389. */
  79390. register(): void;
  79391. /**
  79392. * Rebuilds the elements related to this component in case of
  79393. * context lost for instance.
  79394. */
  79395. rebuild(): void;
  79396. /**
  79397. * Disposes the component and the associated ressources.
  79398. */
  79399. dispose(): void;
  79400. private _pickSpriteButKeepRay;
  79401. private _pointerMove;
  79402. private _pointerDown;
  79403. private _pointerUp;
  79404. }
  79405. }
  79406. declare module BABYLON {
  79407. /** @hidden */
  79408. export var fogFragmentDeclaration: {
  79409. name: string;
  79410. shader: string;
  79411. };
  79412. }
  79413. declare module BABYLON {
  79414. /** @hidden */
  79415. export var fogFragment: {
  79416. name: string;
  79417. shader: string;
  79418. };
  79419. }
  79420. declare module BABYLON {
  79421. /** @hidden */
  79422. export var spritesPixelShader: {
  79423. name: string;
  79424. shader: string;
  79425. };
  79426. }
  79427. declare module BABYLON {
  79428. /** @hidden */
  79429. export var fogVertexDeclaration: {
  79430. name: string;
  79431. shader: string;
  79432. };
  79433. }
  79434. declare module BABYLON {
  79435. /** @hidden */
  79436. export var spritesVertexShader: {
  79437. name: string;
  79438. shader: string;
  79439. };
  79440. }
  79441. declare module BABYLON {
  79442. /**
  79443. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79444. */
  79445. export interface ISpriteManager extends IDisposable {
  79446. /**
  79447. * Restricts the camera to viewing objects with the same layerMask.
  79448. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79449. */
  79450. layerMask: number;
  79451. /**
  79452. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79453. */
  79454. isPickable: boolean;
  79455. /**
  79456. * Specifies the rendering group id for this mesh (0 by default)
  79457. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79458. */
  79459. renderingGroupId: number;
  79460. /**
  79461. * Defines the list of sprites managed by the manager.
  79462. */
  79463. sprites: Array<Sprite>;
  79464. /**
  79465. * Tests the intersection of a sprite with a specific ray.
  79466. * @param ray The ray we are sending to test the collision
  79467. * @param camera The camera space we are sending rays in
  79468. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79469. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79470. * @returns picking info or null.
  79471. */
  79472. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79473. /**
  79474. * Intersects the sprites with a ray
  79475. * @param ray defines the ray to intersect with
  79476. * @param camera defines the current active camera
  79477. * @param predicate defines a predicate used to select candidate sprites
  79478. * @returns null if no hit or a PickingInfo array
  79479. */
  79480. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79481. /**
  79482. * Renders the list of sprites on screen.
  79483. */
  79484. render(): void;
  79485. }
  79486. /**
  79487. * Class used to manage multiple sprites on the same spritesheet
  79488. * @see http://doc.babylonjs.com/babylon101/sprites
  79489. */
  79490. export class SpriteManager implements ISpriteManager {
  79491. /** defines the manager's name */
  79492. name: string;
  79493. /** Gets the list of sprites */
  79494. sprites: Sprite[];
  79495. /** Gets or sets the rendering group id (0 by default) */
  79496. renderingGroupId: number;
  79497. /** Gets or sets camera layer mask */
  79498. layerMask: number;
  79499. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79500. fogEnabled: boolean;
  79501. /** Gets or sets a boolean indicating if the sprites are pickable */
  79502. isPickable: boolean;
  79503. /** Defines the default width of a cell in the spritesheet */
  79504. cellWidth: number;
  79505. /** Defines the default height of a cell in the spritesheet */
  79506. cellHeight: number;
  79507. /** Associative array from JSON sprite data file */
  79508. private _cellData;
  79509. /** Array of sprite names from JSON sprite data file */
  79510. private _spriteMap;
  79511. /** True when packed cell data from JSON file is ready*/
  79512. private _packedAndReady;
  79513. /**
  79514. * An event triggered when the manager is disposed.
  79515. */
  79516. onDisposeObservable: Observable<SpriteManager>;
  79517. private _onDisposeObserver;
  79518. /**
  79519. * Callback called when the manager is disposed
  79520. */
  79521. onDispose: () => void;
  79522. private _capacity;
  79523. private _fromPacked;
  79524. private _spriteTexture;
  79525. private _epsilon;
  79526. private _scene;
  79527. private _vertexData;
  79528. private _buffer;
  79529. private _vertexBuffers;
  79530. private _indexBuffer;
  79531. private _effectBase;
  79532. private _effectFog;
  79533. /**
  79534. * Gets or sets the spritesheet texture
  79535. */
  79536. texture: Texture;
  79537. /**
  79538. * Creates a new sprite manager
  79539. * @param name defines the manager's name
  79540. * @param imgUrl defines the sprite sheet url
  79541. * @param capacity defines the maximum allowed number of sprites
  79542. * @param cellSize defines the size of a sprite cell
  79543. * @param scene defines the hosting scene
  79544. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79545. * @param samplingMode defines the smapling mode to use with spritesheet
  79546. * @param fromPacked set to false; do not alter
  79547. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79548. */
  79549. constructor(
  79550. /** defines the manager's name */
  79551. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79552. private _makePacked;
  79553. private _appendSpriteVertex;
  79554. /**
  79555. * Intersects the sprites with a ray
  79556. * @param ray defines the ray to intersect with
  79557. * @param camera defines the current active camera
  79558. * @param predicate defines a predicate used to select candidate sprites
  79559. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79560. * @returns null if no hit or a PickingInfo
  79561. */
  79562. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79563. /**
  79564. * Intersects the sprites with a ray
  79565. * @param ray defines the ray to intersect with
  79566. * @param camera defines the current active camera
  79567. * @param predicate defines a predicate used to select candidate sprites
  79568. * @returns null if no hit or a PickingInfo array
  79569. */
  79570. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79571. /**
  79572. * Render all child sprites
  79573. */
  79574. render(): void;
  79575. /**
  79576. * Release associated resources
  79577. */
  79578. dispose(): void;
  79579. }
  79580. }
  79581. declare module BABYLON {
  79582. /**
  79583. * Class used to represent a sprite
  79584. * @see http://doc.babylonjs.com/babylon101/sprites
  79585. */
  79586. export class Sprite {
  79587. /** defines the name */
  79588. name: string;
  79589. /** Gets or sets the current world position */
  79590. position: Vector3;
  79591. /** Gets or sets the main color */
  79592. color: Color4;
  79593. /** Gets or sets the width */
  79594. width: number;
  79595. /** Gets or sets the height */
  79596. height: number;
  79597. /** Gets or sets rotation angle */
  79598. angle: number;
  79599. /** Gets or sets the cell index in the sprite sheet */
  79600. cellIndex: number;
  79601. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79602. cellRef: string;
  79603. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79604. invertU: number;
  79605. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79606. invertV: number;
  79607. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79608. disposeWhenFinishedAnimating: boolean;
  79609. /** Gets the list of attached animations */
  79610. animations: Animation[];
  79611. /** Gets or sets a boolean indicating if the sprite can be picked */
  79612. isPickable: boolean;
  79613. /**
  79614. * Gets or sets the associated action manager
  79615. */
  79616. actionManager: Nullable<ActionManager>;
  79617. private _animationStarted;
  79618. private _loopAnimation;
  79619. private _fromIndex;
  79620. private _toIndex;
  79621. private _delay;
  79622. private _direction;
  79623. private _manager;
  79624. private _time;
  79625. private _onAnimationEnd;
  79626. /**
  79627. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79628. */
  79629. isVisible: boolean;
  79630. /**
  79631. * Gets or sets the sprite size
  79632. */
  79633. size: number;
  79634. /**
  79635. * Creates a new Sprite
  79636. * @param name defines the name
  79637. * @param manager defines the manager
  79638. */
  79639. constructor(
  79640. /** defines the name */
  79641. name: string, manager: ISpriteManager);
  79642. /**
  79643. * Starts an animation
  79644. * @param from defines the initial key
  79645. * @param to defines the end key
  79646. * @param loop defines if the animation must loop
  79647. * @param delay defines the start delay (in ms)
  79648. * @param onAnimationEnd defines a callback to call when animation ends
  79649. */
  79650. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79651. /** Stops current animation (if any) */
  79652. stopAnimation(): void;
  79653. /** @hidden */
  79654. _animate(deltaTime: number): void;
  79655. /** Release associated resources */
  79656. dispose(): void;
  79657. }
  79658. }
  79659. declare module BABYLON {
  79660. /**
  79661. * Information about the result of picking within a scene
  79662. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79663. */
  79664. export class PickingInfo {
  79665. /** @hidden */
  79666. _pickingUnavailable: boolean;
  79667. /**
  79668. * If the pick collided with an object
  79669. */
  79670. hit: boolean;
  79671. /**
  79672. * Distance away where the pick collided
  79673. */
  79674. distance: number;
  79675. /**
  79676. * The location of pick collision
  79677. */
  79678. pickedPoint: Nullable<Vector3>;
  79679. /**
  79680. * The mesh corresponding the the pick collision
  79681. */
  79682. pickedMesh: Nullable<AbstractMesh>;
  79683. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79684. bu: number;
  79685. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79686. bv: number;
  79687. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79688. faceId: number;
  79689. /** Id of the the submesh that was picked */
  79690. subMeshId: number;
  79691. /** If a sprite was picked, this will be the sprite the pick collided with */
  79692. pickedSprite: Nullable<Sprite>;
  79693. /**
  79694. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79695. */
  79696. originMesh: Nullable<AbstractMesh>;
  79697. /**
  79698. * The ray that was used to perform the picking.
  79699. */
  79700. ray: Nullable<Ray>;
  79701. /**
  79702. * Gets the normal correspodning to the face the pick collided with
  79703. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79704. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79705. * @returns The normal correspodning to the face the pick collided with
  79706. */
  79707. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79708. /**
  79709. * Gets the texture coordinates of where the pick occured
  79710. * @returns the vector containing the coordnates of the texture
  79711. */
  79712. getTextureCoordinates(): Nullable<Vector2>;
  79713. }
  79714. }
  79715. declare module BABYLON {
  79716. /**
  79717. * Gather the list of pointer event types as constants.
  79718. */
  79719. export class PointerEventTypes {
  79720. /**
  79721. * 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.
  79722. */
  79723. static readonly POINTERDOWN: number;
  79724. /**
  79725. * The pointerup event is fired when a pointer is no longer active.
  79726. */
  79727. static readonly POINTERUP: number;
  79728. /**
  79729. * The pointermove event is fired when a pointer changes coordinates.
  79730. */
  79731. static readonly POINTERMOVE: number;
  79732. /**
  79733. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79734. */
  79735. static readonly POINTERWHEEL: number;
  79736. /**
  79737. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79738. */
  79739. static readonly POINTERPICK: number;
  79740. /**
  79741. * The pointertap event is fired when a the object has been touched and released without drag.
  79742. */
  79743. static readonly POINTERTAP: number;
  79744. /**
  79745. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79746. */
  79747. static readonly POINTERDOUBLETAP: number;
  79748. }
  79749. /**
  79750. * Base class of pointer info types.
  79751. */
  79752. export class PointerInfoBase {
  79753. /**
  79754. * Defines the type of event (PointerEventTypes)
  79755. */
  79756. type: number;
  79757. /**
  79758. * Defines the related dom event
  79759. */
  79760. event: PointerEvent | MouseWheelEvent;
  79761. /**
  79762. * Instantiates the base class of pointers info.
  79763. * @param type Defines the type of event (PointerEventTypes)
  79764. * @param event Defines the related dom event
  79765. */
  79766. constructor(
  79767. /**
  79768. * Defines the type of event (PointerEventTypes)
  79769. */
  79770. type: number,
  79771. /**
  79772. * Defines the related dom event
  79773. */
  79774. event: PointerEvent | MouseWheelEvent);
  79775. }
  79776. /**
  79777. * This class is used to store pointer related info for the onPrePointerObservable event.
  79778. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79779. */
  79780. export class PointerInfoPre extends PointerInfoBase {
  79781. /**
  79782. * Ray from a pointer if availible (eg. 6dof controller)
  79783. */
  79784. ray: Nullable<Ray>;
  79785. /**
  79786. * Defines the local position of the pointer on the canvas.
  79787. */
  79788. localPosition: Vector2;
  79789. /**
  79790. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79791. */
  79792. skipOnPointerObservable: boolean;
  79793. /**
  79794. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79795. * @param type Defines the type of event (PointerEventTypes)
  79796. * @param event Defines the related dom event
  79797. * @param localX Defines the local x coordinates of the pointer when the event occured
  79798. * @param localY Defines the local y coordinates of the pointer when the event occured
  79799. */
  79800. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79801. }
  79802. /**
  79803. * This type contains all the data related to a pointer event in Babylon.js.
  79804. * 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.
  79805. */
  79806. export class PointerInfo extends PointerInfoBase {
  79807. /**
  79808. * Defines the picking info associated to the info (if any)\
  79809. */
  79810. pickInfo: Nullable<PickingInfo>;
  79811. /**
  79812. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79813. * @param type Defines the type of event (PointerEventTypes)
  79814. * @param event Defines the related dom event
  79815. * @param pickInfo Defines the picking info associated to the info (if any)\
  79816. */
  79817. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79818. /**
  79819. * Defines the picking info associated to the info (if any)\
  79820. */
  79821. pickInfo: Nullable<PickingInfo>);
  79822. }
  79823. /**
  79824. * Data relating to a touch event on the screen.
  79825. */
  79826. export interface PointerTouch {
  79827. /**
  79828. * X coordinate of touch.
  79829. */
  79830. x: number;
  79831. /**
  79832. * Y coordinate of touch.
  79833. */
  79834. y: number;
  79835. /**
  79836. * Id of touch. Unique for each finger.
  79837. */
  79838. pointerId: number;
  79839. /**
  79840. * Event type passed from DOM.
  79841. */
  79842. type: any;
  79843. }
  79844. }
  79845. declare module BABYLON {
  79846. /**
  79847. * Manage the mouse inputs to control the movement of a free camera.
  79848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79849. */
  79850. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79851. /**
  79852. * Define if touch is enabled in the mouse input
  79853. */
  79854. touchEnabled: boolean;
  79855. /**
  79856. * Defines the camera the input is attached to.
  79857. */
  79858. camera: FreeCamera;
  79859. /**
  79860. * Defines the buttons associated with the input to handle camera move.
  79861. */
  79862. buttons: number[];
  79863. /**
  79864. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79865. */
  79866. angularSensibility: number;
  79867. private _pointerInput;
  79868. private _onMouseMove;
  79869. private _observer;
  79870. private previousPosition;
  79871. /**
  79872. * Observable for when a pointer move event occurs containing the move offset
  79873. */
  79874. onPointerMovedObservable: Observable<{
  79875. offsetX: number;
  79876. offsetY: number;
  79877. }>;
  79878. /**
  79879. * @hidden
  79880. * If the camera should be rotated automatically based on pointer movement
  79881. */
  79882. _allowCameraRotation: boolean;
  79883. /**
  79884. * Manage the mouse inputs to control the movement of a free camera.
  79885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79886. * @param touchEnabled Defines if touch is enabled or not
  79887. */
  79888. constructor(
  79889. /**
  79890. * Define if touch is enabled in the mouse input
  79891. */
  79892. touchEnabled?: boolean);
  79893. /**
  79894. * Attach the input controls to a specific dom element to get the input from.
  79895. * @param element Defines the element the controls should be listened from
  79896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79897. */
  79898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79899. /**
  79900. * Called on JS contextmenu event.
  79901. * Override this method to provide functionality.
  79902. */
  79903. protected onContextMenu(evt: PointerEvent): void;
  79904. /**
  79905. * Detach the current controls from the specified dom element.
  79906. * @param element Defines the element to stop listening the inputs from
  79907. */
  79908. detachControl(element: Nullable<HTMLElement>): void;
  79909. /**
  79910. * Gets the class name of the current intput.
  79911. * @returns the class name
  79912. */
  79913. getClassName(): string;
  79914. /**
  79915. * Get the friendly name associated with the input class.
  79916. * @returns the input friendly name
  79917. */
  79918. getSimpleName(): string;
  79919. }
  79920. }
  79921. declare module BABYLON {
  79922. /**
  79923. * Manage the touch inputs to control the movement of a free camera.
  79924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79925. */
  79926. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79927. /**
  79928. * Defines the camera the input is attached to.
  79929. */
  79930. camera: FreeCamera;
  79931. /**
  79932. * Defines the touch sensibility for rotation.
  79933. * The higher the faster.
  79934. */
  79935. touchAngularSensibility: number;
  79936. /**
  79937. * Defines the touch sensibility for move.
  79938. * The higher the faster.
  79939. */
  79940. touchMoveSensibility: number;
  79941. private _offsetX;
  79942. private _offsetY;
  79943. private _pointerPressed;
  79944. private _pointerInput;
  79945. private _observer;
  79946. private _onLostFocus;
  79947. /**
  79948. * Attach the input controls to a specific dom element to get the input from.
  79949. * @param element Defines the element the controls should be listened from
  79950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79951. */
  79952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79953. /**
  79954. * Detach the current controls from the specified dom element.
  79955. * @param element Defines the element to stop listening the inputs from
  79956. */
  79957. detachControl(element: Nullable<HTMLElement>): void;
  79958. /**
  79959. * Update the current camera state depending on the inputs that have been used this frame.
  79960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79961. */
  79962. checkInputs(): void;
  79963. /**
  79964. * Gets the class name of the current intput.
  79965. * @returns the class name
  79966. */
  79967. getClassName(): string;
  79968. /**
  79969. * Get the friendly name associated with the input class.
  79970. * @returns the input friendly name
  79971. */
  79972. getSimpleName(): string;
  79973. }
  79974. }
  79975. declare module BABYLON {
  79976. /**
  79977. * Default Inputs manager for the FreeCamera.
  79978. * It groups all the default supported inputs for ease of use.
  79979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79980. */
  79981. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79982. /**
  79983. * @hidden
  79984. */
  79985. _mouseInput: Nullable<FreeCameraMouseInput>;
  79986. /**
  79987. * Instantiates a new FreeCameraInputsManager.
  79988. * @param camera Defines the camera the inputs belong to
  79989. */
  79990. constructor(camera: FreeCamera);
  79991. /**
  79992. * Add keyboard input support to the input manager.
  79993. * @returns the current input manager
  79994. */
  79995. addKeyboard(): FreeCameraInputsManager;
  79996. /**
  79997. * Add mouse input support to the input manager.
  79998. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79999. * @returns the current input manager
  80000. */
  80001. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80002. /**
  80003. * Removes the mouse input support from the manager
  80004. * @returns the current input manager
  80005. */
  80006. removeMouse(): FreeCameraInputsManager;
  80007. /**
  80008. * Add touch input support to the input manager.
  80009. * @returns the current input manager
  80010. */
  80011. addTouch(): FreeCameraInputsManager;
  80012. /**
  80013. * Remove all attached input methods from a camera
  80014. */
  80015. clear(): void;
  80016. }
  80017. }
  80018. declare module BABYLON {
  80019. /**
  80020. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80021. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80022. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80023. */
  80024. export class FreeCamera extends TargetCamera {
  80025. /**
  80026. * Define the collision ellipsoid of the camera.
  80027. * This is helpful to simulate a camera body like the player body around the camera
  80028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80029. */
  80030. ellipsoid: Vector3;
  80031. /**
  80032. * Define an offset for the position of the ellipsoid around the camera.
  80033. * This can be helpful to determine the center of the body near the gravity center of the body
  80034. * instead of its head.
  80035. */
  80036. ellipsoidOffset: Vector3;
  80037. /**
  80038. * Enable or disable collisions of the camera with the rest of the scene objects.
  80039. */
  80040. checkCollisions: boolean;
  80041. /**
  80042. * Enable or disable gravity on the camera.
  80043. */
  80044. applyGravity: boolean;
  80045. /**
  80046. * Define the input manager associated to the camera.
  80047. */
  80048. inputs: FreeCameraInputsManager;
  80049. /**
  80050. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80051. * Higher values reduce sensitivity.
  80052. */
  80053. /**
  80054. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80055. * Higher values reduce sensitivity.
  80056. */
  80057. angularSensibility: number;
  80058. /**
  80059. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80060. */
  80061. keysUp: number[];
  80062. /**
  80063. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80064. */
  80065. keysDown: number[];
  80066. /**
  80067. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80068. */
  80069. keysLeft: number[];
  80070. /**
  80071. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80072. */
  80073. keysRight: number[];
  80074. /**
  80075. * Event raised when the camera collide with a mesh in the scene.
  80076. */
  80077. onCollide: (collidedMesh: AbstractMesh) => void;
  80078. private _collider;
  80079. private _needMoveForGravity;
  80080. private _oldPosition;
  80081. private _diffPosition;
  80082. private _newPosition;
  80083. /** @hidden */
  80084. _localDirection: Vector3;
  80085. /** @hidden */
  80086. _transformedDirection: Vector3;
  80087. /**
  80088. * Instantiates a Free Camera.
  80089. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80090. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80091. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80092. * @param name Define the name of the camera in the scene
  80093. * @param position Define the start position of the camera in the scene
  80094. * @param scene Define the scene the camera belongs to
  80095. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80096. */
  80097. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80098. /**
  80099. * Attached controls to the current camera.
  80100. * @param element Defines the element the controls should be listened from
  80101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80102. */
  80103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80104. /**
  80105. * Detach the current controls from the camera.
  80106. * The camera will stop reacting to inputs.
  80107. * @param element Defines the element to stop listening the inputs from
  80108. */
  80109. detachControl(element: HTMLElement): void;
  80110. private _collisionMask;
  80111. /**
  80112. * Define a collision mask to limit the list of object the camera can collide with
  80113. */
  80114. collisionMask: number;
  80115. /** @hidden */
  80116. _collideWithWorld(displacement: Vector3): void;
  80117. private _onCollisionPositionChange;
  80118. /** @hidden */
  80119. _checkInputs(): void;
  80120. /** @hidden */
  80121. _decideIfNeedsToMove(): boolean;
  80122. /** @hidden */
  80123. _updatePosition(): void;
  80124. /**
  80125. * Destroy the camera and release the current resources hold by it.
  80126. */
  80127. dispose(): void;
  80128. /**
  80129. * Gets the current object class name.
  80130. * @return the class name
  80131. */
  80132. getClassName(): string;
  80133. }
  80134. }
  80135. declare module BABYLON {
  80136. /**
  80137. * Represents a gamepad control stick position
  80138. */
  80139. export class StickValues {
  80140. /**
  80141. * The x component of the control stick
  80142. */
  80143. x: number;
  80144. /**
  80145. * The y component of the control stick
  80146. */
  80147. y: number;
  80148. /**
  80149. * Initializes the gamepad x and y control stick values
  80150. * @param x The x component of the gamepad control stick value
  80151. * @param y The y component of the gamepad control stick value
  80152. */
  80153. constructor(
  80154. /**
  80155. * The x component of the control stick
  80156. */
  80157. x: number,
  80158. /**
  80159. * The y component of the control stick
  80160. */
  80161. y: number);
  80162. }
  80163. /**
  80164. * An interface which manages callbacks for gamepad button changes
  80165. */
  80166. export interface GamepadButtonChanges {
  80167. /**
  80168. * Called when a gamepad has been changed
  80169. */
  80170. changed: boolean;
  80171. /**
  80172. * Called when a gamepad press event has been triggered
  80173. */
  80174. pressChanged: boolean;
  80175. /**
  80176. * Called when a touch event has been triggered
  80177. */
  80178. touchChanged: boolean;
  80179. /**
  80180. * Called when a value has changed
  80181. */
  80182. valueChanged: boolean;
  80183. }
  80184. /**
  80185. * Represents a gamepad
  80186. */
  80187. export class Gamepad {
  80188. /**
  80189. * The id of the gamepad
  80190. */
  80191. id: string;
  80192. /**
  80193. * The index of the gamepad
  80194. */
  80195. index: number;
  80196. /**
  80197. * The browser gamepad
  80198. */
  80199. browserGamepad: any;
  80200. /**
  80201. * Specifies what type of gamepad this represents
  80202. */
  80203. type: number;
  80204. private _leftStick;
  80205. private _rightStick;
  80206. /** @hidden */
  80207. _isConnected: boolean;
  80208. private _leftStickAxisX;
  80209. private _leftStickAxisY;
  80210. private _rightStickAxisX;
  80211. private _rightStickAxisY;
  80212. /**
  80213. * Triggered when the left control stick has been changed
  80214. */
  80215. private _onleftstickchanged;
  80216. /**
  80217. * Triggered when the right control stick has been changed
  80218. */
  80219. private _onrightstickchanged;
  80220. /**
  80221. * Represents a gamepad controller
  80222. */
  80223. static GAMEPAD: number;
  80224. /**
  80225. * Represents a generic controller
  80226. */
  80227. static GENERIC: number;
  80228. /**
  80229. * Represents an XBox controller
  80230. */
  80231. static XBOX: number;
  80232. /**
  80233. * Represents a pose-enabled controller
  80234. */
  80235. static POSE_ENABLED: number;
  80236. /**
  80237. * Represents an Dual Shock controller
  80238. */
  80239. static DUALSHOCK: number;
  80240. /**
  80241. * Specifies whether the left control stick should be Y-inverted
  80242. */
  80243. protected _invertLeftStickY: boolean;
  80244. /**
  80245. * Specifies if the gamepad has been connected
  80246. */
  80247. readonly isConnected: boolean;
  80248. /**
  80249. * Initializes the gamepad
  80250. * @param id The id of the gamepad
  80251. * @param index The index of the gamepad
  80252. * @param browserGamepad The browser gamepad
  80253. * @param leftStickX The x component of the left joystick
  80254. * @param leftStickY The y component of the left joystick
  80255. * @param rightStickX The x component of the right joystick
  80256. * @param rightStickY The y component of the right joystick
  80257. */
  80258. constructor(
  80259. /**
  80260. * The id of the gamepad
  80261. */
  80262. id: string,
  80263. /**
  80264. * The index of the gamepad
  80265. */
  80266. index: number,
  80267. /**
  80268. * The browser gamepad
  80269. */
  80270. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80271. /**
  80272. * Callback triggered when the left joystick has changed
  80273. * @param callback
  80274. */
  80275. onleftstickchanged(callback: (values: StickValues) => void): void;
  80276. /**
  80277. * Callback triggered when the right joystick has changed
  80278. * @param callback
  80279. */
  80280. onrightstickchanged(callback: (values: StickValues) => void): void;
  80281. /**
  80282. * Gets the left joystick
  80283. */
  80284. /**
  80285. * Sets the left joystick values
  80286. */
  80287. leftStick: StickValues;
  80288. /**
  80289. * Gets the right joystick
  80290. */
  80291. /**
  80292. * Sets the right joystick value
  80293. */
  80294. rightStick: StickValues;
  80295. /**
  80296. * Updates the gamepad joystick positions
  80297. */
  80298. update(): void;
  80299. /**
  80300. * Disposes the gamepad
  80301. */
  80302. dispose(): void;
  80303. }
  80304. /**
  80305. * Represents a generic gamepad
  80306. */
  80307. export class GenericPad extends Gamepad {
  80308. private _buttons;
  80309. private _onbuttondown;
  80310. private _onbuttonup;
  80311. /**
  80312. * Observable triggered when a button has been pressed
  80313. */
  80314. onButtonDownObservable: Observable<number>;
  80315. /**
  80316. * Observable triggered when a button has been released
  80317. */
  80318. onButtonUpObservable: Observable<number>;
  80319. /**
  80320. * Callback triggered when a button has been pressed
  80321. * @param callback Called when a button has been pressed
  80322. */
  80323. onbuttondown(callback: (buttonPressed: number) => void): void;
  80324. /**
  80325. * Callback triggered when a button has been released
  80326. * @param callback Called when a button has been released
  80327. */
  80328. onbuttonup(callback: (buttonReleased: number) => void): void;
  80329. /**
  80330. * Initializes the generic gamepad
  80331. * @param id The id of the generic gamepad
  80332. * @param index The index of the generic gamepad
  80333. * @param browserGamepad The browser gamepad
  80334. */
  80335. constructor(id: string, index: number, browserGamepad: any);
  80336. private _setButtonValue;
  80337. /**
  80338. * Updates the generic gamepad
  80339. */
  80340. update(): void;
  80341. /**
  80342. * Disposes the generic gamepad
  80343. */
  80344. dispose(): void;
  80345. }
  80346. }
  80347. declare module BABYLON {
  80348. interface Engine {
  80349. /**
  80350. * Creates a raw texture
  80351. * @param data defines the data to store in the texture
  80352. * @param width defines the width of the texture
  80353. * @param height defines the height of the texture
  80354. * @param format defines the format of the data
  80355. * @param generateMipMaps defines if the engine should generate the mip levels
  80356. * @param invertY defines if data must be stored with Y axis inverted
  80357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80358. * @param compression defines the compression used (null by default)
  80359. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80360. * @returns the raw texture inside an InternalTexture
  80361. */
  80362. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80363. /**
  80364. * Update a raw texture
  80365. * @param texture defines the texture to update
  80366. * @param data defines the data to store in the texture
  80367. * @param format defines the format of the data
  80368. * @param invertY defines if data must be stored with Y axis inverted
  80369. */
  80370. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80371. /**
  80372. * Update a raw texture
  80373. * @param texture defines the texture to update
  80374. * @param data defines the data to store in the texture
  80375. * @param format defines the format of the data
  80376. * @param invertY defines if data must be stored with Y axis inverted
  80377. * @param compression defines the compression used (null by default)
  80378. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80379. */
  80380. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80381. /**
  80382. * Creates a new raw cube texture
  80383. * @param data defines the array of data to use to create each face
  80384. * @param size defines the size of the textures
  80385. * @param format defines the format of the data
  80386. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80387. * @param generateMipMaps defines if the engine should generate the mip levels
  80388. * @param invertY defines if data must be stored with Y axis inverted
  80389. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80390. * @param compression defines the compression used (null by default)
  80391. * @returns the cube texture as an InternalTexture
  80392. */
  80393. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80394. /**
  80395. * Update a raw cube texture
  80396. * @param texture defines the texture to udpdate
  80397. * @param data defines the data to store
  80398. * @param format defines the data format
  80399. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80400. * @param invertY defines if data must be stored with Y axis inverted
  80401. */
  80402. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80403. /**
  80404. * Update a raw cube texture
  80405. * @param texture defines the texture to udpdate
  80406. * @param data defines the data to store
  80407. * @param format defines the data format
  80408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80409. * @param invertY defines if data must be stored with Y axis inverted
  80410. * @param compression defines the compression used (null by default)
  80411. */
  80412. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80413. /**
  80414. * Update a raw cube texture
  80415. * @param texture defines the texture to udpdate
  80416. * @param data defines the data to store
  80417. * @param format defines the data format
  80418. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80419. * @param invertY defines if data must be stored with Y axis inverted
  80420. * @param compression defines the compression used (null by default)
  80421. * @param level defines which level of the texture to update
  80422. */
  80423. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80424. /**
  80425. * Creates a new raw cube texture from a specified url
  80426. * @param url defines the url where the data is located
  80427. * @param scene defines the current scene
  80428. * @param size defines the size of the textures
  80429. * @param format defines the format of the data
  80430. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80431. * @param noMipmap defines if the engine should avoid generating the mip levels
  80432. * @param callback defines a callback used to extract texture data from loaded data
  80433. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80434. * @param onLoad defines a callback called when texture is loaded
  80435. * @param onError defines a callback called if there is an error
  80436. * @returns the cube texture as an InternalTexture
  80437. */
  80438. 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;
  80439. /**
  80440. * Creates a new raw cube texture from a specified url
  80441. * @param url defines the url where the data is located
  80442. * @param scene defines the current scene
  80443. * @param size defines the size of the textures
  80444. * @param format defines the format of the data
  80445. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80446. * @param noMipmap defines if the engine should avoid generating the mip levels
  80447. * @param callback defines a callback used to extract texture data from loaded data
  80448. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80449. * @param onLoad defines a callback called when texture is loaded
  80450. * @param onError defines a callback called if there is an error
  80451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80452. * @param invertY defines if data must be stored with Y axis inverted
  80453. * @returns the cube texture as an InternalTexture
  80454. */
  80455. 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;
  80456. /**
  80457. * Creates a new raw 3D texture
  80458. * @param data defines the data used to create the texture
  80459. * @param width defines the width of the texture
  80460. * @param height defines the height of the texture
  80461. * @param depth defines the depth of the texture
  80462. * @param format defines the format of the texture
  80463. * @param generateMipMaps defines if the engine must generate mip levels
  80464. * @param invertY defines if data must be stored with Y axis inverted
  80465. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80466. * @param compression defines the compressed used (can be null)
  80467. * @param textureType defines the compressed used (can be null)
  80468. * @returns a new raw 3D texture (stored in an InternalTexture)
  80469. */
  80470. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80471. /**
  80472. * Update a raw 3D texture
  80473. * @param texture defines the texture to update
  80474. * @param data defines the data to store
  80475. * @param format defines the data format
  80476. * @param invertY defines if data must be stored with Y axis inverted
  80477. */
  80478. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80479. /**
  80480. * Update a raw 3D texture
  80481. * @param texture defines the texture to update
  80482. * @param data defines the data to store
  80483. * @param format defines the data format
  80484. * @param invertY defines if data must be stored with Y axis inverted
  80485. * @param compression defines the used compression (can be null)
  80486. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80487. */
  80488. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80489. /**
  80490. * Creates a new raw 2D array texture
  80491. * @param data defines the data used to create the texture
  80492. * @param width defines the width of the texture
  80493. * @param height defines the height of the texture
  80494. * @param depth defines the number of layers of the texture
  80495. * @param format defines the format of the texture
  80496. * @param generateMipMaps defines if the engine must generate mip levels
  80497. * @param invertY defines if data must be stored with Y axis inverted
  80498. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80499. * @param compression defines the compressed used (can be null)
  80500. * @param textureType defines the compressed used (can be null)
  80501. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80502. */
  80503. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80504. /**
  80505. * Update a raw 2D array texture
  80506. * @param texture defines the texture to update
  80507. * @param data defines the data to store
  80508. * @param format defines the data format
  80509. * @param invertY defines if data must be stored with Y axis inverted
  80510. */
  80511. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80512. /**
  80513. * Update a raw 2D array texture
  80514. * @param texture defines the texture to update
  80515. * @param data defines the data to store
  80516. * @param format defines the data format
  80517. * @param invertY defines if data must be stored with Y axis inverted
  80518. * @param compression defines the used compression (can be null)
  80519. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80520. */
  80521. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80522. }
  80523. }
  80524. declare module BABYLON {
  80525. /**
  80526. * Raw texture can help creating a texture directly from an array of data.
  80527. * This can be super useful if you either get the data from an uncompressed source or
  80528. * if you wish to create your texture pixel by pixel.
  80529. */
  80530. export class RawTexture extends Texture {
  80531. /**
  80532. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80533. */
  80534. format: number;
  80535. private _engine;
  80536. /**
  80537. * Instantiates a new RawTexture.
  80538. * Raw texture can help creating a texture directly from an array of data.
  80539. * This can be super useful if you either get the data from an uncompressed source or
  80540. * if you wish to create your texture pixel by pixel.
  80541. * @param data define the array of data to use to create the texture
  80542. * @param width define the width of the texture
  80543. * @param height define the height of the texture
  80544. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80545. * @param scene define the scene the texture belongs to
  80546. * @param generateMipMaps define whether mip maps should be generated or not
  80547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80549. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80550. */
  80551. constructor(data: ArrayBufferView, width: number, height: number,
  80552. /**
  80553. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80554. */
  80555. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80556. /**
  80557. * Updates the texture underlying data.
  80558. * @param data Define the new data of the texture
  80559. */
  80560. update(data: ArrayBufferView): void;
  80561. /**
  80562. * Creates a luminance texture from some data.
  80563. * @param data Define the texture data
  80564. * @param width Define the width of the texture
  80565. * @param height Define the height of the texture
  80566. * @param scene Define the scene the texture belongs to
  80567. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80570. * @returns the luminance texture
  80571. */
  80572. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80573. /**
  80574. * Creates a luminance alpha texture from some data.
  80575. * @param data Define the texture data
  80576. * @param width Define the width of the texture
  80577. * @param height Define the height of the texture
  80578. * @param scene Define the scene the texture belongs to
  80579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80582. * @returns the luminance alpha texture
  80583. */
  80584. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80585. /**
  80586. * Creates an alpha texture from some data.
  80587. * @param data Define the texture data
  80588. * @param width Define the width of the texture
  80589. * @param height Define the height of the texture
  80590. * @param scene Define the scene the texture belongs to
  80591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80594. * @returns the alpha texture
  80595. */
  80596. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80597. /**
  80598. * Creates a RGB texture from some data.
  80599. * @param data Define the texture data
  80600. * @param width Define the width of the texture
  80601. * @param height Define the height of the texture
  80602. * @param scene Define the scene the texture belongs to
  80603. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80604. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80605. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80606. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80607. * @returns the RGB alpha texture
  80608. */
  80609. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80610. /**
  80611. * Creates a RGBA texture from some data.
  80612. * @param data Define the texture data
  80613. * @param width Define the width of the texture
  80614. * @param height Define the height of the texture
  80615. * @param scene Define the scene the texture belongs to
  80616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80619. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80620. * @returns the RGBA texture
  80621. */
  80622. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80623. /**
  80624. * Creates a R texture from some data.
  80625. * @param data Define the texture data
  80626. * @param width Define the width of the texture
  80627. * @param height Define the height of the texture
  80628. * @param scene Define the scene the texture belongs to
  80629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80632. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80633. * @returns the R texture
  80634. */
  80635. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80636. }
  80637. }
  80638. declare module BABYLON {
  80639. /**
  80640. * Interface for the size containing width and height
  80641. */
  80642. export interface ISize {
  80643. /**
  80644. * Width
  80645. */
  80646. width: number;
  80647. /**
  80648. * Heighht
  80649. */
  80650. height: number;
  80651. }
  80652. /**
  80653. * Size containing widht and height
  80654. */
  80655. export class Size implements ISize {
  80656. /**
  80657. * Width
  80658. */
  80659. width: number;
  80660. /**
  80661. * Height
  80662. */
  80663. height: number;
  80664. /**
  80665. * Creates a Size object from the given width and height (floats).
  80666. * @param width width of the new size
  80667. * @param height height of the new size
  80668. */
  80669. constructor(width: number, height: number);
  80670. /**
  80671. * Returns a string with the Size width and height
  80672. * @returns a string with the Size width and height
  80673. */
  80674. toString(): string;
  80675. /**
  80676. * "Size"
  80677. * @returns the string "Size"
  80678. */
  80679. getClassName(): string;
  80680. /**
  80681. * Returns the Size hash code.
  80682. * @returns a hash code for a unique width and height
  80683. */
  80684. getHashCode(): number;
  80685. /**
  80686. * Updates the current size from the given one.
  80687. * @param src the given size
  80688. */
  80689. copyFrom(src: Size): void;
  80690. /**
  80691. * Updates in place the current Size from the given floats.
  80692. * @param width width of the new size
  80693. * @param height height of the new size
  80694. * @returns the updated Size.
  80695. */
  80696. copyFromFloats(width: number, height: number): Size;
  80697. /**
  80698. * Updates in place the current Size from the given floats.
  80699. * @param width width to set
  80700. * @param height height to set
  80701. * @returns the updated Size.
  80702. */
  80703. set(width: number, height: number): Size;
  80704. /**
  80705. * Multiplies the width and height by numbers
  80706. * @param w factor to multiple the width by
  80707. * @param h factor to multiple the height by
  80708. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80709. */
  80710. multiplyByFloats(w: number, h: number): Size;
  80711. /**
  80712. * Clones the size
  80713. * @returns a new Size copied from the given one.
  80714. */
  80715. clone(): Size;
  80716. /**
  80717. * True if the current Size and the given one width and height are strictly equal.
  80718. * @param other the other size to compare against
  80719. * @returns True if the current Size and the given one width and height are strictly equal.
  80720. */
  80721. equals(other: Size): boolean;
  80722. /**
  80723. * The surface of the Size : width * height (float).
  80724. */
  80725. readonly surface: number;
  80726. /**
  80727. * Create a new size of zero
  80728. * @returns a new Size set to (0.0, 0.0)
  80729. */
  80730. static Zero(): Size;
  80731. /**
  80732. * Sums the width and height of two sizes
  80733. * @param otherSize size to add to this size
  80734. * @returns a new Size set as the addition result of the current Size and the given one.
  80735. */
  80736. add(otherSize: Size): Size;
  80737. /**
  80738. * Subtracts the width and height of two
  80739. * @param otherSize size to subtract to this size
  80740. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80741. */
  80742. subtract(otherSize: Size): Size;
  80743. /**
  80744. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80745. * @param start starting size to lerp between
  80746. * @param end end size to lerp between
  80747. * @param amount amount to lerp between the start and end values
  80748. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80749. */
  80750. static Lerp(start: Size, end: Size, amount: number): Size;
  80751. }
  80752. }
  80753. declare module BABYLON {
  80754. /**
  80755. * Defines a runtime animation
  80756. */
  80757. export class RuntimeAnimation {
  80758. private _events;
  80759. /**
  80760. * The current frame of the runtime animation
  80761. */
  80762. private _currentFrame;
  80763. /**
  80764. * The animation used by the runtime animation
  80765. */
  80766. private _animation;
  80767. /**
  80768. * The target of the runtime animation
  80769. */
  80770. private _target;
  80771. /**
  80772. * The initiating animatable
  80773. */
  80774. private _host;
  80775. /**
  80776. * The original value of the runtime animation
  80777. */
  80778. private _originalValue;
  80779. /**
  80780. * The original blend value of the runtime animation
  80781. */
  80782. private _originalBlendValue;
  80783. /**
  80784. * The offsets cache of the runtime animation
  80785. */
  80786. private _offsetsCache;
  80787. /**
  80788. * The high limits cache of the runtime animation
  80789. */
  80790. private _highLimitsCache;
  80791. /**
  80792. * Specifies if the runtime animation has been stopped
  80793. */
  80794. private _stopped;
  80795. /**
  80796. * The blending factor of the runtime animation
  80797. */
  80798. private _blendingFactor;
  80799. /**
  80800. * The BabylonJS scene
  80801. */
  80802. private _scene;
  80803. /**
  80804. * The current value of the runtime animation
  80805. */
  80806. private _currentValue;
  80807. /** @hidden */
  80808. _animationState: _IAnimationState;
  80809. /**
  80810. * The active target of the runtime animation
  80811. */
  80812. private _activeTargets;
  80813. private _currentActiveTarget;
  80814. private _directTarget;
  80815. /**
  80816. * The target path of the runtime animation
  80817. */
  80818. private _targetPath;
  80819. /**
  80820. * The weight of the runtime animation
  80821. */
  80822. private _weight;
  80823. /**
  80824. * The ratio offset of the runtime animation
  80825. */
  80826. private _ratioOffset;
  80827. /**
  80828. * The previous delay of the runtime animation
  80829. */
  80830. private _previousDelay;
  80831. /**
  80832. * The previous ratio of the runtime animation
  80833. */
  80834. private _previousRatio;
  80835. private _enableBlending;
  80836. private _keys;
  80837. private _minFrame;
  80838. private _maxFrame;
  80839. private _minValue;
  80840. private _maxValue;
  80841. private _targetIsArray;
  80842. /**
  80843. * Gets the current frame of the runtime animation
  80844. */
  80845. readonly currentFrame: number;
  80846. /**
  80847. * Gets the weight of the runtime animation
  80848. */
  80849. readonly weight: number;
  80850. /**
  80851. * Gets the current value of the runtime animation
  80852. */
  80853. readonly currentValue: any;
  80854. /**
  80855. * Gets the target path of the runtime animation
  80856. */
  80857. readonly targetPath: string;
  80858. /**
  80859. * Gets the actual target of the runtime animation
  80860. */
  80861. readonly target: any;
  80862. /** @hidden */
  80863. _onLoop: () => void;
  80864. /**
  80865. * Create a new RuntimeAnimation object
  80866. * @param target defines the target of the animation
  80867. * @param animation defines the source animation object
  80868. * @param scene defines the hosting scene
  80869. * @param host defines the initiating Animatable
  80870. */
  80871. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80872. private _preparePath;
  80873. /**
  80874. * Gets the animation from the runtime animation
  80875. */
  80876. readonly animation: Animation;
  80877. /**
  80878. * Resets the runtime animation to the beginning
  80879. * @param restoreOriginal defines whether to restore the target property to the original value
  80880. */
  80881. reset(restoreOriginal?: boolean): void;
  80882. /**
  80883. * Specifies if the runtime animation is stopped
  80884. * @returns Boolean specifying if the runtime animation is stopped
  80885. */
  80886. isStopped(): boolean;
  80887. /**
  80888. * Disposes of the runtime animation
  80889. */
  80890. dispose(): void;
  80891. /**
  80892. * Apply the interpolated value to the target
  80893. * @param currentValue defines the value computed by the animation
  80894. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80895. */
  80896. setValue(currentValue: any, weight: number): void;
  80897. private _getOriginalValues;
  80898. private _setValue;
  80899. /**
  80900. * Gets the loop pmode of the runtime animation
  80901. * @returns Loop Mode
  80902. */
  80903. private _getCorrectLoopMode;
  80904. /**
  80905. * Move the current animation to a given frame
  80906. * @param frame defines the frame to move to
  80907. */
  80908. goToFrame(frame: number): void;
  80909. /**
  80910. * @hidden Internal use only
  80911. */
  80912. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80913. /**
  80914. * Execute the current animation
  80915. * @param delay defines the delay to add to the current frame
  80916. * @param from defines the lower bound of the animation range
  80917. * @param to defines the upper bound of the animation range
  80918. * @param loop defines if the current animation must loop
  80919. * @param speedRatio defines the current speed ratio
  80920. * @param weight defines the weight of the animation (default is -1 so no weight)
  80921. * @param onLoop optional callback called when animation loops
  80922. * @returns a boolean indicating if the animation is running
  80923. */
  80924. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80925. }
  80926. }
  80927. declare module BABYLON {
  80928. /**
  80929. * Class used to store an actual running animation
  80930. */
  80931. export class Animatable {
  80932. /** defines the target object */
  80933. target: any;
  80934. /** defines the starting frame number (default is 0) */
  80935. fromFrame: number;
  80936. /** defines the ending frame number (default is 100) */
  80937. toFrame: number;
  80938. /** defines if the animation must loop (default is false) */
  80939. loopAnimation: boolean;
  80940. /** defines a callback to call when animation ends if it is not looping */
  80941. onAnimationEnd?: (() => void) | null | undefined;
  80942. /** defines a callback to call when animation loops */
  80943. onAnimationLoop?: (() => void) | null | undefined;
  80944. private _localDelayOffset;
  80945. private _pausedDelay;
  80946. private _runtimeAnimations;
  80947. private _paused;
  80948. private _scene;
  80949. private _speedRatio;
  80950. private _weight;
  80951. private _syncRoot;
  80952. /**
  80953. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80954. * This will only apply for non looping animation (default is true)
  80955. */
  80956. disposeOnEnd: boolean;
  80957. /**
  80958. * Gets a boolean indicating if the animation has started
  80959. */
  80960. animationStarted: boolean;
  80961. /**
  80962. * Observer raised when the animation ends
  80963. */
  80964. onAnimationEndObservable: Observable<Animatable>;
  80965. /**
  80966. * Observer raised when the animation loops
  80967. */
  80968. onAnimationLoopObservable: Observable<Animatable>;
  80969. /**
  80970. * Gets the root Animatable used to synchronize and normalize animations
  80971. */
  80972. readonly syncRoot: Nullable<Animatable>;
  80973. /**
  80974. * Gets the current frame of the first RuntimeAnimation
  80975. * Used to synchronize Animatables
  80976. */
  80977. readonly masterFrame: number;
  80978. /**
  80979. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80980. */
  80981. weight: number;
  80982. /**
  80983. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80984. */
  80985. speedRatio: number;
  80986. /**
  80987. * Creates a new Animatable
  80988. * @param scene defines the hosting scene
  80989. * @param target defines the target object
  80990. * @param fromFrame defines the starting frame number (default is 0)
  80991. * @param toFrame defines the ending frame number (default is 100)
  80992. * @param loopAnimation defines if the animation must loop (default is false)
  80993. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80994. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80995. * @param animations defines a group of animation to add to the new Animatable
  80996. * @param onAnimationLoop defines a callback to call when animation loops
  80997. */
  80998. constructor(scene: Scene,
  80999. /** defines the target object */
  81000. target: any,
  81001. /** defines the starting frame number (default is 0) */
  81002. fromFrame?: number,
  81003. /** defines the ending frame number (default is 100) */
  81004. toFrame?: number,
  81005. /** defines if the animation must loop (default is false) */
  81006. loopAnimation?: boolean, speedRatio?: number,
  81007. /** defines a callback to call when animation ends if it is not looping */
  81008. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81009. /** defines a callback to call when animation loops */
  81010. onAnimationLoop?: (() => void) | null | undefined);
  81011. /**
  81012. * Synchronize and normalize current Animatable with a source Animatable
  81013. * This is useful when using animation weights and when animations are not of the same length
  81014. * @param root defines the root Animatable to synchronize with
  81015. * @returns the current Animatable
  81016. */
  81017. syncWith(root: Animatable): Animatable;
  81018. /**
  81019. * Gets the list of runtime animations
  81020. * @returns an array of RuntimeAnimation
  81021. */
  81022. getAnimations(): RuntimeAnimation[];
  81023. /**
  81024. * Adds more animations to the current animatable
  81025. * @param target defines the target of the animations
  81026. * @param animations defines the new animations to add
  81027. */
  81028. appendAnimations(target: any, animations: Animation[]): void;
  81029. /**
  81030. * Gets the source animation for a specific property
  81031. * @param property defines the propertyu to look for
  81032. * @returns null or the source animation for the given property
  81033. */
  81034. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81035. /**
  81036. * Gets the runtime animation for a specific property
  81037. * @param property defines the propertyu to look for
  81038. * @returns null or the runtime animation for the given property
  81039. */
  81040. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81041. /**
  81042. * Resets the animatable to its original state
  81043. */
  81044. reset(): void;
  81045. /**
  81046. * Allows the animatable to blend with current running animations
  81047. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81048. * @param blendingSpeed defines the blending speed to use
  81049. */
  81050. enableBlending(blendingSpeed: number): void;
  81051. /**
  81052. * Disable animation blending
  81053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81054. */
  81055. disableBlending(): void;
  81056. /**
  81057. * Jump directly to a given frame
  81058. * @param frame defines the frame to jump to
  81059. */
  81060. goToFrame(frame: number): void;
  81061. /**
  81062. * Pause the animation
  81063. */
  81064. pause(): void;
  81065. /**
  81066. * Restart the animation
  81067. */
  81068. restart(): void;
  81069. private _raiseOnAnimationEnd;
  81070. /**
  81071. * Stop and delete the current animation
  81072. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81073. * @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)
  81074. */
  81075. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81076. /**
  81077. * Wait asynchronously for the animation to end
  81078. * @returns a promise which will be fullfilled when the animation ends
  81079. */
  81080. waitAsync(): Promise<Animatable>;
  81081. /** @hidden */
  81082. _animate(delay: number): boolean;
  81083. }
  81084. interface Scene {
  81085. /** @hidden */
  81086. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81087. /** @hidden */
  81088. _processLateAnimationBindingsForMatrices(holder: {
  81089. totalWeight: number;
  81090. animations: RuntimeAnimation[];
  81091. originalValue: Matrix;
  81092. }): any;
  81093. /** @hidden */
  81094. _processLateAnimationBindingsForQuaternions(holder: {
  81095. totalWeight: number;
  81096. animations: RuntimeAnimation[];
  81097. originalValue: Quaternion;
  81098. }, refQuaternion: Quaternion): Quaternion;
  81099. /** @hidden */
  81100. _processLateAnimationBindings(): void;
  81101. /**
  81102. * Will start the animation sequence of a given target
  81103. * @param target defines the target
  81104. * @param from defines from which frame should animation start
  81105. * @param to defines until which frame should animation run.
  81106. * @param weight defines the weight to apply to the animation (1.0 by default)
  81107. * @param loop defines if the animation loops
  81108. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81109. * @param onAnimationEnd defines the function to be executed when the animation ends
  81110. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81111. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81112. * @param onAnimationLoop defines the callback to call when an animation loops
  81113. * @returns the animatable object created for this animation
  81114. */
  81115. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81116. /**
  81117. * Will start the animation sequence of a given target
  81118. * @param target defines the target
  81119. * @param from defines from which frame should animation start
  81120. * @param to defines until which frame should animation run.
  81121. * @param loop defines if the animation loops
  81122. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81123. * @param onAnimationEnd defines the function to be executed when the animation ends
  81124. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81125. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81126. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81127. * @param onAnimationLoop defines the callback to call when an animation loops
  81128. * @returns the animatable object created for this animation
  81129. */
  81130. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81131. /**
  81132. * Will start the animation sequence of a given target and its hierarchy
  81133. * @param target defines the target
  81134. * @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.
  81135. * @param from defines from which frame should animation start
  81136. * @param to defines until which frame should animation run.
  81137. * @param loop defines if the animation loops
  81138. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81139. * @param onAnimationEnd defines the function to be executed when the animation ends
  81140. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81141. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81142. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81143. * @param onAnimationLoop defines the callback to call when an animation loops
  81144. * @returns the list of created animatables
  81145. */
  81146. 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[];
  81147. /**
  81148. * Begin a new animation on a given node
  81149. * @param target defines the target where the animation will take place
  81150. * @param animations defines the list of animations to start
  81151. * @param from defines the initial value
  81152. * @param to defines the final value
  81153. * @param loop defines if you want animation to loop (off by default)
  81154. * @param speedRatio defines the speed ratio to apply to all animations
  81155. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81156. * @param onAnimationLoop defines the callback to call when an animation loops
  81157. * @returns the list of created animatables
  81158. */
  81159. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81160. /**
  81161. * Begin a new animation on a given node and its hierarchy
  81162. * @param target defines the root node where the animation will take place
  81163. * @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.
  81164. * @param animations defines the list of animations to start
  81165. * @param from defines the initial value
  81166. * @param to defines the final value
  81167. * @param loop defines if you want animation to loop (off by default)
  81168. * @param speedRatio defines the speed ratio to apply to all animations
  81169. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81170. * @param onAnimationLoop defines the callback to call when an animation loops
  81171. * @returns the list of animatables created for all nodes
  81172. */
  81173. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81174. /**
  81175. * Gets the animatable associated with a specific target
  81176. * @param target defines the target of the animatable
  81177. * @returns the required animatable if found
  81178. */
  81179. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81180. /**
  81181. * Gets all animatables associated with a given target
  81182. * @param target defines the target to look animatables for
  81183. * @returns an array of Animatables
  81184. */
  81185. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81186. /**
  81187. * Stops and removes all animations that have been applied to the scene
  81188. */
  81189. stopAllAnimations(): void;
  81190. /**
  81191. * Gets the current delta time used by animation engine
  81192. */
  81193. deltaTime: number;
  81194. }
  81195. interface Bone {
  81196. /**
  81197. * Copy an animation range from another bone
  81198. * @param source defines the source bone
  81199. * @param rangeName defines the range name to copy
  81200. * @param frameOffset defines the frame offset
  81201. * @param rescaleAsRequired defines if rescaling must be applied if required
  81202. * @param skelDimensionsRatio defines the scaling ratio
  81203. * @returns true if operation was successful
  81204. */
  81205. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81206. }
  81207. }
  81208. declare module BABYLON {
  81209. /**
  81210. * Class used to override all child animations of a given target
  81211. */
  81212. export class AnimationPropertiesOverride {
  81213. /**
  81214. * Gets or sets a value indicating if animation blending must be used
  81215. */
  81216. enableBlending: boolean;
  81217. /**
  81218. * Gets or sets the blending speed to use when enableBlending is true
  81219. */
  81220. blendingSpeed: number;
  81221. /**
  81222. * Gets or sets the default loop mode to use
  81223. */
  81224. loopMode: number;
  81225. }
  81226. }
  81227. declare module BABYLON {
  81228. /**
  81229. * Class used to handle skinning animations
  81230. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81231. */
  81232. export class Skeleton implements IAnimatable {
  81233. /** defines the skeleton name */
  81234. name: string;
  81235. /** defines the skeleton Id */
  81236. id: string;
  81237. /**
  81238. * Defines the list of child bones
  81239. */
  81240. bones: Bone[];
  81241. /**
  81242. * Defines an estimate of the dimension of the skeleton at rest
  81243. */
  81244. dimensionsAtRest: Vector3;
  81245. /**
  81246. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81247. */
  81248. needInitialSkinMatrix: boolean;
  81249. /**
  81250. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81251. */
  81252. overrideMesh: Nullable<AbstractMesh>;
  81253. /**
  81254. * Gets the list of animations attached to this skeleton
  81255. */
  81256. animations: Array<Animation>;
  81257. private _scene;
  81258. private _isDirty;
  81259. private _transformMatrices;
  81260. private _transformMatrixTexture;
  81261. private _meshesWithPoseMatrix;
  81262. private _animatables;
  81263. private _identity;
  81264. private _synchronizedWithMesh;
  81265. private _ranges;
  81266. private _lastAbsoluteTransformsUpdateId;
  81267. private _canUseTextureForBones;
  81268. private _uniqueId;
  81269. /** @hidden */
  81270. _numBonesWithLinkedTransformNode: number;
  81271. /** @hidden */
  81272. _hasWaitingData: Nullable<boolean>;
  81273. /**
  81274. * Specifies if the skeleton should be serialized
  81275. */
  81276. doNotSerialize: boolean;
  81277. private _useTextureToStoreBoneMatrices;
  81278. /**
  81279. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81280. * Please note that this option is not available if the hardware does not support it
  81281. */
  81282. useTextureToStoreBoneMatrices: boolean;
  81283. private _animationPropertiesOverride;
  81284. /**
  81285. * Gets or sets the animation properties override
  81286. */
  81287. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81288. /**
  81289. * List of inspectable custom properties (used by the Inspector)
  81290. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81291. */
  81292. inspectableCustomProperties: IInspectable[];
  81293. /**
  81294. * An observable triggered before computing the skeleton's matrices
  81295. */
  81296. onBeforeComputeObservable: Observable<Skeleton>;
  81297. /**
  81298. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81299. */
  81300. readonly isUsingTextureForMatrices: boolean;
  81301. /**
  81302. * Gets the unique ID of this skeleton
  81303. */
  81304. readonly uniqueId: number;
  81305. /**
  81306. * Creates a new skeleton
  81307. * @param name defines the skeleton name
  81308. * @param id defines the skeleton Id
  81309. * @param scene defines the hosting scene
  81310. */
  81311. constructor(
  81312. /** defines the skeleton name */
  81313. name: string,
  81314. /** defines the skeleton Id */
  81315. id: string, scene: Scene);
  81316. /**
  81317. * Gets the current object class name.
  81318. * @return the class name
  81319. */
  81320. getClassName(): string;
  81321. /**
  81322. * Returns an array containing the root bones
  81323. * @returns an array containing the root bones
  81324. */
  81325. getChildren(): Array<Bone>;
  81326. /**
  81327. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81328. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81329. * @returns a Float32Array containing matrices data
  81330. */
  81331. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81332. /**
  81333. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81334. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81335. * @returns a raw texture containing the data
  81336. */
  81337. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81338. /**
  81339. * Gets the current hosting scene
  81340. * @returns a scene object
  81341. */
  81342. getScene(): Scene;
  81343. /**
  81344. * Gets a string representing the current skeleton data
  81345. * @param fullDetails defines a boolean indicating if we want a verbose version
  81346. * @returns a string representing the current skeleton data
  81347. */
  81348. toString(fullDetails?: boolean): string;
  81349. /**
  81350. * Get bone's index searching by name
  81351. * @param name defines bone's name to search for
  81352. * @return the indice of the bone. Returns -1 if not found
  81353. */
  81354. getBoneIndexByName(name: string): number;
  81355. /**
  81356. * Creater a new animation range
  81357. * @param name defines the name of the range
  81358. * @param from defines the start key
  81359. * @param to defines the end key
  81360. */
  81361. createAnimationRange(name: string, from: number, to: number): void;
  81362. /**
  81363. * Delete a specific animation range
  81364. * @param name defines the name of the range
  81365. * @param deleteFrames defines if frames must be removed as well
  81366. */
  81367. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81368. /**
  81369. * Gets a specific animation range
  81370. * @param name defines the name of the range to look for
  81371. * @returns the requested animation range or null if not found
  81372. */
  81373. getAnimationRange(name: string): Nullable<AnimationRange>;
  81374. /**
  81375. * Gets the list of all animation ranges defined on this skeleton
  81376. * @returns an array
  81377. */
  81378. getAnimationRanges(): Nullable<AnimationRange>[];
  81379. /**
  81380. * Copy animation range from a source skeleton.
  81381. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81382. * @param source defines the source skeleton
  81383. * @param name defines the name of the range to copy
  81384. * @param rescaleAsRequired defines if rescaling must be applied if required
  81385. * @returns true if operation was successful
  81386. */
  81387. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81388. /**
  81389. * Forces the skeleton to go to rest pose
  81390. */
  81391. returnToRest(): void;
  81392. private _getHighestAnimationFrame;
  81393. /**
  81394. * Begin a specific animation range
  81395. * @param name defines the name of the range to start
  81396. * @param loop defines if looping must be turned on (false by default)
  81397. * @param speedRatio defines the speed ratio to apply (1 by default)
  81398. * @param onAnimationEnd defines a callback which will be called when animation will end
  81399. * @returns a new animatable
  81400. */
  81401. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81402. /** @hidden */
  81403. _markAsDirty(): void;
  81404. /** @hidden */
  81405. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81406. /** @hidden */
  81407. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81408. private _computeTransformMatrices;
  81409. /**
  81410. * Build all resources required to render a skeleton
  81411. */
  81412. prepare(): void;
  81413. /**
  81414. * Gets the list of animatables currently running for this skeleton
  81415. * @returns an array of animatables
  81416. */
  81417. getAnimatables(): IAnimatable[];
  81418. /**
  81419. * Clone the current skeleton
  81420. * @param name defines the name of the new skeleton
  81421. * @param id defines the id of the new skeleton
  81422. * @returns the new skeleton
  81423. */
  81424. clone(name: string, id?: string): Skeleton;
  81425. /**
  81426. * Enable animation blending for this skeleton
  81427. * @param blendingSpeed defines the blending speed to apply
  81428. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81429. */
  81430. enableBlending(blendingSpeed?: number): void;
  81431. /**
  81432. * Releases all resources associated with the current skeleton
  81433. */
  81434. dispose(): void;
  81435. /**
  81436. * Serialize the skeleton in a JSON object
  81437. * @returns a JSON object
  81438. */
  81439. serialize(): any;
  81440. /**
  81441. * Creates a new skeleton from serialized data
  81442. * @param parsedSkeleton defines the serialized data
  81443. * @param scene defines the hosting scene
  81444. * @returns a new skeleton
  81445. */
  81446. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81447. /**
  81448. * Compute all node absolute transforms
  81449. * @param forceUpdate defines if computation must be done even if cache is up to date
  81450. */
  81451. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81452. /**
  81453. * Gets the root pose matrix
  81454. * @returns a matrix
  81455. */
  81456. getPoseMatrix(): Nullable<Matrix>;
  81457. /**
  81458. * Sorts bones per internal index
  81459. */
  81460. sortBones(): void;
  81461. private _sortBones;
  81462. }
  81463. }
  81464. declare module BABYLON {
  81465. /**
  81466. * Class used to store bone information
  81467. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81468. */
  81469. export class Bone extends Node {
  81470. /**
  81471. * defines the bone name
  81472. */
  81473. name: string;
  81474. private static _tmpVecs;
  81475. private static _tmpQuat;
  81476. private static _tmpMats;
  81477. /**
  81478. * Gets the list of child bones
  81479. */
  81480. children: Bone[];
  81481. /** Gets the animations associated with this bone */
  81482. animations: Animation[];
  81483. /**
  81484. * Gets or sets bone length
  81485. */
  81486. length: number;
  81487. /**
  81488. * @hidden Internal only
  81489. * Set this value to map this bone to a different index in the transform matrices
  81490. * Set this value to -1 to exclude the bone from the transform matrices
  81491. */
  81492. _index: Nullable<number>;
  81493. private _skeleton;
  81494. private _localMatrix;
  81495. private _restPose;
  81496. private _baseMatrix;
  81497. private _absoluteTransform;
  81498. private _invertedAbsoluteTransform;
  81499. private _parent;
  81500. private _scalingDeterminant;
  81501. private _worldTransform;
  81502. private _localScaling;
  81503. private _localRotation;
  81504. private _localPosition;
  81505. private _needToDecompose;
  81506. private _needToCompose;
  81507. /** @hidden */
  81508. _linkedTransformNode: Nullable<TransformNode>;
  81509. /** @hidden */
  81510. _waitingTransformNodeId: Nullable<string>;
  81511. /** @hidden */
  81512. /** @hidden */
  81513. _matrix: Matrix;
  81514. /**
  81515. * Create a new bone
  81516. * @param name defines the bone name
  81517. * @param skeleton defines the parent skeleton
  81518. * @param parentBone defines the parent (can be null if the bone is the root)
  81519. * @param localMatrix defines the local matrix
  81520. * @param restPose defines the rest pose matrix
  81521. * @param baseMatrix defines the base matrix
  81522. * @param index defines index of the bone in the hiearchy
  81523. */
  81524. constructor(
  81525. /**
  81526. * defines the bone name
  81527. */
  81528. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81529. /**
  81530. * Gets the current object class name.
  81531. * @return the class name
  81532. */
  81533. getClassName(): string;
  81534. /**
  81535. * Gets the parent skeleton
  81536. * @returns a skeleton
  81537. */
  81538. getSkeleton(): Skeleton;
  81539. /**
  81540. * Gets parent bone
  81541. * @returns a bone or null if the bone is the root of the bone hierarchy
  81542. */
  81543. getParent(): Nullable<Bone>;
  81544. /**
  81545. * Returns an array containing the root bones
  81546. * @returns an array containing the root bones
  81547. */
  81548. getChildren(): Array<Bone>;
  81549. /**
  81550. * Gets the node index in matrix array generated for rendering
  81551. * @returns the node index
  81552. */
  81553. getIndex(): number;
  81554. /**
  81555. * Sets the parent bone
  81556. * @param parent defines the parent (can be null if the bone is the root)
  81557. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81558. */
  81559. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81560. /**
  81561. * Gets the local matrix
  81562. * @returns a matrix
  81563. */
  81564. getLocalMatrix(): Matrix;
  81565. /**
  81566. * Gets the base matrix (initial matrix which remains unchanged)
  81567. * @returns a matrix
  81568. */
  81569. getBaseMatrix(): Matrix;
  81570. /**
  81571. * Gets the rest pose matrix
  81572. * @returns a matrix
  81573. */
  81574. getRestPose(): Matrix;
  81575. /**
  81576. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81577. */
  81578. getWorldMatrix(): Matrix;
  81579. /**
  81580. * Sets the local matrix to rest pose matrix
  81581. */
  81582. returnToRest(): void;
  81583. /**
  81584. * Gets the inverse of the absolute transform matrix.
  81585. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81586. * @returns a matrix
  81587. */
  81588. getInvertedAbsoluteTransform(): Matrix;
  81589. /**
  81590. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81591. * @returns a matrix
  81592. */
  81593. getAbsoluteTransform(): Matrix;
  81594. /**
  81595. * Links with the given transform node.
  81596. * The local matrix of this bone is copied from the transform node every frame.
  81597. * @param transformNode defines the transform node to link to
  81598. */
  81599. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81600. /**
  81601. * Gets the node used to drive the bone's transformation
  81602. * @returns a transform node or null
  81603. */
  81604. getTransformNode(): Nullable<TransformNode>;
  81605. /** Gets or sets current position (in local space) */
  81606. position: Vector3;
  81607. /** Gets or sets current rotation (in local space) */
  81608. rotation: Vector3;
  81609. /** Gets or sets current rotation quaternion (in local space) */
  81610. rotationQuaternion: Quaternion;
  81611. /** Gets or sets current scaling (in local space) */
  81612. scaling: Vector3;
  81613. /**
  81614. * Gets the animation properties override
  81615. */
  81616. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81617. private _decompose;
  81618. private _compose;
  81619. /**
  81620. * Update the base and local matrices
  81621. * @param matrix defines the new base or local matrix
  81622. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81623. * @param updateLocalMatrix defines if the local matrix should be updated
  81624. */
  81625. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81626. /** @hidden */
  81627. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81628. /**
  81629. * Flag the bone as dirty (Forcing it to update everything)
  81630. */
  81631. markAsDirty(): void;
  81632. /** @hidden */
  81633. _markAsDirtyAndCompose(): void;
  81634. private _markAsDirtyAndDecompose;
  81635. /**
  81636. * Translate the bone in local or world space
  81637. * @param vec The amount to translate the bone
  81638. * @param space The space that the translation is in
  81639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81640. */
  81641. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81642. /**
  81643. * Set the postion of the bone in local or world space
  81644. * @param position The position to set the bone
  81645. * @param space The space that the position is in
  81646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81647. */
  81648. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81649. /**
  81650. * Set the absolute position of the bone (world space)
  81651. * @param position The position to set the bone
  81652. * @param mesh The mesh that this bone is attached to
  81653. */
  81654. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81655. /**
  81656. * Scale the bone on the x, y and z axes (in local space)
  81657. * @param x The amount to scale the bone on the x axis
  81658. * @param y The amount to scale the bone on the y axis
  81659. * @param z The amount to scale the bone on the z axis
  81660. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81661. */
  81662. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81663. /**
  81664. * Set the bone scaling in local space
  81665. * @param scale defines the scaling vector
  81666. */
  81667. setScale(scale: Vector3): void;
  81668. /**
  81669. * Gets the current scaling in local space
  81670. * @returns the current scaling vector
  81671. */
  81672. getScale(): Vector3;
  81673. /**
  81674. * Gets the current scaling in local space and stores it in a target vector
  81675. * @param result defines the target vector
  81676. */
  81677. getScaleToRef(result: Vector3): void;
  81678. /**
  81679. * Set the yaw, pitch, and roll of the bone in local or world space
  81680. * @param yaw The rotation of the bone on the y axis
  81681. * @param pitch The rotation of the bone on the x axis
  81682. * @param roll The rotation of the bone on the z axis
  81683. * @param space The space that the axes of rotation are in
  81684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81685. */
  81686. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81687. /**
  81688. * Add a rotation to the bone on an axis in local or world space
  81689. * @param axis The axis to rotate the bone on
  81690. * @param amount The amount to rotate the bone
  81691. * @param space The space that the axis is in
  81692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81693. */
  81694. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81695. /**
  81696. * Set the rotation of the bone to a particular axis angle in local or world space
  81697. * @param axis The axis to rotate the bone on
  81698. * @param angle The angle that the bone should be rotated to
  81699. * @param space The space that the axis is in
  81700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81701. */
  81702. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81703. /**
  81704. * Set the euler rotation of the bone in local of world space
  81705. * @param rotation The euler rotation that the bone should be set to
  81706. * @param space The space that the rotation is in
  81707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81708. */
  81709. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81710. /**
  81711. * Set the quaternion rotation of the bone in local of world space
  81712. * @param quat The quaternion rotation that the bone should be set to
  81713. * @param space The space that the rotation is in
  81714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81715. */
  81716. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81717. /**
  81718. * Set the rotation matrix of the bone in local of world space
  81719. * @param rotMat The rotation matrix that the bone should be set to
  81720. * @param space The space that the rotation is in
  81721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81722. */
  81723. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81724. private _rotateWithMatrix;
  81725. private _getNegativeRotationToRef;
  81726. /**
  81727. * Get the position of the bone in local or world space
  81728. * @param space The space that the returned position is in
  81729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81730. * @returns The position of the bone
  81731. */
  81732. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81733. /**
  81734. * Copy the position of the bone to a vector3 in local or world space
  81735. * @param space The space that the returned position is in
  81736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81737. * @param result The vector3 to copy the position to
  81738. */
  81739. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81740. /**
  81741. * Get the absolute position of the bone (world space)
  81742. * @param mesh The mesh that this bone is attached to
  81743. * @returns The absolute position of the bone
  81744. */
  81745. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81746. /**
  81747. * Copy the absolute position of the bone (world space) to the result param
  81748. * @param mesh The mesh that this bone is attached to
  81749. * @param result The vector3 to copy the absolute position to
  81750. */
  81751. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81752. /**
  81753. * Compute the absolute transforms of this bone and its children
  81754. */
  81755. computeAbsoluteTransforms(): void;
  81756. /**
  81757. * Get the world direction from an axis that is in the local space of the bone
  81758. * @param localAxis The local direction that is used to compute the world direction
  81759. * @param mesh The mesh that this bone is attached to
  81760. * @returns The world direction
  81761. */
  81762. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81763. /**
  81764. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81765. * @param localAxis The local direction that is used to compute the world direction
  81766. * @param mesh The mesh that this bone is attached to
  81767. * @param result The vector3 that the world direction will be copied to
  81768. */
  81769. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81770. /**
  81771. * Get the euler rotation of the bone in local or world space
  81772. * @param space The space that the rotation should be in
  81773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81774. * @returns The euler rotation
  81775. */
  81776. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81777. /**
  81778. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81779. * @param space The space that the rotation should be in
  81780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81781. * @param result The vector3 that the rotation should be copied to
  81782. */
  81783. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81784. /**
  81785. * Get the quaternion rotation of the bone in either local or world space
  81786. * @param space The space that the rotation should be in
  81787. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81788. * @returns The quaternion rotation
  81789. */
  81790. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81791. /**
  81792. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81793. * @param space The space that the rotation should be in
  81794. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81795. * @param result The quaternion that the rotation should be copied to
  81796. */
  81797. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81798. /**
  81799. * Get the rotation matrix of the bone in local or world space
  81800. * @param space The space that the rotation should be in
  81801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81802. * @returns The rotation matrix
  81803. */
  81804. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81805. /**
  81806. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either 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. * @param result The quaternion that the rotation should be copied to
  81810. */
  81811. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81812. /**
  81813. * Get the world position of a point that is in the local space of the bone
  81814. * @param position The local position
  81815. * @param mesh The mesh that this bone is attached to
  81816. * @returns The world position
  81817. */
  81818. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81819. /**
  81820. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81821. * @param position The local position
  81822. * @param mesh The mesh that this bone is attached to
  81823. * @param result The vector3 that the world position should be copied to
  81824. */
  81825. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81826. /**
  81827. * Get the local position of a point that is in world space
  81828. * @param position The world position
  81829. * @param mesh The mesh that this bone is attached to
  81830. * @returns The local position
  81831. */
  81832. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81833. /**
  81834. * Get the local position of a point that is in world space and copy it to the result param
  81835. * @param position The world position
  81836. * @param mesh The mesh that this bone is attached to
  81837. * @param result The vector3 that the local position should be copied to
  81838. */
  81839. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81840. }
  81841. }
  81842. declare module BABYLON {
  81843. /**
  81844. * 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.
  81845. * @see https://doc.babylonjs.com/how_to/transformnode
  81846. */
  81847. export class TransformNode extends Node {
  81848. /**
  81849. * Object will not rotate to face the camera
  81850. */
  81851. static BILLBOARDMODE_NONE: number;
  81852. /**
  81853. * Object will rotate to face the camera but only on the x axis
  81854. */
  81855. static BILLBOARDMODE_X: number;
  81856. /**
  81857. * Object will rotate to face the camera but only on the y axis
  81858. */
  81859. static BILLBOARDMODE_Y: number;
  81860. /**
  81861. * Object will rotate to face the camera but only on the z axis
  81862. */
  81863. static BILLBOARDMODE_Z: number;
  81864. /**
  81865. * Object will rotate to face the camera
  81866. */
  81867. static BILLBOARDMODE_ALL: number;
  81868. /**
  81869. * Object will rotate to face the camera's position instead of orientation
  81870. */
  81871. static BILLBOARDMODE_USE_POSITION: number;
  81872. private _forward;
  81873. private _forwardInverted;
  81874. private _up;
  81875. private _right;
  81876. private _rightInverted;
  81877. private _position;
  81878. private _rotation;
  81879. private _rotationQuaternion;
  81880. protected _scaling: Vector3;
  81881. protected _isDirty: boolean;
  81882. private _transformToBoneReferal;
  81883. private _isAbsoluteSynced;
  81884. private _billboardMode;
  81885. /**
  81886. * Gets or sets the billboard mode. Default is 0.
  81887. *
  81888. * | Value | Type | Description |
  81889. * | --- | --- | --- |
  81890. * | 0 | BILLBOARDMODE_NONE | |
  81891. * | 1 | BILLBOARDMODE_X | |
  81892. * | 2 | BILLBOARDMODE_Y | |
  81893. * | 4 | BILLBOARDMODE_Z | |
  81894. * | 7 | BILLBOARDMODE_ALL | |
  81895. *
  81896. */
  81897. billboardMode: number;
  81898. private _preserveParentRotationForBillboard;
  81899. /**
  81900. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81901. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81902. */
  81903. preserveParentRotationForBillboard: boolean;
  81904. /**
  81905. * 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
  81906. */
  81907. scalingDeterminant: number;
  81908. private _infiniteDistance;
  81909. /**
  81910. * Gets or sets the distance of the object to max, often used by skybox
  81911. */
  81912. infiniteDistance: boolean;
  81913. /**
  81914. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81915. * By default the system will update normals to compensate
  81916. */
  81917. ignoreNonUniformScaling: boolean;
  81918. /**
  81919. * 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
  81920. */
  81921. reIntegrateRotationIntoRotationQuaternion: boolean;
  81922. /** @hidden */
  81923. _poseMatrix: Nullable<Matrix>;
  81924. /** @hidden */
  81925. _localMatrix: Matrix;
  81926. private _usePivotMatrix;
  81927. private _absolutePosition;
  81928. private _absoluteScaling;
  81929. private _absoluteRotationQuaternion;
  81930. private _pivotMatrix;
  81931. private _pivotMatrixInverse;
  81932. protected _postMultiplyPivotMatrix: boolean;
  81933. protected _isWorldMatrixFrozen: boolean;
  81934. /** @hidden */
  81935. _indexInSceneTransformNodesArray: number;
  81936. /**
  81937. * An event triggered after the world matrix is updated
  81938. */
  81939. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81940. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81941. /**
  81942. * Gets a string identifying the name of the class
  81943. * @returns "TransformNode" string
  81944. */
  81945. getClassName(): string;
  81946. /**
  81947. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81948. */
  81949. position: Vector3;
  81950. /**
  81951. * 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)).
  81952. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81953. */
  81954. rotation: Vector3;
  81955. /**
  81956. * 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)).
  81957. */
  81958. scaling: Vector3;
  81959. /**
  81960. * 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).
  81961. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81962. */
  81963. rotationQuaternion: Nullable<Quaternion>;
  81964. /**
  81965. * The forward direction of that transform in world space.
  81966. */
  81967. readonly forward: Vector3;
  81968. /**
  81969. * The up direction of that transform in world space.
  81970. */
  81971. readonly up: Vector3;
  81972. /**
  81973. * The right direction of that transform in world space.
  81974. */
  81975. readonly right: Vector3;
  81976. /**
  81977. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81978. * @param matrix the matrix to copy the pose from
  81979. * @returns this TransformNode.
  81980. */
  81981. updatePoseMatrix(matrix: Matrix): TransformNode;
  81982. /**
  81983. * Returns the mesh Pose matrix.
  81984. * @returns the pose matrix
  81985. */
  81986. getPoseMatrix(): Matrix;
  81987. /** @hidden */
  81988. _isSynchronized(): boolean;
  81989. /** @hidden */
  81990. _initCache(): void;
  81991. /**
  81992. * Flag the transform node as dirty (Forcing it to update everything)
  81993. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81994. * @returns this transform node
  81995. */
  81996. markAsDirty(property: string): TransformNode;
  81997. /**
  81998. * Returns the current mesh absolute position.
  81999. * Returns a Vector3.
  82000. */
  82001. readonly absolutePosition: Vector3;
  82002. /**
  82003. * Returns the current mesh absolute scaling.
  82004. * Returns a Vector3.
  82005. */
  82006. readonly absoluteScaling: Vector3;
  82007. /**
  82008. * Returns the current mesh absolute rotation.
  82009. * Returns a Quaternion.
  82010. */
  82011. readonly absoluteRotationQuaternion: Quaternion;
  82012. /**
  82013. * Sets a new matrix to apply before all other transformation
  82014. * @param matrix defines the transform matrix
  82015. * @returns the current TransformNode
  82016. */
  82017. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82018. /**
  82019. * Sets a new pivot matrix to the current node
  82020. * @param matrix defines the new pivot matrix to use
  82021. * @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
  82022. * @returns the current TransformNode
  82023. */
  82024. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82025. /**
  82026. * Returns the mesh pivot matrix.
  82027. * Default : Identity.
  82028. * @returns the matrix
  82029. */
  82030. getPivotMatrix(): Matrix;
  82031. /**
  82032. * Instantiate (when possible) or clone that node with its hierarchy
  82033. * @param newParent defines the new parent to use for the instance (or clone)
  82034. * @param options defines options to configure how copy is done
  82035. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82036. * @returns an instance (or a clone) of the current node with its hiearchy
  82037. */
  82038. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82039. doNotInstantiate: boolean;
  82040. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82041. /**
  82042. * Prevents the World matrix to be computed any longer
  82043. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82044. * @returns the TransformNode.
  82045. */
  82046. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82047. /**
  82048. * Allows back the World matrix computation.
  82049. * @returns the TransformNode.
  82050. */
  82051. unfreezeWorldMatrix(): this;
  82052. /**
  82053. * True if the World matrix has been frozen.
  82054. */
  82055. readonly isWorldMatrixFrozen: boolean;
  82056. /**
  82057. * Retuns the mesh absolute position in the World.
  82058. * @returns a Vector3.
  82059. */
  82060. getAbsolutePosition(): Vector3;
  82061. /**
  82062. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82063. * @param absolutePosition the absolute position to set
  82064. * @returns the TransformNode.
  82065. */
  82066. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82067. /**
  82068. * Sets the mesh position in its local space.
  82069. * @param vector3 the position to set in localspace
  82070. * @returns the TransformNode.
  82071. */
  82072. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82073. /**
  82074. * Returns the mesh position in the local space from the current World matrix values.
  82075. * @returns a new Vector3.
  82076. */
  82077. getPositionExpressedInLocalSpace(): Vector3;
  82078. /**
  82079. * Translates the mesh along the passed Vector3 in its local space.
  82080. * @param vector3 the distance to translate in localspace
  82081. * @returns the TransformNode.
  82082. */
  82083. locallyTranslate(vector3: Vector3): TransformNode;
  82084. private static _lookAtVectorCache;
  82085. /**
  82086. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82087. * @param targetPoint the position (must be in same space as current mesh) to look at
  82088. * @param yawCor optional yaw (y-axis) correction in radians
  82089. * @param pitchCor optional pitch (x-axis) correction in radians
  82090. * @param rollCor optional roll (z-axis) correction in radians
  82091. * @param space the choosen space of the target
  82092. * @returns the TransformNode.
  82093. */
  82094. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82095. /**
  82096. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82097. * This Vector3 is expressed in the World space.
  82098. * @param localAxis axis to rotate
  82099. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82100. */
  82101. getDirection(localAxis: Vector3): Vector3;
  82102. /**
  82103. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82104. * localAxis is expressed in the mesh local space.
  82105. * result is computed in the Wordl space from the mesh World matrix.
  82106. * @param localAxis axis to rotate
  82107. * @param result the resulting transformnode
  82108. * @returns this TransformNode.
  82109. */
  82110. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82111. /**
  82112. * Sets this transform node rotation to the given local axis.
  82113. * @param localAxis the axis in local space
  82114. * @param yawCor optional yaw (y-axis) correction in radians
  82115. * @param pitchCor optional pitch (x-axis) correction in radians
  82116. * @param rollCor optional roll (z-axis) correction in radians
  82117. * @returns this TransformNode
  82118. */
  82119. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82120. /**
  82121. * Sets a new pivot point to the current node
  82122. * @param point defines the new pivot point to use
  82123. * @param space defines if the point is in world or local space (local by default)
  82124. * @returns the current TransformNode
  82125. */
  82126. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82127. /**
  82128. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82129. * @returns the pivot point
  82130. */
  82131. getPivotPoint(): Vector3;
  82132. /**
  82133. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82134. * @param result the vector3 to store the result
  82135. * @returns this TransformNode.
  82136. */
  82137. getPivotPointToRef(result: Vector3): TransformNode;
  82138. /**
  82139. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82140. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82141. */
  82142. getAbsolutePivotPoint(): Vector3;
  82143. /**
  82144. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82145. * @param result vector3 to store the result
  82146. * @returns this TransformNode.
  82147. */
  82148. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82149. /**
  82150. * Defines the passed node as the parent of the current node.
  82151. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82152. * @see https://doc.babylonjs.com/how_to/parenting
  82153. * @param node the node ot set as the parent
  82154. * @returns this TransformNode.
  82155. */
  82156. setParent(node: Nullable<Node>): TransformNode;
  82157. private _nonUniformScaling;
  82158. /**
  82159. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82160. */
  82161. readonly nonUniformScaling: boolean;
  82162. /** @hidden */
  82163. _updateNonUniformScalingState(value: boolean): boolean;
  82164. /**
  82165. * Attach the current TransformNode to another TransformNode associated with a bone
  82166. * @param bone Bone affecting the TransformNode
  82167. * @param affectedTransformNode TransformNode associated with the bone
  82168. * @returns this object
  82169. */
  82170. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82171. /**
  82172. * Detach the transform node if its associated with a bone
  82173. * @returns this object
  82174. */
  82175. detachFromBone(): TransformNode;
  82176. private static _rotationAxisCache;
  82177. /**
  82178. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82179. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82180. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82181. * The passed axis is also normalized.
  82182. * @param axis the axis to rotate around
  82183. * @param amount the amount to rotate in radians
  82184. * @param space Space to rotate in (Default: local)
  82185. * @returns the TransformNode.
  82186. */
  82187. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82188. /**
  82189. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82190. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82191. * The passed axis is also normalized. .
  82192. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82193. * @param point the point to rotate around
  82194. * @param axis the axis to rotate around
  82195. * @param amount the amount to rotate in radians
  82196. * @returns the TransformNode
  82197. */
  82198. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82199. /**
  82200. * Translates the mesh along the axis vector for the passed distance in the given space.
  82201. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82202. * @param axis the axis to translate in
  82203. * @param distance the distance to translate
  82204. * @param space Space to rotate in (Default: local)
  82205. * @returns the TransformNode.
  82206. */
  82207. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82208. /**
  82209. * Adds a rotation step to the mesh current rotation.
  82210. * x, y, z are Euler angles expressed in radians.
  82211. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82212. * This means this rotation is made in the mesh local space only.
  82213. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82214. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82215. * ```javascript
  82216. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82217. * ```
  82218. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82219. * 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.
  82220. * @param x Rotation to add
  82221. * @param y Rotation to add
  82222. * @param z Rotation to add
  82223. * @returns the TransformNode.
  82224. */
  82225. addRotation(x: number, y: number, z: number): TransformNode;
  82226. /**
  82227. * @hidden
  82228. */
  82229. protected _getEffectiveParent(): Nullable<Node>;
  82230. /**
  82231. * Computes the world matrix of the node
  82232. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82233. * @returns the world matrix
  82234. */
  82235. computeWorldMatrix(force?: boolean): Matrix;
  82236. protected _afterComputeWorldMatrix(): void;
  82237. /**
  82238. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82239. * @param func callback function to add
  82240. *
  82241. * @returns the TransformNode.
  82242. */
  82243. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82244. /**
  82245. * Removes a registered callback function.
  82246. * @param func callback function to remove
  82247. * @returns the TransformNode.
  82248. */
  82249. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82250. /**
  82251. * Gets the position of the current mesh in camera space
  82252. * @param camera defines the camera to use
  82253. * @returns a position
  82254. */
  82255. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82256. /**
  82257. * Returns the distance from the mesh to the active camera
  82258. * @param camera defines the camera to use
  82259. * @returns the distance
  82260. */
  82261. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82262. /**
  82263. * Clone the current transform node
  82264. * @param name Name of the new clone
  82265. * @param newParent New parent for the clone
  82266. * @param doNotCloneChildren Do not clone children hierarchy
  82267. * @returns the new transform node
  82268. */
  82269. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82270. /**
  82271. * Serializes the objects information.
  82272. * @param currentSerializationObject defines the object to serialize in
  82273. * @returns the serialized object
  82274. */
  82275. serialize(currentSerializationObject?: any): any;
  82276. /**
  82277. * Returns a new TransformNode object parsed from the source provided.
  82278. * @param parsedTransformNode is the source.
  82279. * @param scene the scne the object belongs to
  82280. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82281. * @returns a new TransformNode object parsed from the source provided.
  82282. */
  82283. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82284. /**
  82285. * Get all child-transformNodes of this node
  82286. * @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
  82287. * @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
  82288. * @returns an array of TransformNode
  82289. */
  82290. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82291. /**
  82292. * Releases resources associated with this transform node.
  82293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82295. */
  82296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82297. /**
  82298. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82299. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82300. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82301. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82302. * @returns the current mesh
  82303. */
  82304. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82305. private _syncAbsoluteScalingAndRotation;
  82306. }
  82307. }
  82308. declare module BABYLON {
  82309. /**
  82310. * Defines the types of pose enabled controllers that are supported
  82311. */
  82312. export enum PoseEnabledControllerType {
  82313. /**
  82314. * HTC Vive
  82315. */
  82316. VIVE = 0,
  82317. /**
  82318. * Oculus Rift
  82319. */
  82320. OCULUS = 1,
  82321. /**
  82322. * Windows mixed reality
  82323. */
  82324. WINDOWS = 2,
  82325. /**
  82326. * Samsung gear VR
  82327. */
  82328. GEAR_VR = 3,
  82329. /**
  82330. * Google Daydream
  82331. */
  82332. DAYDREAM = 4,
  82333. /**
  82334. * Generic
  82335. */
  82336. GENERIC = 5
  82337. }
  82338. /**
  82339. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82340. */
  82341. export interface MutableGamepadButton {
  82342. /**
  82343. * Value of the button/trigger
  82344. */
  82345. value: number;
  82346. /**
  82347. * If the button/trigger is currently touched
  82348. */
  82349. touched: boolean;
  82350. /**
  82351. * If the button/trigger is currently pressed
  82352. */
  82353. pressed: boolean;
  82354. }
  82355. /**
  82356. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82357. * @hidden
  82358. */
  82359. export interface ExtendedGamepadButton extends GamepadButton {
  82360. /**
  82361. * If the button/trigger is currently pressed
  82362. */
  82363. readonly pressed: boolean;
  82364. /**
  82365. * If the button/trigger is currently touched
  82366. */
  82367. readonly touched: boolean;
  82368. /**
  82369. * Value of the button/trigger
  82370. */
  82371. readonly value: number;
  82372. }
  82373. /** @hidden */
  82374. export interface _GamePadFactory {
  82375. /**
  82376. * Returns wether or not the current gamepad can be created for this type of controller.
  82377. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82378. * @returns true if it can be created, otherwise false
  82379. */
  82380. canCreate(gamepadInfo: any): boolean;
  82381. /**
  82382. * Creates a new instance of the Gamepad.
  82383. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82384. * @returns the new gamepad instance
  82385. */
  82386. create(gamepadInfo: any): Gamepad;
  82387. }
  82388. /**
  82389. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82390. */
  82391. export class PoseEnabledControllerHelper {
  82392. /** @hidden */
  82393. static _ControllerFactories: _GamePadFactory[];
  82394. /** @hidden */
  82395. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82396. /**
  82397. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82398. * @param vrGamepad the gamepad to initialized
  82399. * @returns a vr controller of the type the gamepad identified as
  82400. */
  82401. static InitiateController(vrGamepad: any): Gamepad;
  82402. }
  82403. /**
  82404. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82405. */
  82406. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82407. /**
  82408. * If the controller is used in a webXR session
  82409. */
  82410. isXR: boolean;
  82411. private _deviceRoomPosition;
  82412. private _deviceRoomRotationQuaternion;
  82413. /**
  82414. * The device position in babylon space
  82415. */
  82416. devicePosition: Vector3;
  82417. /**
  82418. * The device rotation in babylon space
  82419. */
  82420. deviceRotationQuaternion: Quaternion;
  82421. /**
  82422. * The scale factor of the device in babylon space
  82423. */
  82424. deviceScaleFactor: number;
  82425. /**
  82426. * (Likely devicePosition should be used instead) The device position in its room space
  82427. */
  82428. position: Vector3;
  82429. /**
  82430. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82431. */
  82432. rotationQuaternion: Quaternion;
  82433. /**
  82434. * The type of controller (Eg. Windows mixed reality)
  82435. */
  82436. controllerType: PoseEnabledControllerType;
  82437. protected _calculatedPosition: Vector3;
  82438. private _calculatedRotation;
  82439. /**
  82440. * The raw pose from the device
  82441. */
  82442. rawPose: DevicePose;
  82443. private _trackPosition;
  82444. private _maxRotationDistFromHeadset;
  82445. private _draggedRoomRotation;
  82446. /**
  82447. * @hidden
  82448. */
  82449. _disableTrackPosition(fixedPosition: Vector3): void;
  82450. /**
  82451. * Internal, the mesh attached to the controller
  82452. * @hidden
  82453. */
  82454. _mesh: Nullable<AbstractMesh>;
  82455. private _poseControlledCamera;
  82456. private _leftHandSystemQuaternion;
  82457. /**
  82458. * Internal, matrix used to convert room space to babylon space
  82459. * @hidden
  82460. */
  82461. _deviceToWorld: Matrix;
  82462. /**
  82463. * Node to be used when casting a ray from the controller
  82464. * @hidden
  82465. */
  82466. _pointingPoseNode: Nullable<TransformNode>;
  82467. /**
  82468. * Name of the child mesh that can be used to cast a ray from the controller
  82469. */
  82470. static readonly POINTING_POSE: string;
  82471. /**
  82472. * Creates a new PoseEnabledController from a gamepad
  82473. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82474. */
  82475. constructor(browserGamepad: any);
  82476. private _workingMatrix;
  82477. /**
  82478. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82479. */
  82480. update(): void;
  82481. /**
  82482. * Updates only the pose device and mesh without doing any button event checking
  82483. */
  82484. protected _updatePoseAndMesh(): void;
  82485. /**
  82486. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82487. * @param poseData raw pose fromthe device
  82488. */
  82489. updateFromDevice(poseData: DevicePose): void;
  82490. /**
  82491. * @hidden
  82492. */
  82493. _meshAttachedObservable: Observable<AbstractMesh>;
  82494. /**
  82495. * Attaches a mesh to the controller
  82496. * @param mesh the mesh to be attached
  82497. */
  82498. attachToMesh(mesh: AbstractMesh): void;
  82499. /**
  82500. * Attaches the controllers mesh to a camera
  82501. * @param camera the camera the mesh should be attached to
  82502. */
  82503. attachToPoseControlledCamera(camera: TargetCamera): void;
  82504. /**
  82505. * Disposes of the controller
  82506. */
  82507. dispose(): void;
  82508. /**
  82509. * The mesh that is attached to the controller
  82510. */
  82511. readonly mesh: Nullable<AbstractMesh>;
  82512. /**
  82513. * Gets the ray of the controller in the direction the controller is pointing
  82514. * @param length the length the resulting ray should be
  82515. * @returns a ray in the direction the controller is pointing
  82516. */
  82517. getForwardRay(length?: number): Ray;
  82518. }
  82519. }
  82520. declare module BABYLON {
  82521. /**
  82522. * Defines the WebVRController object that represents controllers tracked in 3D space
  82523. */
  82524. export abstract class WebVRController extends PoseEnabledController {
  82525. /**
  82526. * Internal, the default controller model for the controller
  82527. */
  82528. protected _defaultModel: Nullable<AbstractMesh>;
  82529. /**
  82530. * Fired when the trigger state has changed
  82531. */
  82532. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82533. /**
  82534. * Fired when the main button state has changed
  82535. */
  82536. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82537. /**
  82538. * Fired when the secondary button state has changed
  82539. */
  82540. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82541. /**
  82542. * Fired when the pad state has changed
  82543. */
  82544. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82545. /**
  82546. * Fired when controllers stick values have changed
  82547. */
  82548. onPadValuesChangedObservable: Observable<StickValues>;
  82549. /**
  82550. * Array of button availible on the controller
  82551. */
  82552. protected _buttons: Array<MutableGamepadButton>;
  82553. private _onButtonStateChange;
  82554. /**
  82555. * Fired when a controller button's state has changed
  82556. * @param callback the callback containing the button that was modified
  82557. */
  82558. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82559. /**
  82560. * X and Y axis corresponding to the controllers joystick
  82561. */
  82562. pad: StickValues;
  82563. /**
  82564. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82565. */
  82566. hand: string;
  82567. /**
  82568. * The default controller model for the controller
  82569. */
  82570. readonly defaultModel: Nullable<AbstractMesh>;
  82571. /**
  82572. * Creates a new WebVRController from a gamepad
  82573. * @param vrGamepad the gamepad that the WebVRController should be created from
  82574. */
  82575. constructor(vrGamepad: any);
  82576. /**
  82577. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82578. */
  82579. update(): void;
  82580. /**
  82581. * Function to be called when a button is modified
  82582. */
  82583. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82584. /**
  82585. * Loads a mesh and attaches it to the controller
  82586. * @param scene the scene the mesh should be added to
  82587. * @param meshLoaded callback for when the mesh has been loaded
  82588. */
  82589. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82590. private _setButtonValue;
  82591. private _changes;
  82592. private _checkChanges;
  82593. /**
  82594. * Disposes of th webVRCOntroller
  82595. */
  82596. dispose(): void;
  82597. }
  82598. }
  82599. declare module BABYLON {
  82600. /**
  82601. * The HemisphericLight simulates the ambient environment light,
  82602. * so the passed direction is the light reflection direction, not the incoming direction.
  82603. */
  82604. export class HemisphericLight extends Light {
  82605. /**
  82606. * The groundColor is the light in the opposite direction to the one specified during creation.
  82607. * 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.
  82608. */
  82609. groundColor: Color3;
  82610. /**
  82611. * The light reflection direction, not the incoming direction.
  82612. */
  82613. direction: Vector3;
  82614. /**
  82615. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82616. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82617. * The HemisphericLight can't cast shadows.
  82618. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82619. * @param name The friendly name of the light
  82620. * @param direction The direction of the light reflection
  82621. * @param scene The scene the light belongs to
  82622. */
  82623. constructor(name: string, direction: Vector3, scene: Scene);
  82624. protected _buildUniformLayout(): void;
  82625. /**
  82626. * Returns the string "HemisphericLight".
  82627. * @return The class name
  82628. */
  82629. getClassName(): string;
  82630. /**
  82631. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82632. * Returns the updated direction.
  82633. * @param target The target the direction should point to
  82634. * @return The computed direction
  82635. */
  82636. setDirectionToTarget(target: Vector3): Vector3;
  82637. /**
  82638. * Returns the shadow generator associated to the light.
  82639. * @returns Always null for hemispheric lights because it does not support shadows.
  82640. */
  82641. getShadowGenerator(): Nullable<IShadowGenerator>;
  82642. /**
  82643. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82644. * @param effect The effect to update
  82645. * @param lightIndex The index of the light in the effect to update
  82646. * @returns The hemispheric light
  82647. */
  82648. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82649. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82650. /**
  82651. * Computes the world matrix of the node
  82652. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82653. * @param useWasUpdatedFlag defines a reserved property
  82654. * @returns the world matrix
  82655. */
  82656. computeWorldMatrix(): Matrix;
  82657. /**
  82658. * Returns the integer 3.
  82659. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82660. */
  82661. getTypeID(): number;
  82662. /**
  82663. * Prepares the list of defines specific to the light type.
  82664. * @param defines the list of defines
  82665. * @param lightIndex defines the index of the light for the effect
  82666. */
  82667. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82668. }
  82669. }
  82670. declare module BABYLON {
  82671. /** @hidden */
  82672. export var vrMultiviewToSingleviewPixelShader: {
  82673. name: string;
  82674. shader: string;
  82675. };
  82676. }
  82677. declare module BABYLON {
  82678. /**
  82679. * Renders to multiple views with a single draw call
  82680. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82681. */
  82682. export class MultiviewRenderTarget extends RenderTargetTexture {
  82683. /**
  82684. * Creates a multiview render target
  82685. * @param scene scene used with the render target
  82686. * @param size the size of the render target (used for each view)
  82687. */
  82688. constructor(scene: Scene, size?: number | {
  82689. width: number;
  82690. height: number;
  82691. } | {
  82692. ratio: number;
  82693. });
  82694. /**
  82695. * @hidden
  82696. * @param faceIndex the face index, if its a cube texture
  82697. */
  82698. _bindFrameBuffer(faceIndex?: number): void;
  82699. /**
  82700. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82701. * @returns the view count
  82702. */
  82703. getViewCount(): number;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /**
  82708. * Represents a camera frustum
  82709. */
  82710. export class Frustum {
  82711. /**
  82712. * Gets the planes representing the frustum
  82713. * @param transform matrix to be applied to the returned planes
  82714. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82715. */
  82716. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82717. /**
  82718. * Gets the near frustum plane transformed by the transform matrix
  82719. * @param transform transformation matrix to be applied to the resulting frustum plane
  82720. * @param frustumPlane the resuling frustum plane
  82721. */
  82722. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82723. /**
  82724. * Gets the far frustum plane transformed by the transform matrix
  82725. * @param transform transformation matrix to be applied to the resulting frustum plane
  82726. * @param frustumPlane the resuling frustum plane
  82727. */
  82728. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82729. /**
  82730. * Gets the left frustum plane transformed by the transform matrix
  82731. * @param transform transformation matrix to be applied to the resulting frustum plane
  82732. * @param frustumPlane the resuling frustum plane
  82733. */
  82734. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82735. /**
  82736. * Gets the right frustum plane transformed by the transform matrix
  82737. * @param transform transformation matrix to be applied to the resulting frustum plane
  82738. * @param frustumPlane the resuling frustum plane
  82739. */
  82740. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82741. /**
  82742. * Gets the top frustum plane transformed by the transform matrix
  82743. * @param transform transformation matrix to be applied to the resulting frustum plane
  82744. * @param frustumPlane the resuling frustum plane
  82745. */
  82746. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82747. /**
  82748. * Gets the bottom frustum plane transformed by the transform matrix
  82749. * @param transform transformation matrix to be applied to the resulting frustum plane
  82750. * @param frustumPlane the resuling frustum plane
  82751. */
  82752. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82753. /**
  82754. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82755. * @param transform transformation matrix to be applied to the resulting frustum planes
  82756. * @param frustumPlanes the resuling frustum planes
  82757. */
  82758. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82759. }
  82760. }
  82761. declare module BABYLON {
  82762. interface Engine {
  82763. /**
  82764. * Creates a new multiview render target
  82765. * @param width defines the width of the texture
  82766. * @param height defines the height of the texture
  82767. * @returns the created multiview texture
  82768. */
  82769. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82770. /**
  82771. * Binds a multiview framebuffer to be drawn to
  82772. * @param multiviewTexture texture to bind
  82773. */
  82774. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82775. }
  82776. interface Camera {
  82777. /**
  82778. * @hidden
  82779. * 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)
  82780. */
  82781. _useMultiviewToSingleView: boolean;
  82782. /**
  82783. * @hidden
  82784. * 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)
  82785. */
  82786. _multiviewTexture: Nullable<RenderTargetTexture>;
  82787. /**
  82788. * @hidden
  82789. * ensures the multiview texture of the camera exists and has the specified width/height
  82790. * @param width height to set on the multiview texture
  82791. * @param height width to set on the multiview texture
  82792. */
  82793. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82794. }
  82795. interface Scene {
  82796. /** @hidden */
  82797. _transformMatrixR: Matrix;
  82798. /** @hidden */
  82799. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82800. /** @hidden */
  82801. _createMultiviewUbo(): void;
  82802. /** @hidden */
  82803. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82804. /** @hidden */
  82805. _renderMultiviewToSingleView(camera: Camera): void;
  82806. }
  82807. }
  82808. declare module BABYLON {
  82809. /**
  82810. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82811. * This will not be used for webXR as it supports displaying texture arrays directly
  82812. */
  82813. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82814. /**
  82815. * Initializes a VRMultiviewToSingleview
  82816. * @param name name of the post process
  82817. * @param camera camera to be applied to
  82818. * @param scaleFactor scaling factor to the size of the output texture
  82819. */
  82820. constructor(name: string, camera: Camera, scaleFactor: number);
  82821. }
  82822. }
  82823. declare module BABYLON {
  82824. /**
  82825. * Interface used to define additional presentation attributes
  82826. */
  82827. export interface IVRPresentationAttributes {
  82828. /**
  82829. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  82830. */
  82831. highRefreshRate: boolean;
  82832. /**
  82833. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  82834. */
  82835. foveationLevel: number;
  82836. }
  82837. interface Engine {
  82838. /** @hidden */
  82839. _vrDisplay: any;
  82840. /** @hidden */
  82841. _vrSupported: boolean;
  82842. /** @hidden */
  82843. _oldSize: Size;
  82844. /** @hidden */
  82845. _oldHardwareScaleFactor: number;
  82846. /** @hidden */
  82847. _vrExclusivePointerMode: boolean;
  82848. /** @hidden */
  82849. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82850. /** @hidden */
  82851. _onVRDisplayPointerRestricted: () => void;
  82852. /** @hidden */
  82853. _onVRDisplayPointerUnrestricted: () => void;
  82854. /** @hidden */
  82855. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82856. /** @hidden */
  82857. _onVrDisplayDisconnect: Nullable<() => void>;
  82858. /** @hidden */
  82859. _onVrDisplayPresentChange: Nullable<() => void>;
  82860. /**
  82861. * Observable signaled when VR display mode changes
  82862. */
  82863. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82864. /**
  82865. * Observable signaled when VR request present is complete
  82866. */
  82867. onVRRequestPresentComplete: Observable<boolean>;
  82868. /**
  82869. * Observable signaled when VR request present starts
  82870. */
  82871. onVRRequestPresentStart: Observable<Engine>;
  82872. /**
  82873. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82874. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82875. */
  82876. isInVRExclusivePointerMode: boolean;
  82877. /**
  82878. * Gets a boolean indicating if a webVR device was detected
  82879. * @returns true if a webVR device was detected
  82880. */
  82881. isVRDevicePresent(): boolean;
  82882. /**
  82883. * Gets the current webVR device
  82884. * @returns the current webVR device (or null)
  82885. */
  82886. getVRDevice(): any;
  82887. /**
  82888. * Initializes a webVR display and starts listening to display change events
  82889. * The onVRDisplayChangedObservable will be notified upon these changes
  82890. * @returns A promise containing a VRDisplay and if vr is supported
  82891. */
  82892. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82893. /** @hidden */
  82894. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82895. /**
  82896. * Gets or sets the presentation attributes used to configure VR rendering
  82897. */
  82898. vrPresentationAttributes?: IVRPresentationAttributes;
  82899. /**
  82900. * Call this function to switch to webVR mode
  82901. * Will do nothing if webVR is not supported or if there is no webVR device
  82902. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82903. */
  82904. enableVR(): void;
  82905. /** @hidden */
  82906. _onVRFullScreenTriggered(): void;
  82907. }
  82908. }
  82909. declare module BABYLON {
  82910. /**
  82911. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82912. * IMPORTANT!! The data is right-hand data.
  82913. * @export
  82914. * @interface DevicePose
  82915. */
  82916. export interface DevicePose {
  82917. /**
  82918. * The position of the device, values in array are [x,y,z].
  82919. */
  82920. readonly position: Nullable<Float32Array>;
  82921. /**
  82922. * The linearVelocity of the device, values in array are [x,y,z].
  82923. */
  82924. readonly linearVelocity: Nullable<Float32Array>;
  82925. /**
  82926. * The linearAcceleration of the device, values in array are [x,y,z].
  82927. */
  82928. readonly linearAcceleration: Nullable<Float32Array>;
  82929. /**
  82930. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82931. */
  82932. readonly orientation: Nullable<Float32Array>;
  82933. /**
  82934. * The angularVelocity of the device, values in array are [x,y,z].
  82935. */
  82936. readonly angularVelocity: Nullable<Float32Array>;
  82937. /**
  82938. * The angularAcceleration of the device, values in array are [x,y,z].
  82939. */
  82940. readonly angularAcceleration: Nullable<Float32Array>;
  82941. }
  82942. /**
  82943. * Interface representing a pose controlled object in Babylon.
  82944. * A pose controlled object has both regular pose values as well as pose values
  82945. * from an external device such as a VR head mounted display
  82946. */
  82947. export interface PoseControlled {
  82948. /**
  82949. * The position of the object in babylon space.
  82950. */
  82951. position: Vector3;
  82952. /**
  82953. * The rotation quaternion of the object in babylon space.
  82954. */
  82955. rotationQuaternion: Quaternion;
  82956. /**
  82957. * The position of the device in babylon space.
  82958. */
  82959. devicePosition?: Vector3;
  82960. /**
  82961. * The rotation quaternion of the device in babylon space.
  82962. */
  82963. deviceRotationQuaternion: Quaternion;
  82964. /**
  82965. * The raw pose coming from the device.
  82966. */
  82967. rawPose: Nullable<DevicePose>;
  82968. /**
  82969. * The scale of the device to be used when translating from device space to babylon space.
  82970. */
  82971. deviceScaleFactor: number;
  82972. /**
  82973. * Updates the poseControlled values based on the input device pose.
  82974. * @param poseData the pose data to update the object with
  82975. */
  82976. updateFromDevice(poseData: DevicePose): void;
  82977. }
  82978. /**
  82979. * Set of options to customize the webVRCamera
  82980. */
  82981. export interface WebVROptions {
  82982. /**
  82983. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82984. */
  82985. trackPosition?: boolean;
  82986. /**
  82987. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82988. */
  82989. positionScale?: number;
  82990. /**
  82991. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82992. */
  82993. displayName?: string;
  82994. /**
  82995. * Should the native controller meshes be initialized. (default: true)
  82996. */
  82997. controllerMeshes?: boolean;
  82998. /**
  82999. * Creating a default HemiLight only on controllers. (default: true)
  83000. */
  83001. defaultLightingOnControllers?: boolean;
  83002. /**
  83003. * If you don't want to use the default VR button of the helper. (default: false)
  83004. */
  83005. useCustomVRButton?: boolean;
  83006. /**
  83007. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83008. */
  83009. customVRButton?: HTMLButtonElement;
  83010. /**
  83011. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83012. */
  83013. rayLength?: number;
  83014. /**
  83015. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83016. */
  83017. defaultHeight?: number;
  83018. /**
  83019. * If multiview should be used if availible (default: false)
  83020. */
  83021. useMultiview?: boolean;
  83022. }
  83023. /**
  83024. * This represents a WebVR camera.
  83025. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83026. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83027. */
  83028. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83029. private webVROptions;
  83030. /**
  83031. * @hidden
  83032. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83033. */
  83034. _vrDevice: any;
  83035. /**
  83036. * The rawPose of the vrDevice.
  83037. */
  83038. rawPose: Nullable<DevicePose>;
  83039. private _onVREnabled;
  83040. private _specsVersion;
  83041. private _attached;
  83042. private _frameData;
  83043. protected _descendants: Array<Node>;
  83044. private _deviceRoomPosition;
  83045. /** @hidden */
  83046. _deviceRoomRotationQuaternion: Quaternion;
  83047. private _standingMatrix;
  83048. /**
  83049. * Represents device position in babylon space.
  83050. */
  83051. devicePosition: Vector3;
  83052. /**
  83053. * Represents device rotation in babylon space.
  83054. */
  83055. deviceRotationQuaternion: Quaternion;
  83056. /**
  83057. * The scale of the device to be used when translating from device space to babylon space.
  83058. */
  83059. deviceScaleFactor: number;
  83060. private _deviceToWorld;
  83061. private _worldToDevice;
  83062. /**
  83063. * References to the webVR controllers for the vrDevice.
  83064. */
  83065. controllers: Array<WebVRController>;
  83066. /**
  83067. * Emits an event when a controller is attached.
  83068. */
  83069. onControllersAttachedObservable: Observable<WebVRController[]>;
  83070. /**
  83071. * Emits an event when a controller's mesh has been loaded;
  83072. */
  83073. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83074. /**
  83075. * Emits an event when the HMD's pose has been updated.
  83076. */
  83077. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83078. private _poseSet;
  83079. /**
  83080. * If the rig cameras be used as parent instead of this camera.
  83081. */
  83082. rigParenting: boolean;
  83083. private _lightOnControllers;
  83084. private _defaultHeight?;
  83085. /**
  83086. * Instantiates a WebVRFreeCamera.
  83087. * @param name The name of the WebVRFreeCamera
  83088. * @param position The starting anchor position for the camera
  83089. * @param scene The scene the camera belongs to
  83090. * @param webVROptions a set of customizable options for the webVRCamera
  83091. */
  83092. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83093. /**
  83094. * Gets the device distance from the ground in meters.
  83095. * @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.
  83096. */
  83097. deviceDistanceToRoomGround(): number;
  83098. /**
  83099. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83100. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83101. */
  83102. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83103. /**
  83104. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83105. * @returns A promise with a boolean set to if the standing matrix is supported.
  83106. */
  83107. useStandingMatrixAsync(): Promise<boolean>;
  83108. /**
  83109. * Disposes the camera
  83110. */
  83111. dispose(): void;
  83112. /**
  83113. * Gets a vrController by name.
  83114. * @param name The name of the controller to retreive
  83115. * @returns the controller matching the name specified or null if not found
  83116. */
  83117. getControllerByName(name: string): Nullable<WebVRController>;
  83118. private _leftController;
  83119. /**
  83120. * The controller corresponding to the users left hand.
  83121. */
  83122. readonly leftController: Nullable<WebVRController>;
  83123. private _rightController;
  83124. /**
  83125. * The controller corresponding to the users right hand.
  83126. */
  83127. readonly rightController: Nullable<WebVRController>;
  83128. /**
  83129. * Casts a ray forward from the vrCamera's gaze.
  83130. * @param length Length of the ray (default: 100)
  83131. * @returns the ray corresponding to the gaze
  83132. */
  83133. getForwardRay(length?: number): Ray;
  83134. /**
  83135. * @hidden
  83136. * Updates the camera based on device's frame data
  83137. */
  83138. _checkInputs(): void;
  83139. /**
  83140. * Updates the poseControlled values based on the input device pose.
  83141. * @param poseData Pose coming from the device
  83142. */
  83143. updateFromDevice(poseData: DevicePose): void;
  83144. private _htmlElementAttached;
  83145. private _detachIfAttached;
  83146. /**
  83147. * WebVR's attach control will start broadcasting frames to the device.
  83148. * Note that in certain browsers (chrome for example) this function must be called
  83149. * within a user-interaction callback. Example:
  83150. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83151. *
  83152. * @param element html element to attach the vrDevice to
  83153. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83154. */
  83155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83156. /**
  83157. * Detaches the camera from the html element and disables VR
  83158. *
  83159. * @param element html element to detach from
  83160. */
  83161. detachControl(element: HTMLElement): void;
  83162. /**
  83163. * @returns the name of this class
  83164. */
  83165. getClassName(): string;
  83166. /**
  83167. * Calls resetPose on the vrDisplay
  83168. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83169. */
  83170. resetToCurrentRotation(): void;
  83171. /**
  83172. * @hidden
  83173. * Updates the rig cameras (left and right eye)
  83174. */
  83175. _updateRigCameras(): void;
  83176. private _workingVector;
  83177. private _oneVector;
  83178. private _workingMatrix;
  83179. private updateCacheCalled;
  83180. private _correctPositionIfNotTrackPosition;
  83181. /**
  83182. * @hidden
  83183. * Updates the cached values of the camera
  83184. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83185. */
  83186. _updateCache(ignoreParentClass?: boolean): void;
  83187. /**
  83188. * @hidden
  83189. * Get current device position in babylon world
  83190. */
  83191. _computeDevicePosition(): void;
  83192. /**
  83193. * Updates the current device position and rotation in the babylon world
  83194. */
  83195. update(): void;
  83196. /**
  83197. * @hidden
  83198. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83199. * @returns an identity matrix
  83200. */
  83201. _getViewMatrix(): Matrix;
  83202. private _tmpMatrix;
  83203. /**
  83204. * This function is called by the two RIG cameras.
  83205. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83206. * @hidden
  83207. */
  83208. _getWebVRViewMatrix(): Matrix;
  83209. /** @hidden */
  83210. _getWebVRProjectionMatrix(): Matrix;
  83211. private _onGamepadConnectedObserver;
  83212. private _onGamepadDisconnectedObserver;
  83213. private _updateCacheWhenTrackingDisabledObserver;
  83214. /**
  83215. * Initializes the controllers and their meshes
  83216. */
  83217. initControllers(): void;
  83218. }
  83219. }
  83220. declare module BABYLON {
  83221. /**
  83222. * Size options for a post process
  83223. */
  83224. export type PostProcessOptions = {
  83225. width: number;
  83226. height: number;
  83227. };
  83228. /**
  83229. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83230. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83231. */
  83232. export class PostProcess {
  83233. /** Name of the PostProcess. */
  83234. name: string;
  83235. /**
  83236. * Gets or sets the unique id of the post process
  83237. */
  83238. uniqueId: number;
  83239. /**
  83240. * Width of the texture to apply the post process on
  83241. */
  83242. width: number;
  83243. /**
  83244. * Height of the texture to apply the post process on
  83245. */
  83246. height: number;
  83247. /**
  83248. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83249. * @hidden
  83250. */
  83251. _outputTexture: Nullable<InternalTexture>;
  83252. /**
  83253. * Sampling mode used by the shader
  83254. * See https://doc.babylonjs.com/classes/3.1/texture
  83255. */
  83256. renderTargetSamplingMode: number;
  83257. /**
  83258. * Clear color to use when screen clearing
  83259. */
  83260. clearColor: Color4;
  83261. /**
  83262. * If the buffer needs to be cleared before applying the post process. (default: true)
  83263. * Should be set to false if shader will overwrite all previous pixels.
  83264. */
  83265. autoClear: boolean;
  83266. /**
  83267. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83268. */
  83269. alphaMode: number;
  83270. /**
  83271. * Sets the setAlphaBlendConstants of the babylon engine
  83272. */
  83273. alphaConstants: Color4;
  83274. /**
  83275. * Animations to be used for the post processing
  83276. */
  83277. animations: Animation[];
  83278. /**
  83279. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83280. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83281. */
  83282. enablePixelPerfectMode: boolean;
  83283. /**
  83284. * Force the postprocess to be applied without taking in account viewport
  83285. */
  83286. forceFullscreenViewport: boolean;
  83287. /**
  83288. * List of inspectable custom properties (used by the Inspector)
  83289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83290. */
  83291. inspectableCustomProperties: IInspectable[];
  83292. /**
  83293. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83294. *
  83295. * | Value | Type | Description |
  83296. * | ----- | ----------------------------------- | ----------- |
  83297. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83298. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83299. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83300. *
  83301. */
  83302. scaleMode: number;
  83303. /**
  83304. * Force textures to be a power of two (default: false)
  83305. */
  83306. alwaysForcePOT: boolean;
  83307. private _samples;
  83308. /**
  83309. * Number of sample textures (default: 1)
  83310. */
  83311. samples: number;
  83312. /**
  83313. * Modify the scale of the post process to be the same as the viewport (default: false)
  83314. */
  83315. adaptScaleToCurrentViewport: boolean;
  83316. private _camera;
  83317. private _scene;
  83318. private _engine;
  83319. private _options;
  83320. private _reusable;
  83321. private _textureType;
  83322. /**
  83323. * Smart array of input and output textures for the post process.
  83324. * @hidden
  83325. */
  83326. _textures: SmartArray<InternalTexture>;
  83327. /**
  83328. * The index in _textures that corresponds to the output texture.
  83329. * @hidden
  83330. */
  83331. _currentRenderTextureInd: number;
  83332. private _effect;
  83333. private _samplers;
  83334. private _fragmentUrl;
  83335. private _vertexUrl;
  83336. private _parameters;
  83337. private _scaleRatio;
  83338. protected _indexParameters: any;
  83339. private _shareOutputWithPostProcess;
  83340. private _texelSize;
  83341. private _forcedOutputTexture;
  83342. /**
  83343. * Returns the fragment url or shader name used in the post process.
  83344. * @returns the fragment url or name in the shader store.
  83345. */
  83346. getEffectName(): string;
  83347. /**
  83348. * An event triggered when the postprocess is activated.
  83349. */
  83350. onActivateObservable: Observable<Camera>;
  83351. private _onActivateObserver;
  83352. /**
  83353. * A function that is added to the onActivateObservable
  83354. */
  83355. onActivate: Nullable<(camera: Camera) => void>;
  83356. /**
  83357. * An event triggered when the postprocess changes its size.
  83358. */
  83359. onSizeChangedObservable: Observable<PostProcess>;
  83360. private _onSizeChangedObserver;
  83361. /**
  83362. * A function that is added to the onSizeChangedObservable
  83363. */
  83364. onSizeChanged: (postProcess: PostProcess) => void;
  83365. /**
  83366. * An event triggered when the postprocess applies its effect.
  83367. */
  83368. onApplyObservable: Observable<Effect>;
  83369. private _onApplyObserver;
  83370. /**
  83371. * A function that is added to the onApplyObservable
  83372. */
  83373. onApply: (effect: Effect) => void;
  83374. /**
  83375. * An event triggered before rendering the postprocess
  83376. */
  83377. onBeforeRenderObservable: Observable<Effect>;
  83378. private _onBeforeRenderObserver;
  83379. /**
  83380. * A function that is added to the onBeforeRenderObservable
  83381. */
  83382. onBeforeRender: (effect: Effect) => void;
  83383. /**
  83384. * An event triggered after rendering the postprocess
  83385. */
  83386. onAfterRenderObservable: Observable<Effect>;
  83387. private _onAfterRenderObserver;
  83388. /**
  83389. * A function that is added to the onAfterRenderObservable
  83390. */
  83391. onAfterRender: (efect: Effect) => void;
  83392. /**
  83393. * 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
  83394. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83395. */
  83396. inputTexture: InternalTexture;
  83397. /**
  83398. * Gets the camera which post process is applied to.
  83399. * @returns The camera the post process is applied to.
  83400. */
  83401. getCamera(): Camera;
  83402. /**
  83403. * Gets the texel size of the postprocess.
  83404. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83405. */
  83406. readonly texelSize: Vector2;
  83407. /**
  83408. * Creates a new instance PostProcess
  83409. * @param name The name of the PostProcess.
  83410. * @param fragmentUrl The url of the fragment shader to be used.
  83411. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83412. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83413. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83414. * @param camera The camera to apply the render pass to.
  83415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83416. * @param engine The engine which the post process will be applied. (default: current engine)
  83417. * @param reusable If the post process can be reused on the same frame. (default: false)
  83418. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83419. * @param textureType Type of textures used when performing the post process. (default: 0)
  83420. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83421. * @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
  83422. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83423. */
  83424. constructor(
  83425. /** Name of the PostProcess. */
  83426. 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);
  83427. /**
  83428. * Gets a string idenfifying the name of the class
  83429. * @returns "PostProcess" string
  83430. */
  83431. getClassName(): string;
  83432. /**
  83433. * Gets the engine which this post process belongs to.
  83434. * @returns The engine the post process was enabled with.
  83435. */
  83436. getEngine(): Engine;
  83437. /**
  83438. * The effect that is created when initializing the post process.
  83439. * @returns The created effect corresponding the the postprocess.
  83440. */
  83441. getEffect(): Effect;
  83442. /**
  83443. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83444. * @param postProcess The post process to share the output with.
  83445. * @returns This post process.
  83446. */
  83447. shareOutputWith(postProcess: PostProcess): PostProcess;
  83448. /**
  83449. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83450. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83451. */
  83452. useOwnOutput(): void;
  83453. /**
  83454. * Updates the effect with the current post process compile time values and recompiles the shader.
  83455. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83456. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83457. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83458. * @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
  83459. * @param onCompiled Called when the shader has been compiled.
  83460. * @param onError Called if there is an error when compiling a shader.
  83461. */
  83462. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83463. /**
  83464. * The post process is reusable if it can be used multiple times within one frame.
  83465. * @returns If the post process is reusable
  83466. */
  83467. isReusable(): boolean;
  83468. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83469. markTextureDirty(): void;
  83470. /**
  83471. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83472. * 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.
  83473. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83474. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83475. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83476. * @returns The target texture that was bound to be written to.
  83477. */
  83478. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83479. /**
  83480. * If the post process is supported.
  83481. */
  83482. readonly isSupported: boolean;
  83483. /**
  83484. * The aspect ratio of the output texture.
  83485. */
  83486. readonly aspectRatio: number;
  83487. /**
  83488. * Get a value indicating if the post-process is ready to be used
  83489. * @returns true if the post-process is ready (shader is compiled)
  83490. */
  83491. isReady(): boolean;
  83492. /**
  83493. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83494. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83495. */
  83496. apply(): Nullable<Effect>;
  83497. private _disposeTextures;
  83498. /**
  83499. * Disposes the post process.
  83500. * @param camera The camera to dispose the post process on.
  83501. */
  83502. dispose(camera?: Camera): void;
  83503. }
  83504. }
  83505. declare module BABYLON {
  83506. /** @hidden */
  83507. export var kernelBlurVaryingDeclaration: {
  83508. name: string;
  83509. shader: string;
  83510. };
  83511. }
  83512. declare module BABYLON {
  83513. /** @hidden */
  83514. export var kernelBlurFragment: {
  83515. name: string;
  83516. shader: string;
  83517. };
  83518. }
  83519. declare module BABYLON {
  83520. /** @hidden */
  83521. export var kernelBlurFragment2: {
  83522. name: string;
  83523. shader: string;
  83524. };
  83525. }
  83526. declare module BABYLON {
  83527. /** @hidden */
  83528. export var kernelBlurPixelShader: {
  83529. name: string;
  83530. shader: string;
  83531. };
  83532. }
  83533. declare module BABYLON {
  83534. /** @hidden */
  83535. export var kernelBlurVertex: {
  83536. name: string;
  83537. shader: string;
  83538. };
  83539. }
  83540. declare module BABYLON {
  83541. /** @hidden */
  83542. export var kernelBlurVertexShader: {
  83543. name: string;
  83544. shader: string;
  83545. };
  83546. }
  83547. declare module BABYLON {
  83548. /**
  83549. * The Blur Post Process which blurs an image based on a kernel and direction.
  83550. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83551. */
  83552. export class BlurPostProcess extends PostProcess {
  83553. /** The direction in which to blur the image. */
  83554. direction: Vector2;
  83555. private blockCompilation;
  83556. protected _kernel: number;
  83557. protected _idealKernel: number;
  83558. protected _packedFloat: boolean;
  83559. private _staticDefines;
  83560. /**
  83561. * Sets the length in pixels of the blur sample region
  83562. */
  83563. /**
  83564. * Gets the length in pixels of the blur sample region
  83565. */
  83566. kernel: number;
  83567. /**
  83568. * Sets wether or not the blur needs to unpack/repack floats
  83569. */
  83570. /**
  83571. * Gets wether or not the blur is unpacking/repacking floats
  83572. */
  83573. packedFloat: boolean;
  83574. /**
  83575. * Creates a new instance BlurPostProcess
  83576. * @param name The name of the effect.
  83577. * @param direction The direction in which to blur the image.
  83578. * @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.
  83579. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83580. * @param camera The camera to apply the render pass to.
  83581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83582. * @param engine The engine which the post process will be applied. (default: current engine)
  83583. * @param reusable If the post process can be reused on the same frame. (default: false)
  83584. * @param textureType Type of textures used when performing the post process. (default: 0)
  83585. * @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)
  83586. */
  83587. constructor(name: string,
  83588. /** The direction in which to blur the image. */
  83589. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83590. /**
  83591. * Updates the effect with the current post process compile time values and recompiles the shader.
  83592. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83593. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83594. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83595. * @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
  83596. * @param onCompiled Called when the shader has been compiled.
  83597. * @param onError Called if there is an error when compiling a shader.
  83598. */
  83599. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83600. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83601. /**
  83602. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83603. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83604. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83605. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83606. * The gaps between physical kernels are compensated for in the weighting of the samples
  83607. * @param idealKernel Ideal blur kernel.
  83608. * @return Nearest best kernel.
  83609. */
  83610. protected _nearestBestKernel(idealKernel: number): number;
  83611. /**
  83612. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83613. * @param x The point on the Gaussian distribution to sample.
  83614. * @return the value of the Gaussian function at x.
  83615. */
  83616. protected _gaussianWeight(x: number): number;
  83617. /**
  83618. * Generates a string that can be used as a floating point number in GLSL.
  83619. * @param x Value to print.
  83620. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83621. * @return GLSL float string.
  83622. */
  83623. protected _glslFloat(x: number, decimalFigures?: number): string;
  83624. }
  83625. }
  83626. declare module BABYLON {
  83627. /**
  83628. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83629. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83630. * You can then easily use it as a reflectionTexture on a flat surface.
  83631. * In case the surface is not a plane, please consider relying on reflection probes.
  83632. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83633. */
  83634. export class MirrorTexture extends RenderTargetTexture {
  83635. private scene;
  83636. /**
  83637. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83638. * 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.
  83639. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83640. */
  83641. mirrorPlane: Plane;
  83642. /**
  83643. * Define the blur ratio used to blur the reflection if needed.
  83644. */
  83645. blurRatio: number;
  83646. /**
  83647. * Define the adaptive blur kernel used to blur the reflection if needed.
  83648. * This will autocompute the closest best match for the `blurKernel`
  83649. */
  83650. adaptiveBlurKernel: number;
  83651. /**
  83652. * Define the blur kernel used to blur the reflection if needed.
  83653. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83654. */
  83655. blurKernel: number;
  83656. /**
  83657. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83658. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83659. */
  83660. blurKernelX: number;
  83661. /**
  83662. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83663. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83664. */
  83665. blurKernelY: number;
  83666. private _autoComputeBlurKernel;
  83667. protected _onRatioRescale(): void;
  83668. private _updateGammaSpace;
  83669. private _imageProcessingConfigChangeObserver;
  83670. private _transformMatrix;
  83671. private _mirrorMatrix;
  83672. private _savedViewMatrix;
  83673. private _blurX;
  83674. private _blurY;
  83675. private _adaptiveBlurKernel;
  83676. private _blurKernelX;
  83677. private _blurKernelY;
  83678. private _blurRatio;
  83679. /**
  83680. * Instantiates a Mirror Texture.
  83681. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83682. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83683. * You can then easily use it as a reflectionTexture on a flat surface.
  83684. * In case the surface is not a plane, please consider relying on reflection probes.
  83685. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83686. * @param name
  83687. * @param size
  83688. * @param scene
  83689. * @param generateMipMaps
  83690. * @param type
  83691. * @param samplingMode
  83692. * @param generateDepthBuffer
  83693. */
  83694. constructor(name: string, size: number | {
  83695. width: number;
  83696. height: number;
  83697. } | {
  83698. ratio: number;
  83699. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83700. private _preparePostProcesses;
  83701. /**
  83702. * Clone the mirror texture.
  83703. * @returns the cloned texture
  83704. */
  83705. clone(): MirrorTexture;
  83706. /**
  83707. * Serialize the texture to a JSON representation you could use in Parse later on
  83708. * @returns the serialized JSON representation
  83709. */
  83710. serialize(): any;
  83711. /**
  83712. * Dispose the texture and release its associated resources.
  83713. */
  83714. dispose(): void;
  83715. }
  83716. }
  83717. declare module BABYLON {
  83718. /**
  83719. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83720. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83721. */
  83722. export class Texture extends BaseTexture {
  83723. /**
  83724. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83725. */
  83726. static SerializeBuffers: boolean;
  83727. /** @hidden */
  83728. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83729. /** @hidden */
  83730. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83731. /** @hidden */
  83732. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83733. /** nearest is mag = nearest and min = nearest and mip = linear */
  83734. static readonly NEAREST_SAMPLINGMODE: number;
  83735. /** nearest is mag = nearest and min = nearest and mip = linear */
  83736. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83737. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83738. static readonly BILINEAR_SAMPLINGMODE: number;
  83739. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83740. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83741. /** Trilinear is mag = linear and min = linear and mip = linear */
  83742. static readonly TRILINEAR_SAMPLINGMODE: number;
  83743. /** Trilinear is mag = linear and min = linear and mip = linear */
  83744. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83745. /** mag = nearest and min = nearest and mip = nearest */
  83746. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83747. /** mag = nearest and min = linear and mip = nearest */
  83748. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83749. /** mag = nearest and min = linear and mip = linear */
  83750. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83751. /** mag = nearest and min = linear and mip = none */
  83752. static readonly NEAREST_LINEAR: number;
  83753. /** mag = nearest and min = nearest and mip = none */
  83754. static readonly NEAREST_NEAREST: number;
  83755. /** mag = linear and min = nearest and mip = nearest */
  83756. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83757. /** mag = linear and min = nearest and mip = linear */
  83758. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83759. /** mag = linear and min = linear and mip = none */
  83760. static readonly LINEAR_LINEAR: number;
  83761. /** mag = linear and min = nearest and mip = none */
  83762. static readonly LINEAR_NEAREST: number;
  83763. /** Explicit coordinates mode */
  83764. static readonly EXPLICIT_MODE: number;
  83765. /** Spherical coordinates mode */
  83766. static readonly SPHERICAL_MODE: number;
  83767. /** Planar coordinates mode */
  83768. static readonly PLANAR_MODE: number;
  83769. /** Cubic coordinates mode */
  83770. static readonly CUBIC_MODE: number;
  83771. /** Projection coordinates mode */
  83772. static readonly PROJECTION_MODE: number;
  83773. /** Inverse Cubic coordinates mode */
  83774. static readonly SKYBOX_MODE: number;
  83775. /** Inverse Cubic coordinates mode */
  83776. static readonly INVCUBIC_MODE: number;
  83777. /** Equirectangular coordinates mode */
  83778. static readonly EQUIRECTANGULAR_MODE: number;
  83779. /** Equirectangular Fixed coordinates mode */
  83780. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83781. /** Equirectangular Fixed Mirrored coordinates mode */
  83782. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83783. /** Texture is not repeating outside of 0..1 UVs */
  83784. static readonly CLAMP_ADDRESSMODE: number;
  83785. /** Texture is repeating outside of 0..1 UVs */
  83786. static readonly WRAP_ADDRESSMODE: number;
  83787. /** Texture is repeating and mirrored */
  83788. static readonly MIRROR_ADDRESSMODE: number;
  83789. /**
  83790. * 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
  83791. */
  83792. static UseSerializedUrlIfAny: boolean;
  83793. /**
  83794. * Define the url of the texture.
  83795. */
  83796. url: Nullable<string>;
  83797. /**
  83798. * Define an offset on the texture to offset the u coordinates of the UVs
  83799. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83800. */
  83801. uOffset: number;
  83802. /**
  83803. * Define an offset on the texture to offset the v coordinates of the UVs
  83804. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83805. */
  83806. vOffset: number;
  83807. /**
  83808. * Define an offset on the texture to scale the u coordinates of the UVs
  83809. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83810. */
  83811. uScale: number;
  83812. /**
  83813. * Define an offset on the texture to scale the v coordinates of the UVs
  83814. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83815. */
  83816. vScale: number;
  83817. /**
  83818. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83819. * @see http://doc.babylonjs.com/how_to/more_materials
  83820. */
  83821. uAng: number;
  83822. /**
  83823. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83824. * @see http://doc.babylonjs.com/how_to/more_materials
  83825. */
  83826. vAng: number;
  83827. /**
  83828. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83829. * @see http://doc.babylonjs.com/how_to/more_materials
  83830. */
  83831. wAng: number;
  83832. /**
  83833. * Defines the center of rotation (U)
  83834. */
  83835. uRotationCenter: number;
  83836. /**
  83837. * Defines the center of rotation (V)
  83838. */
  83839. vRotationCenter: number;
  83840. /**
  83841. * Defines the center of rotation (W)
  83842. */
  83843. wRotationCenter: number;
  83844. /**
  83845. * Are mip maps generated for this texture or not.
  83846. */
  83847. readonly noMipmap: boolean;
  83848. /**
  83849. * List of inspectable custom properties (used by the Inspector)
  83850. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83851. */
  83852. inspectableCustomProperties: Nullable<IInspectable[]>;
  83853. private _noMipmap;
  83854. /** @hidden */
  83855. _invertY: boolean;
  83856. private _rowGenerationMatrix;
  83857. private _cachedTextureMatrix;
  83858. private _projectionModeMatrix;
  83859. private _t0;
  83860. private _t1;
  83861. private _t2;
  83862. private _cachedUOffset;
  83863. private _cachedVOffset;
  83864. private _cachedUScale;
  83865. private _cachedVScale;
  83866. private _cachedUAng;
  83867. private _cachedVAng;
  83868. private _cachedWAng;
  83869. private _cachedProjectionMatrixId;
  83870. private _cachedCoordinatesMode;
  83871. /** @hidden */
  83872. protected _initialSamplingMode: number;
  83873. /** @hidden */
  83874. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83875. private _deleteBuffer;
  83876. protected _format: Nullable<number>;
  83877. private _delayedOnLoad;
  83878. private _delayedOnError;
  83879. private _mimeType?;
  83880. /**
  83881. * Observable triggered once the texture has been loaded.
  83882. */
  83883. onLoadObservable: Observable<Texture>;
  83884. protected _isBlocking: boolean;
  83885. /**
  83886. * Is the texture preventing material to render while loading.
  83887. * If false, a default texture will be used instead of the loading one during the preparation step.
  83888. */
  83889. isBlocking: boolean;
  83890. /**
  83891. * Get the current sampling mode associated with the texture.
  83892. */
  83893. readonly samplingMode: number;
  83894. /**
  83895. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83896. */
  83897. readonly invertY: boolean;
  83898. /**
  83899. * Instantiates a new texture.
  83900. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83901. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83902. * @param url defines the url of the picture to load as a texture
  83903. * @param scene defines the scene or engine the texture will belong to
  83904. * @param noMipmap defines if the texture will require mip maps or not
  83905. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83906. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83907. * @param onLoad defines a callback triggered when the texture has been loaded
  83908. * @param onError defines a callback triggered when an error occurred during the loading session
  83909. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83910. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83911. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83912. * @param mimeType defines an optional mime type information
  83913. */
  83914. 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);
  83915. /**
  83916. * Update the url (and optional buffer) of this texture if url was null during construction.
  83917. * @param url the url of the texture
  83918. * @param buffer the buffer of the texture (defaults to null)
  83919. * @param onLoad callback called when the texture is loaded (defaults to null)
  83920. */
  83921. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83922. /**
  83923. * Finish the loading sequence of a texture flagged as delayed load.
  83924. * @hidden
  83925. */
  83926. delayLoad(): void;
  83927. private _prepareRowForTextureGeneration;
  83928. /**
  83929. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83930. * @returns the transform matrix of the texture.
  83931. */
  83932. getTextureMatrix(): Matrix;
  83933. /**
  83934. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83935. * @returns The reflection texture transform
  83936. */
  83937. getReflectionTextureMatrix(): Matrix;
  83938. /**
  83939. * Clones the texture.
  83940. * @returns the cloned texture
  83941. */
  83942. clone(): Texture;
  83943. /**
  83944. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83945. * @returns The JSON representation of the texture
  83946. */
  83947. serialize(): any;
  83948. /**
  83949. * Get the current class name of the texture useful for serialization or dynamic coding.
  83950. * @returns "Texture"
  83951. */
  83952. getClassName(): string;
  83953. /**
  83954. * Dispose the texture and release its associated resources.
  83955. */
  83956. dispose(): void;
  83957. /**
  83958. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83959. * @param parsedTexture Define the JSON representation of the texture
  83960. * @param scene Define the scene the parsed texture should be instantiated in
  83961. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83962. * @returns The parsed texture if successful
  83963. */
  83964. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83965. /**
  83966. * Creates a texture from its base 64 representation.
  83967. * @param data Define the base64 payload without the data: prefix
  83968. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83969. * @param scene Define the scene the texture should belong to
  83970. * @param noMipmap Forces the texture to not create mip map information if true
  83971. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83972. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83973. * @param onLoad define a callback triggered when the texture has been loaded
  83974. * @param onError define a callback triggered when an error occurred during the loading session
  83975. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83976. * @returns the created texture
  83977. */
  83978. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83979. /**
  83980. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83981. * @param data Define the base64 payload without the data: prefix
  83982. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83983. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83984. * @param scene Define the scene the texture should belong to
  83985. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83986. * @param noMipmap Forces the texture to not create mip map information if true
  83987. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83988. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83989. * @param onLoad define a callback triggered when the texture has been loaded
  83990. * @param onError define a callback triggered when an error occurred during the loading session
  83991. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83992. * @returns the created texture
  83993. */
  83994. 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;
  83995. }
  83996. }
  83997. declare module BABYLON {
  83998. /**
  83999. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84000. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84001. */
  84002. export class PostProcessManager {
  84003. private _scene;
  84004. private _indexBuffer;
  84005. private _vertexBuffers;
  84006. /**
  84007. * Creates a new instance PostProcess
  84008. * @param scene The scene that the post process is associated with.
  84009. */
  84010. constructor(scene: Scene);
  84011. private _prepareBuffers;
  84012. private _buildIndexBuffer;
  84013. /**
  84014. * Rebuilds the vertex buffers of the manager.
  84015. * @hidden
  84016. */
  84017. _rebuild(): void;
  84018. /**
  84019. * Prepares a frame to be run through a post process.
  84020. * @param sourceTexture The input texture to the post procesess. (default: null)
  84021. * @param postProcesses An array of post processes to be run. (default: null)
  84022. * @returns True if the post processes were able to be run.
  84023. * @hidden
  84024. */
  84025. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84026. /**
  84027. * Manually render a set of post processes to a texture.
  84028. * @param postProcesses An array of post processes to be run.
  84029. * @param targetTexture The target texture to render to.
  84030. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84031. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84032. * @param lodLevel defines which lod of the texture to render to
  84033. */
  84034. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84035. /**
  84036. * Finalize the result of the output of the postprocesses.
  84037. * @param doNotPresent If true the result will not be displayed to the screen.
  84038. * @param targetTexture The target texture to render to.
  84039. * @param faceIndex The index of the face to bind the target texture to.
  84040. * @param postProcesses The array of post processes to render.
  84041. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84042. * @hidden
  84043. */
  84044. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84045. /**
  84046. * Disposes of the post process manager.
  84047. */
  84048. dispose(): void;
  84049. }
  84050. }
  84051. declare module BABYLON {
  84052. /** Interface used by value gradients (color, factor, ...) */
  84053. export interface IValueGradient {
  84054. /**
  84055. * Gets or sets the gradient value (between 0 and 1)
  84056. */
  84057. gradient: number;
  84058. }
  84059. /** Class used to store color4 gradient */
  84060. export class ColorGradient implements IValueGradient {
  84061. /**
  84062. * Gets or sets the gradient value (between 0 and 1)
  84063. */
  84064. gradient: number;
  84065. /**
  84066. * Gets or sets first associated color
  84067. */
  84068. color1: Color4;
  84069. /**
  84070. * Gets or sets second associated color
  84071. */
  84072. color2?: Color4;
  84073. /**
  84074. * Will get a color picked randomly between color1 and color2.
  84075. * If color2 is undefined then color1 will be used
  84076. * @param result defines the target Color4 to store the result in
  84077. */
  84078. getColorToRef(result: Color4): void;
  84079. }
  84080. /** Class used to store color 3 gradient */
  84081. export class Color3Gradient implements IValueGradient {
  84082. /**
  84083. * Gets or sets the gradient value (between 0 and 1)
  84084. */
  84085. gradient: number;
  84086. /**
  84087. * Gets or sets the associated color
  84088. */
  84089. color: Color3;
  84090. }
  84091. /** Class used to store factor gradient */
  84092. export class FactorGradient implements IValueGradient {
  84093. /**
  84094. * Gets or sets the gradient value (between 0 and 1)
  84095. */
  84096. gradient: number;
  84097. /**
  84098. * Gets or sets first associated factor
  84099. */
  84100. factor1: number;
  84101. /**
  84102. * Gets or sets second associated factor
  84103. */
  84104. factor2?: number;
  84105. /**
  84106. * Will get a number picked randomly between factor1 and factor2.
  84107. * If factor2 is undefined then factor1 will be used
  84108. * @returns the picked number
  84109. */
  84110. getFactor(): number;
  84111. }
  84112. /**
  84113. * Helper used to simplify some generic gradient tasks
  84114. */
  84115. export class GradientHelper {
  84116. /**
  84117. * Gets the current gradient from an array of IValueGradient
  84118. * @param ratio defines the current ratio to get
  84119. * @param gradients defines the array of IValueGradient
  84120. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84121. */
  84122. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84123. }
  84124. }
  84125. declare module BABYLON {
  84126. interface ThinEngine {
  84127. /**
  84128. * Creates a dynamic texture
  84129. * @param width defines the width of the texture
  84130. * @param height defines the height of the texture
  84131. * @param generateMipMaps defines if the engine should generate the mip levels
  84132. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84133. * @returns the dynamic texture inside an InternalTexture
  84134. */
  84135. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84136. /**
  84137. * Update the content of a dynamic texture
  84138. * @param texture defines the texture to update
  84139. * @param canvas defines the canvas containing the source
  84140. * @param invertY defines if data must be stored with Y axis inverted
  84141. * @param premulAlpha defines if alpha is stored as premultiplied
  84142. * @param format defines the format of the data
  84143. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84144. */
  84145. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84146. }
  84147. }
  84148. declare module BABYLON {
  84149. /**
  84150. * Helper class used to generate a canvas to manipulate images
  84151. */
  84152. export class CanvasGenerator {
  84153. /**
  84154. * Create a new canvas (or offscreen canvas depending on the context)
  84155. * @param width defines the expected width
  84156. * @param height defines the expected height
  84157. * @return a new canvas or offscreen canvas
  84158. */
  84159. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84160. }
  84161. }
  84162. declare module BABYLON {
  84163. /**
  84164. * A class extending Texture allowing drawing on a texture
  84165. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84166. */
  84167. export class DynamicTexture extends Texture {
  84168. private _generateMipMaps;
  84169. private _canvas;
  84170. private _context;
  84171. private _engine;
  84172. /**
  84173. * Creates a DynamicTexture
  84174. * @param name defines the name of the texture
  84175. * @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
  84176. * @param scene defines the scene where you want the texture
  84177. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84178. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84179. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84180. */
  84181. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84182. /**
  84183. * Get the current class name of the texture useful for serialization or dynamic coding.
  84184. * @returns "DynamicTexture"
  84185. */
  84186. getClassName(): string;
  84187. /**
  84188. * Gets the current state of canRescale
  84189. */
  84190. readonly canRescale: boolean;
  84191. private _recreate;
  84192. /**
  84193. * Scales the texture
  84194. * @param ratio the scale factor to apply to both width and height
  84195. */
  84196. scale(ratio: number): void;
  84197. /**
  84198. * Resizes the texture
  84199. * @param width the new width
  84200. * @param height the new height
  84201. */
  84202. scaleTo(width: number, height: number): void;
  84203. /**
  84204. * Gets the context of the canvas used by the texture
  84205. * @returns the canvas context of the dynamic texture
  84206. */
  84207. getContext(): CanvasRenderingContext2D;
  84208. /**
  84209. * Clears the texture
  84210. */
  84211. clear(): void;
  84212. /**
  84213. * Updates the texture
  84214. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84215. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84216. */
  84217. update(invertY?: boolean, premulAlpha?: boolean): void;
  84218. /**
  84219. * Draws text onto the texture
  84220. * @param text defines the text to be drawn
  84221. * @param x defines the placement of the text from the left
  84222. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84223. * @param font defines the font to be used with font-style, font-size, font-name
  84224. * @param color defines the color used for the text
  84225. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84226. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84227. * @param update defines whether texture is immediately update (default is true)
  84228. */
  84229. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84230. /**
  84231. * Clones the texture
  84232. * @returns the clone of the texture.
  84233. */
  84234. clone(): DynamicTexture;
  84235. /**
  84236. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84237. * @returns a serialized dynamic texture object
  84238. */
  84239. serialize(): any;
  84240. /** @hidden */
  84241. _rebuild(): void;
  84242. }
  84243. }
  84244. declare module BABYLON {
  84245. interface AbstractScene {
  84246. /**
  84247. * The list of procedural textures added to the scene
  84248. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84249. */
  84250. proceduralTextures: Array<ProceduralTexture>;
  84251. }
  84252. /**
  84253. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84254. * in a given scene.
  84255. */
  84256. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84257. /**
  84258. * The component name helpfull to identify the component in the list of scene components.
  84259. */
  84260. readonly name: string;
  84261. /**
  84262. * The scene the component belongs to.
  84263. */
  84264. scene: Scene;
  84265. /**
  84266. * Creates a new instance of the component for the given scene
  84267. * @param scene Defines the scene to register the component in
  84268. */
  84269. constructor(scene: Scene);
  84270. /**
  84271. * Registers the component in a given scene
  84272. */
  84273. register(): void;
  84274. /**
  84275. * Rebuilds the elements related to this component in case of
  84276. * context lost for instance.
  84277. */
  84278. rebuild(): void;
  84279. /**
  84280. * Disposes the component and the associated ressources.
  84281. */
  84282. dispose(): void;
  84283. private _beforeClear;
  84284. }
  84285. }
  84286. declare module BABYLON {
  84287. interface ThinEngine {
  84288. /**
  84289. * Creates a new render target cube texture
  84290. * @param size defines the size of the texture
  84291. * @param options defines the options used to create the texture
  84292. * @returns a new render target cube texture stored in an InternalTexture
  84293. */
  84294. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84295. }
  84296. }
  84297. declare module BABYLON {
  84298. /** @hidden */
  84299. export var proceduralVertexShader: {
  84300. name: string;
  84301. shader: string;
  84302. };
  84303. }
  84304. declare module BABYLON {
  84305. /**
  84306. * 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.
  84307. * This is the base class of any Procedural texture and contains most of the shareable code.
  84308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84309. */
  84310. export class ProceduralTexture extends Texture {
  84311. isCube: boolean;
  84312. /**
  84313. * Define if the texture is enabled or not (disabled texture will not render)
  84314. */
  84315. isEnabled: boolean;
  84316. /**
  84317. * Define if the texture must be cleared before rendering (default is true)
  84318. */
  84319. autoClear: boolean;
  84320. /**
  84321. * Callback called when the texture is generated
  84322. */
  84323. onGenerated: () => void;
  84324. /**
  84325. * Event raised when the texture is generated
  84326. */
  84327. onGeneratedObservable: Observable<ProceduralTexture>;
  84328. /** @hidden */
  84329. _generateMipMaps: boolean;
  84330. /** @hidden **/
  84331. _effect: Effect;
  84332. /** @hidden */
  84333. _textures: {
  84334. [key: string]: Texture;
  84335. };
  84336. private _size;
  84337. private _currentRefreshId;
  84338. private _refreshRate;
  84339. private _vertexBuffers;
  84340. private _indexBuffer;
  84341. private _uniforms;
  84342. private _samplers;
  84343. private _fragment;
  84344. private _floats;
  84345. private _ints;
  84346. private _floatsArrays;
  84347. private _colors3;
  84348. private _colors4;
  84349. private _vectors2;
  84350. private _vectors3;
  84351. private _matrices;
  84352. private _fallbackTexture;
  84353. private _fallbackTextureUsed;
  84354. private _engine;
  84355. private _cachedDefines;
  84356. private _contentUpdateId;
  84357. private _contentData;
  84358. /**
  84359. * Instantiates a new procedural texture.
  84360. * 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.
  84361. * This is the base class of any Procedural texture and contains most of the shareable code.
  84362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84363. * @param name Define the name of the texture
  84364. * @param size Define the size of the texture to create
  84365. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84366. * @param scene Define the scene the texture belongs to
  84367. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84368. * @param generateMipMaps Define if the texture should creates mip maps or not
  84369. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84370. */
  84371. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84372. /**
  84373. * The effect that is created when initializing the post process.
  84374. * @returns The created effect corresponding the the postprocess.
  84375. */
  84376. getEffect(): Effect;
  84377. /**
  84378. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84379. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84380. */
  84381. getContent(): Nullable<ArrayBufferView>;
  84382. private _createIndexBuffer;
  84383. /** @hidden */
  84384. _rebuild(): void;
  84385. /**
  84386. * Resets the texture in order to recreate its associated resources.
  84387. * This can be called in case of context loss
  84388. */
  84389. reset(): void;
  84390. protected _getDefines(): string;
  84391. /**
  84392. * Is the texture ready to be used ? (rendered at least once)
  84393. * @returns true if ready, otherwise, false.
  84394. */
  84395. isReady(): boolean;
  84396. /**
  84397. * Resets the refresh counter of the texture and start bak from scratch.
  84398. * Could be useful to regenerate the texture if it is setup to render only once.
  84399. */
  84400. resetRefreshCounter(): void;
  84401. /**
  84402. * Set the fragment shader to use in order to render the texture.
  84403. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84404. */
  84405. setFragment(fragment: any): void;
  84406. /**
  84407. * Define the refresh rate of the texture or the rendering frequency.
  84408. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84409. */
  84410. refreshRate: number;
  84411. /** @hidden */
  84412. _shouldRender(): boolean;
  84413. /**
  84414. * Get the size the texture is rendering at.
  84415. * @returns the size (texture is always squared)
  84416. */
  84417. getRenderSize(): number;
  84418. /**
  84419. * Resize the texture to new value.
  84420. * @param size Define the new size the texture should have
  84421. * @param generateMipMaps Define whether the new texture should create mip maps
  84422. */
  84423. resize(size: number, generateMipMaps: boolean): void;
  84424. private _checkUniform;
  84425. /**
  84426. * Set a texture in the shader program used to render.
  84427. * @param name Define the name of the uniform samplers as defined in the shader
  84428. * @param texture Define the texture to bind to this sampler
  84429. * @return the texture itself allowing "fluent" like uniform updates
  84430. */
  84431. setTexture(name: string, texture: Texture): ProceduralTexture;
  84432. /**
  84433. * Set a float in the shader.
  84434. * @param name Define the name of the uniform as defined in the shader
  84435. * @param value Define the value to give to the uniform
  84436. * @return the texture itself allowing "fluent" like uniform updates
  84437. */
  84438. setFloat(name: string, value: number): ProceduralTexture;
  84439. /**
  84440. * Set a int in the shader.
  84441. * @param name Define the name of the uniform as defined in the shader
  84442. * @param value Define the value to give to the uniform
  84443. * @return the texture itself allowing "fluent" like uniform updates
  84444. */
  84445. setInt(name: string, value: number): ProceduralTexture;
  84446. /**
  84447. * Set an array of floats in the shader.
  84448. * @param name Define the name of the uniform as defined in the shader
  84449. * @param value Define the value to give to the uniform
  84450. * @return the texture itself allowing "fluent" like uniform updates
  84451. */
  84452. setFloats(name: string, value: number[]): ProceduralTexture;
  84453. /**
  84454. * Set a vec3 in the shader from a Color3.
  84455. * @param name Define the name of the uniform as defined in the shader
  84456. * @param value Define the value to give to the uniform
  84457. * @return the texture itself allowing "fluent" like uniform updates
  84458. */
  84459. setColor3(name: string, value: Color3): ProceduralTexture;
  84460. /**
  84461. * Set a vec4 in the shader from a Color4.
  84462. * @param name Define the name of the uniform as defined in the shader
  84463. * @param value Define the value to give to the uniform
  84464. * @return the texture itself allowing "fluent" like uniform updates
  84465. */
  84466. setColor4(name: string, value: Color4): ProceduralTexture;
  84467. /**
  84468. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  84474. /**
  84475. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  84481. /**
  84482. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84488. /**
  84489. * Render the texture to its associated render target.
  84490. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84491. */
  84492. render(useCameraPostProcess?: boolean): void;
  84493. /**
  84494. * Clone the texture.
  84495. * @returns the cloned texture
  84496. */
  84497. clone(): ProceduralTexture;
  84498. /**
  84499. * Dispose the texture and release its asoociated resources.
  84500. */
  84501. dispose(): void;
  84502. }
  84503. }
  84504. declare module BABYLON {
  84505. /**
  84506. * This represents the base class for particle system in Babylon.
  84507. * 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.
  84508. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84509. * @example https://doc.babylonjs.com/babylon101/particles
  84510. */
  84511. export class BaseParticleSystem {
  84512. /**
  84513. * Source color is added to the destination color without alpha affecting the result
  84514. */
  84515. static BLENDMODE_ONEONE: number;
  84516. /**
  84517. * Blend current color and particle color using particle’s alpha
  84518. */
  84519. static BLENDMODE_STANDARD: number;
  84520. /**
  84521. * Add current color and particle color multiplied by particle’s alpha
  84522. */
  84523. static BLENDMODE_ADD: number;
  84524. /**
  84525. * Multiply current color with particle color
  84526. */
  84527. static BLENDMODE_MULTIPLY: number;
  84528. /**
  84529. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84530. */
  84531. static BLENDMODE_MULTIPLYADD: number;
  84532. /**
  84533. * List of animations used by the particle system.
  84534. */
  84535. animations: Animation[];
  84536. /**
  84537. * The id of the Particle system.
  84538. */
  84539. id: string;
  84540. /**
  84541. * The friendly name of the Particle system.
  84542. */
  84543. name: string;
  84544. /**
  84545. * The rendering group used by the Particle system to chose when to render.
  84546. */
  84547. renderingGroupId: number;
  84548. /**
  84549. * The emitter represents the Mesh or position we are attaching the particle system to.
  84550. */
  84551. emitter: Nullable<AbstractMesh | Vector3>;
  84552. /**
  84553. * The maximum number of particles to emit per frame
  84554. */
  84555. emitRate: number;
  84556. /**
  84557. * If you want to launch only a few particles at once, that can be done, as well.
  84558. */
  84559. manualEmitCount: number;
  84560. /**
  84561. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84562. */
  84563. updateSpeed: number;
  84564. /**
  84565. * The amount of time the particle system is running (depends of the overall update speed).
  84566. */
  84567. targetStopDuration: number;
  84568. /**
  84569. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84570. */
  84571. disposeOnStop: boolean;
  84572. /**
  84573. * Minimum power of emitting particles.
  84574. */
  84575. minEmitPower: number;
  84576. /**
  84577. * Maximum power of emitting particles.
  84578. */
  84579. maxEmitPower: number;
  84580. /**
  84581. * Minimum life time of emitting particles.
  84582. */
  84583. minLifeTime: number;
  84584. /**
  84585. * Maximum life time of emitting particles.
  84586. */
  84587. maxLifeTime: number;
  84588. /**
  84589. * Minimum Size of emitting particles.
  84590. */
  84591. minSize: number;
  84592. /**
  84593. * Maximum Size of emitting particles.
  84594. */
  84595. maxSize: number;
  84596. /**
  84597. * Minimum scale of emitting particles on X axis.
  84598. */
  84599. minScaleX: number;
  84600. /**
  84601. * Maximum scale of emitting particles on X axis.
  84602. */
  84603. maxScaleX: number;
  84604. /**
  84605. * Minimum scale of emitting particles on Y axis.
  84606. */
  84607. minScaleY: number;
  84608. /**
  84609. * Maximum scale of emitting particles on Y axis.
  84610. */
  84611. maxScaleY: number;
  84612. /**
  84613. * Gets or sets the minimal initial rotation in radians.
  84614. */
  84615. minInitialRotation: number;
  84616. /**
  84617. * Gets or sets the maximal initial rotation in radians.
  84618. */
  84619. maxInitialRotation: number;
  84620. /**
  84621. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84622. */
  84623. minAngularSpeed: number;
  84624. /**
  84625. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84626. */
  84627. maxAngularSpeed: number;
  84628. /**
  84629. * The texture used to render each particle. (this can be a spritesheet)
  84630. */
  84631. particleTexture: Nullable<Texture>;
  84632. /**
  84633. * The layer mask we are rendering the particles through.
  84634. */
  84635. layerMask: number;
  84636. /**
  84637. * This can help using your own shader to render the particle system.
  84638. * The according effect will be created
  84639. */
  84640. customShader: any;
  84641. /**
  84642. * By default particle system starts as soon as they are created. This prevents the
  84643. * automatic start to happen and let you decide when to start emitting particles.
  84644. */
  84645. preventAutoStart: boolean;
  84646. private _noiseTexture;
  84647. /**
  84648. * Gets or sets a texture used to add random noise to particle positions
  84649. */
  84650. noiseTexture: Nullable<ProceduralTexture>;
  84651. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84652. noiseStrength: Vector3;
  84653. /**
  84654. * Callback triggered when the particle animation is ending.
  84655. */
  84656. onAnimationEnd: Nullable<() => void>;
  84657. /**
  84658. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84659. */
  84660. blendMode: number;
  84661. /**
  84662. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84663. * to override the particles.
  84664. */
  84665. forceDepthWrite: boolean;
  84666. /** 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 */
  84667. preWarmCycles: number;
  84668. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84669. preWarmStepOffset: number;
  84670. /**
  84671. * 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)
  84672. */
  84673. spriteCellChangeSpeed: number;
  84674. /**
  84675. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84676. */
  84677. startSpriteCellID: number;
  84678. /**
  84679. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84680. */
  84681. endSpriteCellID: number;
  84682. /**
  84683. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84684. */
  84685. spriteCellWidth: number;
  84686. /**
  84687. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84688. */
  84689. spriteCellHeight: number;
  84690. /**
  84691. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84692. */
  84693. spriteRandomStartCell: boolean;
  84694. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84695. translationPivot: Vector2;
  84696. /** @hidden */
  84697. protected _isAnimationSheetEnabled: boolean;
  84698. /**
  84699. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84700. */
  84701. beginAnimationOnStart: boolean;
  84702. /**
  84703. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84704. */
  84705. beginAnimationFrom: number;
  84706. /**
  84707. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84708. */
  84709. beginAnimationTo: number;
  84710. /**
  84711. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84712. */
  84713. beginAnimationLoop: boolean;
  84714. /**
  84715. * Gets or sets a world offset applied to all particles
  84716. */
  84717. worldOffset: Vector3;
  84718. /**
  84719. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84720. */
  84721. isAnimationSheetEnabled: boolean;
  84722. /**
  84723. * Get hosting scene
  84724. * @returns the scene
  84725. */
  84726. getScene(): Scene;
  84727. /**
  84728. * You can use gravity if you want to give an orientation to your particles.
  84729. */
  84730. gravity: Vector3;
  84731. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84732. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84733. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84734. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84735. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84736. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84737. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84738. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84739. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84740. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84741. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84742. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84743. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84744. /**
  84745. * Defines the delay in milliseconds before starting the system (0 by default)
  84746. */
  84747. startDelay: number;
  84748. /**
  84749. * Gets the current list of drag gradients.
  84750. * You must use addDragGradient and removeDragGradient to udpate this list
  84751. * @returns the list of drag gradients
  84752. */
  84753. getDragGradients(): Nullable<Array<FactorGradient>>;
  84754. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84755. limitVelocityDamping: number;
  84756. /**
  84757. * Gets the current list of limit velocity gradients.
  84758. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84759. * @returns the list of limit velocity gradients
  84760. */
  84761. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84762. /**
  84763. * Gets the current list of color gradients.
  84764. * You must use addColorGradient and removeColorGradient to udpate this list
  84765. * @returns the list of color gradients
  84766. */
  84767. getColorGradients(): Nullable<Array<ColorGradient>>;
  84768. /**
  84769. * Gets the current list of size gradients.
  84770. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84771. * @returns the list of size gradients
  84772. */
  84773. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84774. /**
  84775. * Gets the current list of color remap gradients.
  84776. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84777. * @returns the list of color remap gradients
  84778. */
  84779. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84780. /**
  84781. * Gets the current list of alpha remap gradients.
  84782. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84783. * @returns the list of alpha remap gradients
  84784. */
  84785. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84786. /**
  84787. * Gets the current list of life time gradients.
  84788. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84789. * @returns the list of life time gradients
  84790. */
  84791. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84792. /**
  84793. * Gets the current list of angular speed gradients.
  84794. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84795. * @returns the list of angular speed gradients
  84796. */
  84797. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84798. /**
  84799. * Gets the current list of velocity gradients.
  84800. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84801. * @returns the list of velocity gradients
  84802. */
  84803. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84804. /**
  84805. * Gets the current list of start size gradients.
  84806. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84807. * @returns the list of start size gradients
  84808. */
  84809. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84810. /**
  84811. * Gets the current list of emit rate gradients.
  84812. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84813. * @returns the list of emit rate gradients
  84814. */
  84815. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84816. /**
  84817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84818. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84819. */
  84820. direction1: Vector3;
  84821. /**
  84822. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84823. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84824. */
  84825. direction2: Vector3;
  84826. /**
  84827. * 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.
  84828. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84829. */
  84830. minEmitBox: Vector3;
  84831. /**
  84832. * 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.
  84833. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84834. */
  84835. maxEmitBox: Vector3;
  84836. /**
  84837. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84838. */
  84839. color1: Color4;
  84840. /**
  84841. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84842. */
  84843. color2: Color4;
  84844. /**
  84845. * Color the particle will have at the end of its lifetime
  84846. */
  84847. colorDead: Color4;
  84848. /**
  84849. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84850. */
  84851. textureMask: Color4;
  84852. /**
  84853. * The particle emitter type defines the emitter used by the particle system.
  84854. * It can be for example box, sphere, or cone...
  84855. */
  84856. particleEmitterType: IParticleEmitterType;
  84857. /** @hidden */
  84858. _isSubEmitter: boolean;
  84859. /**
  84860. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84861. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84862. */
  84863. billboardMode: number;
  84864. protected _isBillboardBased: boolean;
  84865. /**
  84866. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84867. */
  84868. isBillboardBased: boolean;
  84869. /**
  84870. * The scene the particle system belongs to.
  84871. */
  84872. protected _scene: Scene;
  84873. /**
  84874. * Local cache of defines for image processing.
  84875. */
  84876. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84877. /**
  84878. * Default configuration related to image processing available in the standard Material.
  84879. */
  84880. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84881. /**
  84882. * Gets the image processing configuration used either in this material.
  84883. */
  84884. /**
  84885. * Sets the Default image processing configuration used either in the this material.
  84886. *
  84887. * If sets to null, the scene one is in use.
  84888. */
  84889. imageProcessingConfiguration: ImageProcessingConfiguration;
  84890. /**
  84891. * Attaches a new image processing configuration to the Standard Material.
  84892. * @param configuration
  84893. */
  84894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84895. /** @hidden */
  84896. protected _reset(): void;
  84897. /** @hidden */
  84898. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84899. /**
  84900. * Instantiates a particle system.
  84901. * 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.
  84902. * @param name The name of the particle system
  84903. */
  84904. constructor(name: string);
  84905. /**
  84906. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84907. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84908. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84909. * @returns the emitter
  84910. */
  84911. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84912. /**
  84913. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84914. * @param radius The radius of the hemisphere to emit from
  84915. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84916. * @returns the emitter
  84917. */
  84918. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84919. /**
  84920. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84921. * @param radius The radius of the sphere to emit from
  84922. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84923. * @returns the emitter
  84924. */
  84925. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84926. /**
  84927. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84928. * @param radius The radius of the sphere to emit from
  84929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84931. * @returns the emitter
  84932. */
  84933. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84934. /**
  84935. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84936. * @param radius The radius of the emission cylinder
  84937. * @param height The height of the emission cylinder
  84938. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84939. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84940. * @returns the emitter
  84941. */
  84942. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84943. /**
  84944. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84945. * @param radius The radius of the cylinder to emit from
  84946. * @param height The height of the emission cylinder
  84947. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84950. * @returns the emitter
  84951. */
  84952. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84953. /**
  84954. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84955. * @param radius The radius of the cone to emit from
  84956. * @param angle The base angle of the cone
  84957. * @returns the emitter
  84958. */
  84959. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84960. /**
  84961. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84962. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84963. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84964. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84965. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84966. * @returns the emitter
  84967. */
  84968. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84969. }
  84970. }
  84971. declare module BABYLON {
  84972. /**
  84973. * Type of sub emitter
  84974. */
  84975. export enum SubEmitterType {
  84976. /**
  84977. * Attached to the particle over it's lifetime
  84978. */
  84979. ATTACHED = 0,
  84980. /**
  84981. * Created when the particle dies
  84982. */
  84983. END = 1
  84984. }
  84985. /**
  84986. * Sub emitter class used to emit particles from an existing particle
  84987. */
  84988. export class SubEmitter {
  84989. /**
  84990. * the particle system to be used by the sub emitter
  84991. */
  84992. particleSystem: ParticleSystem;
  84993. /**
  84994. * Type of the submitter (Default: END)
  84995. */
  84996. type: SubEmitterType;
  84997. /**
  84998. * 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)
  84999. * Note: This only is supported when using an emitter of type Mesh
  85000. */
  85001. inheritDirection: boolean;
  85002. /**
  85003. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85004. */
  85005. inheritedVelocityAmount: number;
  85006. /**
  85007. * Creates a sub emitter
  85008. * @param particleSystem the particle system to be used by the sub emitter
  85009. */
  85010. constructor(
  85011. /**
  85012. * the particle system to be used by the sub emitter
  85013. */
  85014. particleSystem: ParticleSystem);
  85015. /**
  85016. * Clones the sub emitter
  85017. * @returns the cloned sub emitter
  85018. */
  85019. clone(): SubEmitter;
  85020. /**
  85021. * Serialize current object to a JSON object
  85022. * @returns the serialized object
  85023. */
  85024. serialize(): any;
  85025. /** @hidden */
  85026. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85027. /**
  85028. * Creates a new SubEmitter from a serialized JSON version
  85029. * @param serializationObject defines the JSON object to read from
  85030. * @param scene defines the hosting scene
  85031. * @param rootUrl defines the rootUrl for data loading
  85032. * @returns a new SubEmitter
  85033. */
  85034. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85035. /** Release associated resources */
  85036. dispose(): void;
  85037. }
  85038. }
  85039. declare module BABYLON {
  85040. /** @hidden */
  85041. export var clipPlaneFragmentDeclaration: {
  85042. name: string;
  85043. shader: string;
  85044. };
  85045. }
  85046. declare module BABYLON {
  85047. /** @hidden */
  85048. export var imageProcessingDeclaration: {
  85049. name: string;
  85050. shader: string;
  85051. };
  85052. }
  85053. declare module BABYLON {
  85054. /** @hidden */
  85055. export var imageProcessingFunctions: {
  85056. name: string;
  85057. shader: string;
  85058. };
  85059. }
  85060. declare module BABYLON {
  85061. /** @hidden */
  85062. export var clipPlaneFragment: {
  85063. name: string;
  85064. shader: string;
  85065. };
  85066. }
  85067. declare module BABYLON {
  85068. /** @hidden */
  85069. export var particlesPixelShader: {
  85070. name: string;
  85071. shader: string;
  85072. };
  85073. }
  85074. declare module BABYLON {
  85075. /** @hidden */
  85076. export var clipPlaneVertexDeclaration: {
  85077. name: string;
  85078. shader: string;
  85079. };
  85080. }
  85081. declare module BABYLON {
  85082. /** @hidden */
  85083. export var clipPlaneVertex: {
  85084. name: string;
  85085. shader: string;
  85086. };
  85087. }
  85088. declare module BABYLON {
  85089. /** @hidden */
  85090. export var particlesVertexShader: {
  85091. name: string;
  85092. shader: string;
  85093. };
  85094. }
  85095. declare module BABYLON {
  85096. /**
  85097. * This represents a particle system in Babylon.
  85098. * 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.
  85099. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85100. * @example https://doc.babylonjs.com/babylon101/particles
  85101. */
  85102. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85103. /**
  85104. * Billboard mode will only apply to Y axis
  85105. */
  85106. static readonly BILLBOARDMODE_Y: number;
  85107. /**
  85108. * Billboard mode will apply to all axes
  85109. */
  85110. static readonly BILLBOARDMODE_ALL: number;
  85111. /**
  85112. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85113. */
  85114. static readonly BILLBOARDMODE_STRETCHED: number;
  85115. /**
  85116. * This function can be defined to provide custom update for active particles.
  85117. * This function will be called instead of regular update (age, position, color, etc.).
  85118. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85119. */
  85120. updateFunction: (particles: Particle[]) => void;
  85121. private _emitterWorldMatrix;
  85122. /**
  85123. * This function can be defined to specify initial direction for every new particle.
  85124. * It by default use the emitterType defined function
  85125. */
  85126. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85127. /**
  85128. * This function can be defined to specify initial position for every new particle.
  85129. * It by default use the emitterType defined function
  85130. */
  85131. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85132. /**
  85133. * @hidden
  85134. */
  85135. _inheritedVelocityOffset: Vector3;
  85136. /**
  85137. * An event triggered when the system is disposed
  85138. */
  85139. onDisposeObservable: Observable<ParticleSystem>;
  85140. private _onDisposeObserver;
  85141. /**
  85142. * Sets a callback that will be triggered when the system is disposed
  85143. */
  85144. onDispose: () => void;
  85145. private _particles;
  85146. private _epsilon;
  85147. private _capacity;
  85148. private _stockParticles;
  85149. private _newPartsExcess;
  85150. private _vertexData;
  85151. private _vertexBuffer;
  85152. private _vertexBuffers;
  85153. private _spriteBuffer;
  85154. private _indexBuffer;
  85155. private _effect;
  85156. private _customEffect;
  85157. private _cachedDefines;
  85158. private _scaledColorStep;
  85159. private _colorDiff;
  85160. private _scaledDirection;
  85161. private _scaledGravity;
  85162. private _currentRenderId;
  85163. private _alive;
  85164. private _useInstancing;
  85165. private _started;
  85166. private _stopped;
  85167. private _actualFrame;
  85168. private _scaledUpdateSpeed;
  85169. private _vertexBufferSize;
  85170. /** @hidden */
  85171. _currentEmitRateGradient: Nullable<FactorGradient>;
  85172. /** @hidden */
  85173. _currentEmitRate1: number;
  85174. /** @hidden */
  85175. _currentEmitRate2: number;
  85176. /** @hidden */
  85177. _currentStartSizeGradient: Nullable<FactorGradient>;
  85178. /** @hidden */
  85179. _currentStartSize1: number;
  85180. /** @hidden */
  85181. _currentStartSize2: number;
  85182. private readonly _rawTextureWidth;
  85183. private _rampGradientsTexture;
  85184. private _useRampGradients;
  85185. /** Gets or sets a boolean indicating that ramp gradients must be used
  85186. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85187. */
  85188. useRampGradients: boolean;
  85189. /**
  85190. * 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.
  85191. * 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: [])
  85192. */
  85193. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85194. private _subEmitters;
  85195. /**
  85196. * @hidden
  85197. * If the particle systems emitter should be disposed when the particle system is disposed
  85198. */
  85199. _disposeEmitterOnDispose: boolean;
  85200. /**
  85201. * The current active Sub-systems, this property is used by the root particle system only.
  85202. */
  85203. activeSubSystems: Array<ParticleSystem>;
  85204. private _rootParticleSystem;
  85205. /**
  85206. * Gets the current list of active particles
  85207. */
  85208. readonly particles: Particle[];
  85209. /**
  85210. * Returns the string "ParticleSystem"
  85211. * @returns a string containing the class name
  85212. */
  85213. getClassName(): string;
  85214. /**
  85215. * Instantiates a particle system.
  85216. * 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.
  85217. * @param name The name of the particle system
  85218. * @param capacity The max number of particles alive at the same time
  85219. * @param scene The scene the particle system belongs to
  85220. * @param customEffect a custom effect used to change the way particles are rendered by default
  85221. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85222. * @param epsilon Offset used to render the particles
  85223. */
  85224. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85225. private _addFactorGradient;
  85226. private _removeFactorGradient;
  85227. /**
  85228. * Adds a new life time gradient
  85229. * @param gradient defines the gradient to use (between 0 and 1)
  85230. * @param factor defines the life time factor to affect to the specified gradient
  85231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85232. * @returns the current particle system
  85233. */
  85234. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85235. /**
  85236. * Remove a specific life time gradient
  85237. * @param gradient defines the gradient to remove
  85238. * @returns the current particle system
  85239. */
  85240. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85241. /**
  85242. * Adds a new size gradient
  85243. * @param gradient defines the gradient to use (between 0 and 1)
  85244. * @param factor defines the size factor to affect to the specified gradient
  85245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85246. * @returns the current particle system
  85247. */
  85248. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85249. /**
  85250. * Remove a specific size gradient
  85251. * @param gradient defines the gradient to remove
  85252. * @returns the current particle system
  85253. */
  85254. removeSizeGradient(gradient: number): IParticleSystem;
  85255. /**
  85256. * Adds a new color remap gradient
  85257. * @param gradient defines the gradient to use (between 0 and 1)
  85258. * @param min defines the color remap minimal range
  85259. * @param max defines the color remap maximal range
  85260. * @returns the current particle system
  85261. */
  85262. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85263. /**
  85264. * Remove a specific color remap gradient
  85265. * @param gradient defines the gradient to remove
  85266. * @returns the current particle system
  85267. */
  85268. removeColorRemapGradient(gradient: number): IParticleSystem;
  85269. /**
  85270. * Adds a new alpha remap gradient
  85271. * @param gradient defines the gradient to use (between 0 and 1)
  85272. * @param min defines the alpha remap minimal range
  85273. * @param max defines the alpha remap maximal range
  85274. * @returns the current particle system
  85275. */
  85276. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85277. /**
  85278. * Remove a specific alpha remap gradient
  85279. * @param gradient defines the gradient to remove
  85280. * @returns the current particle system
  85281. */
  85282. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85283. /**
  85284. * Adds a new angular speed gradient
  85285. * @param gradient defines the gradient to use (between 0 and 1)
  85286. * @param factor defines the angular speed to affect to the specified gradient
  85287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85288. * @returns the current particle system
  85289. */
  85290. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85291. /**
  85292. * Remove a specific angular speed gradient
  85293. * @param gradient defines the gradient to remove
  85294. * @returns the current particle system
  85295. */
  85296. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85297. /**
  85298. * Adds a new velocity gradient
  85299. * @param gradient defines the gradient to use (between 0 and 1)
  85300. * @param factor defines the velocity to affect to the specified gradient
  85301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85302. * @returns the current particle system
  85303. */
  85304. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85305. /**
  85306. * Remove a specific velocity gradient
  85307. * @param gradient defines the gradient to remove
  85308. * @returns the current particle system
  85309. */
  85310. removeVelocityGradient(gradient: number): IParticleSystem;
  85311. /**
  85312. * Adds a new limit velocity gradient
  85313. * @param gradient defines the gradient to use (between 0 and 1)
  85314. * @param factor defines the limit velocity value to affect to the specified gradient
  85315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85316. * @returns the current particle system
  85317. */
  85318. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85319. /**
  85320. * Remove a specific limit velocity gradient
  85321. * @param gradient defines the gradient to remove
  85322. * @returns the current particle system
  85323. */
  85324. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85325. /**
  85326. * Adds a new drag gradient
  85327. * @param gradient defines the gradient to use (between 0 and 1)
  85328. * @param factor defines the drag value to affect to the specified gradient
  85329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85330. * @returns the current particle system
  85331. */
  85332. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85333. /**
  85334. * Remove a specific drag gradient
  85335. * @param gradient defines the gradient to remove
  85336. * @returns the current particle system
  85337. */
  85338. removeDragGradient(gradient: number): IParticleSystem;
  85339. /**
  85340. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85341. * @param gradient defines the gradient to use (between 0 and 1)
  85342. * @param factor defines the emit rate value to affect to the specified gradient
  85343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85344. * @returns the current particle system
  85345. */
  85346. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85347. /**
  85348. * Remove a specific emit rate gradient
  85349. * @param gradient defines the gradient to remove
  85350. * @returns the current particle system
  85351. */
  85352. removeEmitRateGradient(gradient: number): IParticleSystem;
  85353. /**
  85354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85355. * @param gradient defines the gradient to use (between 0 and 1)
  85356. * @param factor defines the start size value to affect to the specified gradient
  85357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85358. * @returns the current particle system
  85359. */
  85360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85361. /**
  85362. * Remove a specific start size gradient
  85363. * @param gradient defines the gradient to remove
  85364. * @returns the current particle system
  85365. */
  85366. removeStartSizeGradient(gradient: number): IParticleSystem;
  85367. private _createRampGradientTexture;
  85368. /**
  85369. * Gets the current list of ramp gradients.
  85370. * You must use addRampGradient and removeRampGradient to udpate this list
  85371. * @returns the list of ramp gradients
  85372. */
  85373. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85374. /**
  85375. * Adds a new ramp gradient used to remap particle colors
  85376. * @param gradient defines the gradient to use (between 0 and 1)
  85377. * @param color defines the color to affect to the specified gradient
  85378. * @returns the current particle system
  85379. */
  85380. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85381. /**
  85382. * Remove a specific ramp gradient
  85383. * @param gradient defines the gradient to remove
  85384. * @returns the current particle system
  85385. */
  85386. removeRampGradient(gradient: number): ParticleSystem;
  85387. /**
  85388. * Adds a new color gradient
  85389. * @param gradient defines the gradient to use (between 0 and 1)
  85390. * @param color1 defines the color to affect to the specified gradient
  85391. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85392. * @returns this particle system
  85393. */
  85394. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85395. /**
  85396. * Remove a specific color gradient
  85397. * @param gradient defines the gradient to remove
  85398. * @returns this particle system
  85399. */
  85400. removeColorGradient(gradient: number): IParticleSystem;
  85401. private _fetchR;
  85402. protected _reset(): void;
  85403. private _resetEffect;
  85404. private _createVertexBuffers;
  85405. private _createIndexBuffer;
  85406. /**
  85407. * Gets the maximum number of particles active at the same time.
  85408. * @returns The max number of active particles.
  85409. */
  85410. getCapacity(): number;
  85411. /**
  85412. * Gets whether there are still active particles in the system.
  85413. * @returns True if it is alive, otherwise false.
  85414. */
  85415. isAlive(): boolean;
  85416. /**
  85417. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85418. * @returns True if it has been started, otherwise false.
  85419. */
  85420. isStarted(): boolean;
  85421. private _prepareSubEmitterInternalArray;
  85422. /**
  85423. * Starts the particle system and begins to emit
  85424. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85425. */
  85426. start(delay?: number): void;
  85427. /**
  85428. * Stops the particle system.
  85429. * @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.
  85430. */
  85431. stop(stopSubEmitters?: boolean): void;
  85432. /**
  85433. * Remove all active particles
  85434. */
  85435. reset(): void;
  85436. /**
  85437. * @hidden (for internal use only)
  85438. */
  85439. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85440. /**
  85441. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85442. * Its lifetime will start back at 0.
  85443. */
  85444. recycleParticle: (particle: Particle) => void;
  85445. private _stopSubEmitters;
  85446. private _createParticle;
  85447. private _removeFromRoot;
  85448. private _emitFromParticle;
  85449. private _update;
  85450. /** @hidden */
  85451. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85452. /** @hidden */
  85453. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85454. /** @hidden */
  85455. private _getEffect;
  85456. /**
  85457. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85458. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85459. */
  85460. animate(preWarmOnly?: boolean): void;
  85461. private _appendParticleVertices;
  85462. /**
  85463. * Rebuilds the particle system.
  85464. */
  85465. rebuild(): void;
  85466. /**
  85467. * Is this system ready to be used/rendered
  85468. * @return true if the system is ready
  85469. */
  85470. isReady(): boolean;
  85471. private _render;
  85472. /**
  85473. * Renders the particle system in its current state.
  85474. * @returns the current number of particles
  85475. */
  85476. render(): number;
  85477. /**
  85478. * Disposes the particle system and free the associated resources
  85479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85480. */
  85481. dispose(disposeTexture?: boolean): void;
  85482. /**
  85483. * Clones the particle system.
  85484. * @param name The name of the cloned object
  85485. * @param newEmitter The new emitter to use
  85486. * @returns the cloned particle system
  85487. */
  85488. clone(name: string, newEmitter: any): ParticleSystem;
  85489. /**
  85490. * Serializes the particle system to a JSON object.
  85491. * @returns the JSON object
  85492. */
  85493. serialize(): any;
  85494. /** @hidden */
  85495. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85496. /** @hidden */
  85497. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85498. /**
  85499. * Parses a JSON object to create a particle system.
  85500. * @param parsedParticleSystem The JSON object to parse
  85501. * @param scene The scene to create the particle system in
  85502. * @param rootUrl The root url to use to load external dependencies like texture
  85503. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85504. * @returns the Parsed particle system
  85505. */
  85506. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85507. }
  85508. }
  85509. declare module BABYLON {
  85510. /**
  85511. * A particle represents one of the element emitted by a particle system.
  85512. * This is mainly define by its coordinates, direction, velocity and age.
  85513. */
  85514. export class Particle {
  85515. /**
  85516. * The particle system the particle belongs to.
  85517. */
  85518. particleSystem: ParticleSystem;
  85519. private static _Count;
  85520. /**
  85521. * Unique ID of the particle
  85522. */
  85523. id: number;
  85524. /**
  85525. * The world position of the particle in the scene.
  85526. */
  85527. position: Vector3;
  85528. /**
  85529. * The world direction of the particle in the scene.
  85530. */
  85531. direction: Vector3;
  85532. /**
  85533. * The color of the particle.
  85534. */
  85535. color: Color4;
  85536. /**
  85537. * The color change of the particle per step.
  85538. */
  85539. colorStep: Color4;
  85540. /**
  85541. * Defines how long will the life of the particle be.
  85542. */
  85543. lifeTime: number;
  85544. /**
  85545. * The current age of the particle.
  85546. */
  85547. age: number;
  85548. /**
  85549. * The current size of the particle.
  85550. */
  85551. size: number;
  85552. /**
  85553. * The current scale of the particle.
  85554. */
  85555. scale: Vector2;
  85556. /**
  85557. * The current angle of the particle.
  85558. */
  85559. angle: number;
  85560. /**
  85561. * Defines how fast is the angle changing.
  85562. */
  85563. angularSpeed: number;
  85564. /**
  85565. * Defines the cell index used by the particle to be rendered from a sprite.
  85566. */
  85567. cellIndex: number;
  85568. /**
  85569. * The information required to support color remapping
  85570. */
  85571. remapData: Vector4;
  85572. /** @hidden */
  85573. _randomCellOffset?: number;
  85574. /** @hidden */
  85575. _initialDirection: Nullable<Vector3>;
  85576. /** @hidden */
  85577. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85578. /** @hidden */
  85579. _initialStartSpriteCellID: number;
  85580. /** @hidden */
  85581. _initialEndSpriteCellID: number;
  85582. /** @hidden */
  85583. _currentColorGradient: Nullable<ColorGradient>;
  85584. /** @hidden */
  85585. _currentColor1: Color4;
  85586. /** @hidden */
  85587. _currentColor2: Color4;
  85588. /** @hidden */
  85589. _currentSizeGradient: Nullable<FactorGradient>;
  85590. /** @hidden */
  85591. _currentSize1: number;
  85592. /** @hidden */
  85593. _currentSize2: number;
  85594. /** @hidden */
  85595. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85596. /** @hidden */
  85597. _currentAngularSpeed1: number;
  85598. /** @hidden */
  85599. _currentAngularSpeed2: number;
  85600. /** @hidden */
  85601. _currentVelocityGradient: Nullable<FactorGradient>;
  85602. /** @hidden */
  85603. _currentVelocity1: number;
  85604. /** @hidden */
  85605. _currentVelocity2: number;
  85606. /** @hidden */
  85607. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85608. /** @hidden */
  85609. _currentLimitVelocity1: number;
  85610. /** @hidden */
  85611. _currentLimitVelocity2: number;
  85612. /** @hidden */
  85613. _currentDragGradient: Nullable<FactorGradient>;
  85614. /** @hidden */
  85615. _currentDrag1: number;
  85616. /** @hidden */
  85617. _currentDrag2: number;
  85618. /** @hidden */
  85619. _randomNoiseCoordinates1: Vector3;
  85620. /** @hidden */
  85621. _randomNoiseCoordinates2: Vector3;
  85622. /**
  85623. * Creates a new instance Particle
  85624. * @param particleSystem the particle system the particle belongs to
  85625. */
  85626. constructor(
  85627. /**
  85628. * The particle system the particle belongs to.
  85629. */
  85630. particleSystem: ParticleSystem);
  85631. private updateCellInfoFromSystem;
  85632. /**
  85633. * Defines how the sprite cell index is updated for the particle
  85634. */
  85635. updateCellIndex(): void;
  85636. /** @hidden */
  85637. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85638. /** @hidden */
  85639. _inheritParticleInfoToSubEmitters(): void;
  85640. /** @hidden */
  85641. _reset(): void;
  85642. /**
  85643. * Copy the properties of particle to another one.
  85644. * @param other the particle to copy the information to.
  85645. */
  85646. copyTo(other: Particle): void;
  85647. }
  85648. }
  85649. declare module BABYLON {
  85650. /**
  85651. * Particle emitter represents a volume emitting particles.
  85652. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85653. */
  85654. export interface IParticleEmitterType {
  85655. /**
  85656. * Called by the particle System when the direction is computed for the created particle.
  85657. * @param worldMatrix is the world matrix of the particle system
  85658. * @param directionToUpdate is the direction vector to update with the result
  85659. * @param particle is the particle we are computed the direction for
  85660. */
  85661. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85662. /**
  85663. * Called by the particle System when the position is computed for the created particle.
  85664. * @param worldMatrix is the world matrix of the particle system
  85665. * @param positionToUpdate is the position vector to update with the result
  85666. * @param particle is the particle we are computed the position for
  85667. */
  85668. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85669. /**
  85670. * Clones the current emitter and returns a copy of it
  85671. * @returns the new emitter
  85672. */
  85673. clone(): IParticleEmitterType;
  85674. /**
  85675. * Called by the GPUParticleSystem to setup the update shader
  85676. * @param effect defines the update shader
  85677. */
  85678. applyToShader(effect: Effect): void;
  85679. /**
  85680. * Returns a string to use to update the GPU particles update shader
  85681. * @returns the effect defines string
  85682. */
  85683. getEffectDefines(): string;
  85684. /**
  85685. * Returns a string representing the class name
  85686. * @returns a string containing the class name
  85687. */
  85688. getClassName(): string;
  85689. /**
  85690. * Serializes the particle system to a JSON object.
  85691. * @returns the JSON object
  85692. */
  85693. serialize(): any;
  85694. /**
  85695. * Parse properties from a JSON object
  85696. * @param serializationObject defines the JSON object
  85697. */
  85698. parse(serializationObject: any): void;
  85699. }
  85700. }
  85701. declare module BABYLON {
  85702. /**
  85703. * Particle emitter emitting particles from the inside of a box.
  85704. * It emits the particles randomly between 2 given directions.
  85705. */
  85706. export class BoxParticleEmitter implements IParticleEmitterType {
  85707. /**
  85708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85709. */
  85710. direction1: Vector3;
  85711. /**
  85712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85713. */
  85714. direction2: Vector3;
  85715. /**
  85716. * 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.
  85717. */
  85718. minEmitBox: Vector3;
  85719. /**
  85720. * 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.
  85721. */
  85722. maxEmitBox: Vector3;
  85723. /**
  85724. * Creates a new instance BoxParticleEmitter
  85725. */
  85726. constructor();
  85727. /**
  85728. * Called by the particle System when the direction is computed for the created particle.
  85729. * @param worldMatrix is the world matrix of the particle system
  85730. * @param directionToUpdate is the direction vector to update with the result
  85731. * @param particle is the particle we are computed the direction for
  85732. */
  85733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85734. /**
  85735. * Called by the particle System when the position is computed for the created particle.
  85736. * @param worldMatrix is the world matrix of the particle system
  85737. * @param positionToUpdate is the position vector to update with the result
  85738. * @param particle is the particle we are computed the position for
  85739. */
  85740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85741. /**
  85742. * Clones the current emitter and returns a copy of it
  85743. * @returns the new emitter
  85744. */
  85745. clone(): BoxParticleEmitter;
  85746. /**
  85747. * Called by the GPUParticleSystem to setup the update shader
  85748. * @param effect defines the update shader
  85749. */
  85750. applyToShader(effect: Effect): void;
  85751. /**
  85752. * Returns a string to use to update the GPU particles update shader
  85753. * @returns a string containng the defines string
  85754. */
  85755. getEffectDefines(): string;
  85756. /**
  85757. * Returns the string "BoxParticleEmitter"
  85758. * @returns a string containing the class name
  85759. */
  85760. getClassName(): string;
  85761. /**
  85762. * Serializes the particle system to a JSON object.
  85763. * @returns the JSON object
  85764. */
  85765. serialize(): any;
  85766. /**
  85767. * Parse properties from a JSON object
  85768. * @param serializationObject defines the JSON object
  85769. */
  85770. parse(serializationObject: any): void;
  85771. }
  85772. }
  85773. declare module BABYLON {
  85774. /**
  85775. * Particle emitter emitting particles from the inside of a cone.
  85776. * It emits the particles alongside the cone volume from the base to the particle.
  85777. * The emission direction might be randomized.
  85778. */
  85779. export class ConeParticleEmitter implements IParticleEmitterType {
  85780. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85781. directionRandomizer: number;
  85782. private _radius;
  85783. private _angle;
  85784. private _height;
  85785. /**
  85786. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85787. */
  85788. radiusRange: number;
  85789. /**
  85790. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85791. */
  85792. heightRange: number;
  85793. /**
  85794. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85795. */
  85796. emitFromSpawnPointOnly: boolean;
  85797. /**
  85798. * Gets or sets the radius of the emission cone
  85799. */
  85800. radius: number;
  85801. /**
  85802. * Gets or sets the angle of the emission cone
  85803. */
  85804. angle: number;
  85805. private _buildHeight;
  85806. /**
  85807. * Creates a new instance ConeParticleEmitter
  85808. * @param radius the radius of the emission cone (1 by default)
  85809. * @param angle the cone base angle (PI by default)
  85810. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85811. */
  85812. constructor(radius?: number, angle?: number,
  85813. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85814. directionRandomizer?: number);
  85815. /**
  85816. * Called by the particle System when the direction is computed for the created particle.
  85817. * @param worldMatrix is the world matrix of the particle system
  85818. * @param directionToUpdate is the direction vector to update with the result
  85819. * @param particle is the particle we are computed the direction for
  85820. */
  85821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85822. /**
  85823. * Called by the particle System when the position is computed for the created particle.
  85824. * @param worldMatrix is the world matrix of the particle system
  85825. * @param positionToUpdate is the position vector to update with the result
  85826. * @param particle is the particle we are computed the position for
  85827. */
  85828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85829. /**
  85830. * Clones the current emitter and returns a copy of it
  85831. * @returns the new emitter
  85832. */
  85833. clone(): ConeParticleEmitter;
  85834. /**
  85835. * Called by the GPUParticleSystem to setup the update shader
  85836. * @param effect defines the update shader
  85837. */
  85838. applyToShader(effect: Effect): void;
  85839. /**
  85840. * Returns a string to use to update the GPU particles update shader
  85841. * @returns a string containng the defines string
  85842. */
  85843. getEffectDefines(): string;
  85844. /**
  85845. * Returns the string "ConeParticleEmitter"
  85846. * @returns a string containing the class name
  85847. */
  85848. getClassName(): string;
  85849. /**
  85850. * Serializes the particle system to a JSON object.
  85851. * @returns the JSON object
  85852. */
  85853. serialize(): any;
  85854. /**
  85855. * Parse properties from a JSON object
  85856. * @param serializationObject defines the JSON object
  85857. */
  85858. parse(serializationObject: any): void;
  85859. }
  85860. }
  85861. declare module BABYLON {
  85862. /**
  85863. * Particle emitter emitting particles from the inside of a cylinder.
  85864. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85865. */
  85866. export class CylinderParticleEmitter implements IParticleEmitterType {
  85867. /**
  85868. * The radius of the emission cylinder.
  85869. */
  85870. radius: number;
  85871. /**
  85872. * The height of the emission cylinder.
  85873. */
  85874. height: number;
  85875. /**
  85876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85877. */
  85878. radiusRange: number;
  85879. /**
  85880. * How much to randomize the particle direction [0-1].
  85881. */
  85882. directionRandomizer: number;
  85883. /**
  85884. * Creates a new instance CylinderParticleEmitter
  85885. * @param radius the radius of the emission cylinder (1 by default)
  85886. * @param height the height of the emission cylinder (1 by default)
  85887. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85888. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85889. */
  85890. constructor(
  85891. /**
  85892. * The radius of the emission cylinder.
  85893. */
  85894. radius?: number,
  85895. /**
  85896. * The height of the emission cylinder.
  85897. */
  85898. height?: number,
  85899. /**
  85900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85901. */
  85902. radiusRange?: number,
  85903. /**
  85904. * How much to randomize the particle direction [0-1].
  85905. */
  85906. directionRandomizer?: number);
  85907. /**
  85908. * Called by the particle System when the direction is computed for the created particle.
  85909. * @param worldMatrix is the world matrix of the particle system
  85910. * @param directionToUpdate is the direction vector to update with the result
  85911. * @param particle is the particle we are computed the direction for
  85912. */
  85913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85914. /**
  85915. * Called by the particle System when the position is computed for the created particle.
  85916. * @param worldMatrix is the world matrix of the particle system
  85917. * @param positionToUpdate is the position vector to update with the result
  85918. * @param particle is the particle we are computed the position for
  85919. */
  85920. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85921. /**
  85922. * Clones the current emitter and returns a copy of it
  85923. * @returns the new emitter
  85924. */
  85925. clone(): CylinderParticleEmitter;
  85926. /**
  85927. * Called by the GPUParticleSystem to setup the update shader
  85928. * @param effect defines the update shader
  85929. */
  85930. applyToShader(effect: Effect): void;
  85931. /**
  85932. * Returns a string to use to update the GPU particles update shader
  85933. * @returns a string containng the defines string
  85934. */
  85935. getEffectDefines(): string;
  85936. /**
  85937. * Returns the string "CylinderParticleEmitter"
  85938. * @returns a string containing the class name
  85939. */
  85940. getClassName(): string;
  85941. /**
  85942. * Serializes the particle system to a JSON object.
  85943. * @returns the JSON object
  85944. */
  85945. serialize(): any;
  85946. /**
  85947. * Parse properties from a JSON object
  85948. * @param serializationObject defines the JSON object
  85949. */
  85950. parse(serializationObject: any): void;
  85951. }
  85952. /**
  85953. * Particle emitter emitting particles from the inside of a cylinder.
  85954. * It emits the particles randomly between two vectors.
  85955. */
  85956. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85957. /**
  85958. * The min limit of the emission direction.
  85959. */
  85960. direction1: Vector3;
  85961. /**
  85962. * The max limit of the emission direction.
  85963. */
  85964. direction2: Vector3;
  85965. /**
  85966. * Creates a new instance CylinderDirectedParticleEmitter
  85967. * @param radius the radius of the emission cylinder (1 by default)
  85968. * @param height the height of the emission cylinder (1 by default)
  85969. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85970. * @param direction1 the min limit of the emission direction (up vector by default)
  85971. * @param direction2 the max limit of the emission direction (up vector by default)
  85972. */
  85973. constructor(radius?: number, height?: number, radiusRange?: number,
  85974. /**
  85975. * The min limit of the emission direction.
  85976. */
  85977. direction1?: Vector3,
  85978. /**
  85979. * The max limit of the emission direction.
  85980. */
  85981. direction2?: Vector3);
  85982. /**
  85983. * Called by the particle System when the direction is computed for the created particle.
  85984. * @param worldMatrix is the world matrix of the particle system
  85985. * @param directionToUpdate is the direction vector to update with the result
  85986. * @param particle is the particle we are computed the direction for
  85987. */
  85988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85989. /**
  85990. * Clones the current emitter and returns a copy of it
  85991. * @returns the new emitter
  85992. */
  85993. clone(): CylinderDirectedParticleEmitter;
  85994. /**
  85995. * Called by the GPUParticleSystem to setup the update shader
  85996. * @param effect defines the update shader
  85997. */
  85998. applyToShader(effect: Effect): void;
  85999. /**
  86000. * Returns a string to use to update the GPU particles update shader
  86001. * @returns a string containng the defines string
  86002. */
  86003. getEffectDefines(): string;
  86004. /**
  86005. * Returns the string "CylinderDirectedParticleEmitter"
  86006. * @returns a string containing the class name
  86007. */
  86008. getClassName(): string;
  86009. /**
  86010. * Serializes the particle system to a JSON object.
  86011. * @returns the JSON object
  86012. */
  86013. serialize(): any;
  86014. /**
  86015. * Parse properties from a JSON object
  86016. * @param serializationObject defines the JSON object
  86017. */
  86018. parse(serializationObject: any): void;
  86019. }
  86020. }
  86021. declare module BABYLON {
  86022. /**
  86023. * Particle emitter emitting particles from the inside of a hemisphere.
  86024. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86025. */
  86026. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86027. /**
  86028. * The radius of the emission hemisphere.
  86029. */
  86030. radius: number;
  86031. /**
  86032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86033. */
  86034. radiusRange: number;
  86035. /**
  86036. * How much to randomize the particle direction [0-1].
  86037. */
  86038. directionRandomizer: number;
  86039. /**
  86040. * Creates a new instance HemisphericParticleEmitter
  86041. * @param radius the radius of the emission hemisphere (1 by default)
  86042. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86043. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86044. */
  86045. constructor(
  86046. /**
  86047. * The radius of the emission hemisphere.
  86048. */
  86049. radius?: number,
  86050. /**
  86051. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86052. */
  86053. radiusRange?: number,
  86054. /**
  86055. * How much to randomize the particle direction [0-1].
  86056. */
  86057. directionRandomizer?: number);
  86058. /**
  86059. * Called by the particle System when the direction is computed for the created particle.
  86060. * @param worldMatrix is the world matrix of the particle system
  86061. * @param directionToUpdate is the direction vector to update with the result
  86062. * @param particle is the particle we are computed the direction for
  86063. */
  86064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86065. /**
  86066. * Called by the particle System when the position is computed for the created particle.
  86067. * @param worldMatrix is the world matrix of the particle system
  86068. * @param positionToUpdate is the position vector to update with the result
  86069. * @param particle is the particle we are computed the position for
  86070. */
  86071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86072. /**
  86073. * Clones the current emitter and returns a copy of it
  86074. * @returns the new emitter
  86075. */
  86076. clone(): HemisphericParticleEmitter;
  86077. /**
  86078. * Called by the GPUParticleSystem to setup the update shader
  86079. * @param effect defines the update shader
  86080. */
  86081. applyToShader(effect: Effect): void;
  86082. /**
  86083. * Returns a string to use to update the GPU particles update shader
  86084. * @returns a string containng the defines string
  86085. */
  86086. getEffectDefines(): string;
  86087. /**
  86088. * Returns the string "HemisphericParticleEmitter"
  86089. * @returns a string containing the class name
  86090. */
  86091. getClassName(): string;
  86092. /**
  86093. * Serializes the particle system to a JSON object.
  86094. * @returns the JSON object
  86095. */
  86096. serialize(): any;
  86097. /**
  86098. * Parse properties from a JSON object
  86099. * @param serializationObject defines the JSON object
  86100. */
  86101. parse(serializationObject: any): void;
  86102. }
  86103. }
  86104. declare module BABYLON {
  86105. /**
  86106. * Particle emitter emitting particles from a point.
  86107. * It emits the particles randomly between 2 given directions.
  86108. */
  86109. export class PointParticleEmitter implements IParticleEmitterType {
  86110. /**
  86111. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86112. */
  86113. direction1: Vector3;
  86114. /**
  86115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86116. */
  86117. direction2: Vector3;
  86118. /**
  86119. * Creates a new instance PointParticleEmitter
  86120. */
  86121. constructor();
  86122. /**
  86123. * Called by the particle System when the direction is computed for the created particle.
  86124. * @param worldMatrix is the world matrix of the particle system
  86125. * @param directionToUpdate is the direction vector to update with the result
  86126. * @param particle is the particle we are computed the direction for
  86127. */
  86128. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86129. /**
  86130. * Called by the particle System when the position is computed for the created particle.
  86131. * @param worldMatrix is the world matrix of the particle system
  86132. * @param positionToUpdate is the position vector to update with the result
  86133. * @param particle is the particle we are computed the position for
  86134. */
  86135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86136. /**
  86137. * Clones the current emitter and returns a copy of it
  86138. * @returns the new emitter
  86139. */
  86140. clone(): PointParticleEmitter;
  86141. /**
  86142. * Called by the GPUParticleSystem to setup the update shader
  86143. * @param effect defines the update shader
  86144. */
  86145. applyToShader(effect: Effect): void;
  86146. /**
  86147. * Returns a string to use to update the GPU particles update shader
  86148. * @returns a string containng the defines string
  86149. */
  86150. getEffectDefines(): string;
  86151. /**
  86152. * Returns the string "PointParticleEmitter"
  86153. * @returns a string containing the class name
  86154. */
  86155. getClassName(): string;
  86156. /**
  86157. * Serializes the particle system to a JSON object.
  86158. * @returns the JSON object
  86159. */
  86160. serialize(): any;
  86161. /**
  86162. * Parse properties from a JSON object
  86163. * @param serializationObject defines the JSON object
  86164. */
  86165. parse(serializationObject: any): void;
  86166. }
  86167. }
  86168. declare module BABYLON {
  86169. /**
  86170. * Particle emitter emitting particles from the inside of a sphere.
  86171. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86172. */
  86173. export class SphereParticleEmitter implements IParticleEmitterType {
  86174. /**
  86175. * The radius of the emission sphere.
  86176. */
  86177. radius: number;
  86178. /**
  86179. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86180. */
  86181. radiusRange: number;
  86182. /**
  86183. * How much to randomize the particle direction [0-1].
  86184. */
  86185. directionRandomizer: number;
  86186. /**
  86187. * Creates a new instance SphereParticleEmitter
  86188. * @param radius the radius of the emission sphere (1 by default)
  86189. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86190. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86191. */
  86192. constructor(
  86193. /**
  86194. * The radius of the emission sphere.
  86195. */
  86196. radius?: number,
  86197. /**
  86198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86199. */
  86200. radiusRange?: number,
  86201. /**
  86202. * How much to randomize the particle direction [0-1].
  86203. */
  86204. directionRandomizer?: number);
  86205. /**
  86206. * Called by the particle System when the direction is computed for the created particle.
  86207. * @param worldMatrix is the world matrix of the particle system
  86208. * @param directionToUpdate is the direction vector to update with the result
  86209. * @param particle is the particle we are computed the direction for
  86210. */
  86211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86212. /**
  86213. * Called by the particle System when the position is computed for the created particle.
  86214. * @param worldMatrix is the world matrix of the particle system
  86215. * @param positionToUpdate is the position vector to update with the result
  86216. * @param particle is the particle we are computed the position for
  86217. */
  86218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86219. /**
  86220. * Clones the current emitter and returns a copy of it
  86221. * @returns the new emitter
  86222. */
  86223. clone(): SphereParticleEmitter;
  86224. /**
  86225. * Called by the GPUParticleSystem to setup the update shader
  86226. * @param effect defines the update shader
  86227. */
  86228. applyToShader(effect: Effect): void;
  86229. /**
  86230. * Returns a string to use to update the GPU particles update shader
  86231. * @returns a string containng the defines string
  86232. */
  86233. getEffectDefines(): string;
  86234. /**
  86235. * Returns the string "SphereParticleEmitter"
  86236. * @returns a string containing the class name
  86237. */
  86238. getClassName(): string;
  86239. /**
  86240. * Serializes the particle system to a JSON object.
  86241. * @returns the JSON object
  86242. */
  86243. serialize(): any;
  86244. /**
  86245. * Parse properties from a JSON object
  86246. * @param serializationObject defines the JSON object
  86247. */
  86248. parse(serializationObject: any): void;
  86249. }
  86250. /**
  86251. * Particle emitter emitting particles from the inside of a sphere.
  86252. * It emits the particles randomly between two vectors.
  86253. */
  86254. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86255. /**
  86256. * The min limit of the emission direction.
  86257. */
  86258. direction1: Vector3;
  86259. /**
  86260. * The max limit of the emission direction.
  86261. */
  86262. direction2: Vector3;
  86263. /**
  86264. * Creates a new instance SphereDirectedParticleEmitter
  86265. * @param radius the radius of the emission sphere (1 by default)
  86266. * @param direction1 the min limit of the emission direction (up vector by default)
  86267. * @param direction2 the max limit of the emission direction (up vector by default)
  86268. */
  86269. constructor(radius?: number,
  86270. /**
  86271. * The min limit of the emission direction.
  86272. */
  86273. direction1?: Vector3,
  86274. /**
  86275. * The max limit of the emission direction.
  86276. */
  86277. direction2?: Vector3);
  86278. /**
  86279. * Called by the particle System when the direction is computed for the created particle.
  86280. * @param worldMatrix is the world matrix of the particle system
  86281. * @param directionToUpdate is the direction vector to update with the result
  86282. * @param particle is the particle we are computed the direction for
  86283. */
  86284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86285. /**
  86286. * Clones the current emitter and returns a copy of it
  86287. * @returns the new emitter
  86288. */
  86289. clone(): SphereDirectedParticleEmitter;
  86290. /**
  86291. * Called by the GPUParticleSystem to setup the update shader
  86292. * @param effect defines the update shader
  86293. */
  86294. applyToShader(effect: Effect): void;
  86295. /**
  86296. * Returns a string to use to update the GPU particles update shader
  86297. * @returns a string containng the defines string
  86298. */
  86299. getEffectDefines(): string;
  86300. /**
  86301. * Returns the string "SphereDirectedParticleEmitter"
  86302. * @returns a string containing the class name
  86303. */
  86304. getClassName(): string;
  86305. /**
  86306. * Serializes the particle system to a JSON object.
  86307. * @returns the JSON object
  86308. */
  86309. serialize(): any;
  86310. /**
  86311. * Parse properties from a JSON object
  86312. * @param serializationObject defines the JSON object
  86313. */
  86314. parse(serializationObject: any): void;
  86315. }
  86316. }
  86317. declare module BABYLON {
  86318. /**
  86319. * Interface representing a particle system in Babylon.js.
  86320. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86321. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86322. */
  86323. export interface IParticleSystem {
  86324. /**
  86325. * List of animations used by the particle system.
  86326. */
  86327. animations: Animation[];
  86328. /**
  86329. * The id of the Particle system.
  86330. */
  86331. id: string;
  86332. /**
  86333. * The name of the Particle system.
  86334. */
  86335. name: string;
  86336. /**
  86337. * The emitter represents the Mesh or position we are attaching the particle system to.
  86338. */
  86339. emitter: Nullable<AbstractMesh | Vector3>;
  86340. /**
  86341. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86342. */
  86343. isBillboardBased: boolean;
  86344. /**
  86345. * The rendering group used by the Particle system to chose when to render.
  86346. */
  86347. renderingGroupId: number;
  86348. /**
  86349. * The layer mask we are rendering the particles through.
  86350. */
  86351. layerMask: number;
  86352. /**
  86353. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86354. */
  86355. updateSpeed: number;
  86356. /**
  86357. * The amount of time the particle system is running (depends of the overall update speed).
  86358. */
  86359. targetStopDuration: number;
  86360. /**
  86361. * The texture used to render each particle. (this can be a spritesheet)
  86362. */
  86363. particleTexture: Nullable<Texture>;
  86364. /**
  86365. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86366. */
  86367. blendMode: number;
  86368. /**
  86369. * Minimum life time of emitting particles.
  86370. */
  86371. minLifeTime: number;
  86372. /**
  86373. * Maximum life time of emitting particles.
  86374. */
  86375. maxLifeTime: number;
  86376. /**
  86377. * Minimum Size of emitting particles.
  86378. */
  86379. minSize: number;
  86380. /**
  86381. * Maximum Size of emitting particles.
  86382. */
  86383. maxSize: number;
  86384. /**
  86385. * Minimum scale of emitting particles on X axis.
  86386. */
  86387. minScaleX: number;
  86388. /**
  86389. * Maximum scale of emitting particles on X axis.
  86390. */
  86391. maxScaleX: number;
  86392. /**
  86393. * Minimum scale of emitting particles on Y axis.
  86394. */
  86395. minScaleY: number;
  86396. /**
  86397. * Maximum scale of emitting particles on Y axis.
  86398. */
  86399. maxScaleY: number;
  86400. /**
  86401. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86402. */
  86403. color1: Color4;
  86404. /**
  86405. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86406. */
  86407. color2: Color4;
  86408. /**
  86409. * Color the particle will have at the end of its lifetime.
  86410. */
  86411. colorDead: Color4;
  86412. /**
  86413. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86414. */
  86415. emitRate: number;
  86416. /**
  86417. * You can use gravity if you want to give an orientation to your particles.
  86418. */
  86419. gravity: Vector3;
  86420. /**
  86421. * Minimum power of emitting particles.
  86422. */
  86423. minEmitPower: number;
  86424. /**
  86425. * Maximum power of emitting particles.
  86426. */
  86427. maxEmitPower: number;
  86428. /**
  86429. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86430. */
  86431. minAngularSpeed: number;
  86432. /**
  86433. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86434. */
  86435. maxAngularSpeed: number;
  86436. /**
  86437. * Gets or sets the minimal initial rotation in radians.
  86438. */
  86439. minInitialRotation: number;
  86440. /**
  86441. * Gets or sets the maximal initial rotation in radians.
  86442. */
  86443. maxInitialRotation: number;
  86444. /**
  86445. * The particle emitter type defines the emitter used by the particle system.
  86446. * It can be for example box, sphere, or cone...
  86447. */
  86448. particleEmitterType: Nullable<IParticleEmitterType>;
  86449. /**
  86450. * Defines the delay in milliseconds before starting the system (0 by default)
  86451. */
  86452. startDelay: number;
  86453. /**
  86454. * 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
  86455. */
  86456. preWarmCycles: number;
  86457. /**
  86458. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86459. */
  86460. preWarmStepOffset: number;
  86461. /**
  86462. * 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)
  86463. */
  86464. spriteCellChangeSpeed: number;
  86465. /**
  86466. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86467. */
  86468. startSpriteCellID: number;
  86469. /**
  86470. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86471. */
  86472. endSpriteCellID: number;
  86473. /**
  86474. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86475. */
  86476. spriteCellWidth: number;
  86477. /**
  86478. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86479. */
  86480. spriteCellHeight: number;
  86481. /**
  86482. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86483. */
  86484. spriteRandomStartCell: boolean;
  86485. /**
  86486. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86487. */
  86488. isAnimationSheetEnabled: boolean;
  86489. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86490. translationPivot: Vector2;
  86491. /**
  86492. * Gets or sets a texture used to add random noise to particle positions
  86493. */
  86494. noiseTexture: Nullable<BaseTexture>;
  86495. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86496. noiseStrength: Vector3;
  86497. /**
  86498. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86499. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86500. */
  86501. billboardMode: number;
  86502. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86503. limitVelocityDamping: number;
  86504. /**
  86505. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86506. */
  86507. beginAnimationOnStart: boolean;
  86508. /**
  86509. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86510. */
  86511. beginAnimationFrom: number;
  86512. /**
  86513. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86514. */
  86515. beginAnimationTo: number;
  86516. /**
  86517. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86518. */
  86519. beginAnimationLoop: boolean;
  86520. /**
  86521. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86522. */
  86523. disposeOnStop: boolean;
  86524. /**
  86525. * Gets the maximum number of particles active at the same time.
  86526. * @returns The max number of active particles.
  86527. */
  86528. getCapacity(): number;
  86529. /**
  86530. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86531. * @returns True if it has been started, otherwise false.
  86532. */
  86533. isStarted(): boolean;
  86534. /**
  86535. * Animates the particle system for this frame.
  86536. */
  86537. animate(): void;
  86538. /**
  86539. * Renders the particle system in its current state.
  86540. * @returns the current number of particles
  86541. */
  86542. render(): number;
  86543. /**
  86544. * Dispose the particle system and frees its associated resources.
  86545. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86546. */
  86547. dispose(disposeTexture?: boolean): void;
  86548. /**
  86549. * Clones the particle system.
  86550. * @param name The name of the cloned object
  86551. * @param newEmitter The new emitter to use
  86552. * @returns the cloned particle system
  86553. */
  86554. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86555. /**
  86556. * Serializes the particle system to a JSON object.
  86557. * @returns the JSON object
  86558. */
  86559. serialize(): any;
  86560. /**
  86561. * Rebuild the particle system
  86562. */
  86563. rebuild(): void;
  86564. /**
  86565. * Starts the particle system and begins to emit
  86566. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86567. */
  86568. start(delay?: number): void;
  86569. /**
  86570. * Stops the particle system.
  86571. */
  86572. stop(): void;
  86573. /**
  86574. * Remove all active particles
  86575. */
  86576. reset(): void;
  86577. /**
  86578. * Is this system ready to be used/rendered
  86579. * @return true if the system is ready
  86580. */
  86581. isReady(): boolean;
  86582. /**
  86583. * Adds a new color gradient
  86584. * @param gradient defines the gradient to use (between 0 and 1)
  86585. * @param color1 defines the color to affect to the specified gradient
  86586. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86587. * @returns the current particle system
  86588. */
  86589. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86590. /**
  86591. * Remove a specific color gradient
  86592. * @param gradient defines the gradient to remove
  86593. * @returns the current particle system
  86594. */
  86595. removeColorGradient(gradient: number): IParticleSystem;
  86596. /**
  86597. * Adds a new size gradient
  86598. * @param gradient defines the gradient to use (between 0 and 1)
  86599. * @param factor defines the size factor to affect to the specified gradient
  86600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86601. * @returns the current particle system
  86602. */
  86603. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86604. /**
  86605. * Remove a specific size gradient
  86606. * @param gradient defines the gradient to remove
  86607. * @returns the current particle system
  86608. */
  86609. removeSizeGradient(gradient: number): IParticleSystem;
  86610. /**
  86611. * Gets the current list of color gradients.
  86612. * You must use addColorGradient and removeColorGradient to udpate this list
  86613. * @returns the list of color gradients
  86614. */
  86615. getColorGradients(): Nullable<Array<ColorGradient>>;
  86616. /**
  86617. * Gets the current list of size gradients.
  86618. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86619. * @returns the list of size gradients
  86620. */
  86621. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86622. /**
  86623. * Gets the current list of angular speed gradients.
  86624. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86625. * @returns the list of angular speed gradients
  86626. */
  86627. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86628. /**
  86629. * Adds a new angular speed gradient
  86630. * @param gradient defines the gradient to use (between 0 and 1)
  86631. * @param factor defines the angular speed to affect to the specified gradient
  86632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86633. * @returns the current particle system
  86634. */
  86635. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86636. /**
  86637. * Remove a specific angular speed gradient
  86638. * @param gradient defines the gradient to remove
  86639. * @returns the current particle system
  86640. */
  86641. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86642. /**
  86643. * Gets the current list of velocity gradients.
  86644. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86645. * @returns the list of velocity gradients
  86646. */
  86647. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86648. /**
  86649. * Adds a new velocity gradient
  86650. * @param gradient defines the gradient to use (between 0 and 1)
  86651. * @param factor defines the velocity to affect to the specified gradient
  86652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86653. * @returns the current particle system
  86654. */
  86655. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86656. /**
  86657. * Remove a specific velocity gradient
  86658. * @param gradient defines the gradient to remove
  86659. * @returns the current particle system
  86660. */
  86661. removeVelocityGradient(gradient: number): IParticleSystem;
  86662. /**
  86663. * Gets the current list of limit velocity gradients.
  86664. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86665. * @returns the list of limit velocity gradients
  86666. */
  86667. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86668. /**
  86669. * Adds a new limit velocity gradient
  86670. * @param gradient defines the gradient to use (between 0 and 1)
  86671. * @param factor defines the limit velocity to affect to the specified gradient
  86672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86673. * @returns the current particle system
  86674. */
  86675. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86676. /**
  86677. * Remove a specific limit velocity gradient
  86678. * @param gradient defines the gradient to remove
  86679. * @returns the current particle system
  86680. */
  86681. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86682. /**
  86683. * Adds a new drag gradient
  86684. * @param gradient defines the gradient to use (between 0 and 1)
  86685. * @param factor defines the drag to affect to the specified gradient
  86686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86687. * @returns the current particle system
  86688. */
  86689. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86690. /**
  86691. * Remove a specific drag gradient
  86692. * @param gradient defines the gradient to remove
  86693. * @returns the current particle system
  86694. */
  86695. removeDragGradient(gradient: number): IParticleSystem;
  86696. /**
  86697. * Gets the current list of drag gradients.
  86698. * You must use addDragGradient and removeDragGradient to udpate this list
  86699. * @returns the list of drag gradients
  86700. */
  86701. getDragGradients(): Nullable<Array<FactorGradient>>;
  86702. /**
  86703. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86704. * @param gradient defines the gradient to use (between 0 and 1)
  86705. * @param factor defines the emit rate to affect to the specified gradient
  86706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86707. * @returns the current particle system
  86708. */
  86709. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86710. /**
  86711. * Remove a specific emit rate gradient
  86712. * @param gradient defines the gradient to remove
  86713. * @returns the current particle system
  86714. */
  86715. removeEmitRateGradient(gradient: number): IParticleSystem;
  86716. /**
  86717. * Gets the current list of emit rate gradients.
  86718. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86719. * @returns the list of emit rate gradients
  86720. */
  86721. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86722. /**
  86723. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86724. * @param gradient defines the gradient to use (between 0 and 1)
  86725. * @param factor defines the start size to affect to the specified gradient
  86726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86727. * @returns the current particle system
  86728. */
  86729. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86730. /**
  86731. * Remove a specific start size gradient
  86732. * @param gradient defines the gradient to remove
  86733. * @returns the current particle system
  86734. */
  86735. removeStartSizeGradient(gradient: number): IParticleSystem;
  86736. /**
  86737. * Gets the current list of start size gradients.
  86738. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86739. * @returns the list of start size gradients
  86740. */
  86741. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86742. /**
  86743. * Adds a new life time gradient
  86744. * @param gradient defines the gradient to use (between 0 and 1)
  86745. * @param factor defines the life time factor to affect to the specified gradient
  86746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86747. * @returns the current particle system
  86748. */
  86749. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86750. /**
  86751. * Remove a specific life time gradient
  86752. * @param gradient defines the gradient to remove
  86753. * @returns the current particle system
  86754. */
  86755. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86756. /**
  86757. * Gets the current list of life time gradients.
  86758. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86759. * @returns the list of life time gradients
  86760. */
  86761. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86762. /**
  86763. * Gets the current list of color gradients.
  86764. * You must use addColorGradient and removeColorGradient to udpate this list
  86765. * @returns the list of color gradients
  86766. */
  86767. getColorGradients(): Nullable<Array<ColorGradient>>;
  86768. /**
  86769. * Adds a new ramp gradient used to remap particle colors
  86770. * @param gradient defines the gradient to use (between 0 and 1)
  86771. * @param color defines the color to affect to the specified gradient
  86772. * @returns the current particle system
  86773. */
  86774. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86775. /**
  86776. * Gets the current list of ramp gradients.
  86777. * You must use addRampGradient and removeRampGradient to udpate this list
  86778. * @returns the list of ramp gradients
  86779. */
  86780. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86781. /** Gets or sets a boolean indicating that ramp gradients must be used
  86782. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86783. */
  86784. useRampGradients: boolean;
  86785. /**
  86786. * Adds a new color remap gradient
  86787. * @param gradient defines the gradient to use (between 0 and 1)
  86788. * @param min defines the color remap minimal range
  86789. * @param max defines the color remap maximal range
  86790. * @returns the current particle system
  86791. */
  86792. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86793. /**
  86794. * Gets the current list of color remap gradients.
  86795. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86796. * @returns the list of color remap gradients
  86797. */
  86798. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86799. /**
  86800. * Adds a new alpha remap gradient
  86801. * @param gradient defines the gradient to use (between 0 and 1)
  86802. * @param min defines the alpha remap minimal range
  86803. * @param max defines the alpha remap maximal range
  86804. * @returns the current particle system
  86805. */
  86806. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86807. /**
  86808. * Gets the current list of alpha remap gradients.
  86809. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86810. * @returns the list of alpha remap gradients
  86811. */
  86812. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86813. /**
  86814. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86817. * @returns the emitter
  86818. */
  86819. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86820. /**
  86821. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86822. * @param radius The radius of the hemisphere to emit from
  86823. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86824. * @returns the emitter
  86825. */
  86826. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86827. /**
  86828. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86829. * @param radius The radius of the sphere to emit from
  86830. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86831. * @returns the emitter
  86832. */
  86833. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86834. /**
  86835. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86836. * @param radius The radius of the sphere to emit from
  86837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86839. * @returns the emitter
  86840. */
  86841. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86842. /**
  86843. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86844. * @param radius The radius of the emission cylinder
  86845. * @param height The height of the emission cylinder
  86846. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86847. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86848. * @returns the emitter
  86849. */
  86850. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86851. /**
  86852. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86853. * @param radius The radius of the cylinder to emit from
  86854. * @param height The height of the emission cylinder
  86855. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86858. * @returns the emitter
  86859. */
  86860. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86861. /**
  86862. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86863. * @param radius The radius of the cone to emit from
  86864. * @param angle The base angle of the cone
  86865. * @returns the emitter
  86866. */
  86867. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86868. /**
  86869. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86872. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86873. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86874. * @returns the emitter
  86875. */
  86876. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86877. /**
  86878. * Get hosting scene
  86879. * @returns the scene
  86880. */
  86881. getScene(): Scene;
  86882. }
  86883. }
  86884. declare module BABYLON {
  86885. /**
  86886. * Creates an instance based on a source mesh.
  86887. */
  86888. export class InstancedMesh extends AbstractMesh {
  86889. private _sourceMesh;
  86890. private _currentLOD;
  86891. /** @hidden */
  86892. _indexInSourceMeshInstanceArray: number;
  86893. constructor(name: string, source: Mesh);
  86894. /**
  86895. * Returns the string "InstancedMesh".
  86896. */
  86897. getClassName(): string;
  86898. /** Gets the list of lights affecting that mesh */
  86899. readonly lightSources: Light[];
  86900. _resyncLightSources(): void;
  86901. _resyncLighSource(light: Light): void;
  86902. _removeLightSource(light: Light, dispose: boolean): void;
  86903. /**
  86904. * If the source mesh receives shadows
  86905. */
  86906. readonly receiveShadows: boolean;
  86907. /**
  86908. * The material of the source mesh
  86909. */
  86910. readonly material: Nullable<Material>;
  86911. /**
  86912. * Visibility of the source mesh
  86913. */
  86914. readonly visibility: number;
  86915. /**
  86916. * Skeleton of the source mesh
  86917. */
  86918. readonly skeleton: Nullable<Skeleton>;
  86919. /**
  86920. * Rendering ground id of the source mesh
  86921. */
  86922. renderingGroupId: number;
  86923. /**
  86924. * Returns the total number of vertices (integer).
  86925. */
  86926. getTotalVertices(): number;
  86927. /**
  86928. * Returns a positive integer : the total number of indices in this mesh geometry.
  86929. * @returns the numner of indices or zero if the mesh has no geometry.
  86930. */
  86931. getTotalIndices(): number;
  86932. /**
  86933. * The source mesh of the instance
  86934. */
  86935. readonly sourceMesh: Mesh;
  86936. /**
  86937. * Is this node ready to be used/rendered
  86938. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86939. * @return {boolean} is it ready
  86940. */
  86941. isReady(completeCheck?: boolean): boolean;
  86942. /**
  86943. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86944. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86945. * @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.
  86946. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86947. */
  86948. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86949. /**
  86950. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86951. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86952. * The `data` are either a numeric array either a Float32Array.
  86953. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86954. * 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).
  86955. * Note that a new underlying VertexBuffer object is created each call.
  86956. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86957. *
  86958. * Possible `kind` values :
  86959. * - VertexBuffer.PositionKind
  86960. * - VertexBuffer.UVKind
  86961. * - VertexBuffer.UV2Kind
  86962. * - VertexBuffer.UV3Kind
  86963. * - VertexBuffer.UV4Kind
  86964. * - VertexBuffer.UV5Kind
  86965. * - VertexBuffer.UV6Kind
  86966. * - VertexBuffer.ColorKind
  86967. * - VertexBuffer.MatricesIndicesKind
  86968. * - VertexBuffer.MatricesIndicesExtraKind
  86969. * - VertexBuffer.MatricesWeightsKind
  86970. * - VertexBuffer.MatricesWeightsExtraKind
  86971. *
  86972. * Returns the Mesh.
  86973. */
  86974. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86975. /**
  86976. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86977. * If the mesh has no geometry, it is simply returned as it is.
  86978. * The `data` are either a numeric array either a Float32Array.
  86979. * No new underlying VertexBuffer object is created.
  86980. * 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.
  86981. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86982. *
  86983. * Possible `kind` values :
  86984. * - VertexBuffer.PositionKind
  86985. * - VertexBuffer.UVKind
  86986. * - VertexBuffer.UV2Kind
  86987. * - VertexBuffer.UV3Kind
  86988. * - VertexBuffer.UV4Kind
  86989. * - VertexBuffer.UV5Kind
  86990. * - VertexBuffer.UV6Kind
  86991. * - VertexBuffer.ColorKind
  86992. * - VertexBuffer.MatricesIndicesKind
  86993. * - VertexBuffer.MatricesIndicesExtraKind
  86994. * - VertexBuffer.MatricesWeightsKind
  86995. * - VertexBuffer.MatricesWeightsExtraKind
  86996. *
  86997. * Returns the Mesh.
  86998. */
  86999. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87000. /**
  87001. * Sets the mesh indices.
  87002. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87003. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87004. * This method creates a new index buffer each call.
  87005. * Returns the Mesh.
  87006. */
  87007. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87008. /**
  87009. * Boolean : True if the mesh owns the requested kind of data.
  87010. */
  87011. isVerticesDataPresent(kind: string): boolean;
  87012. /**
  87013. * Returns an array of indices (IndicesArray).
  87014. */
  87015. getIndices(): Nullable<IndicesArray>;
  87016. readonly _positions: Nullable<Vector3[]>;
  87017. /**
  87018. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87019. * This means the mesh underlying bounding box and sphere are recomputed.
  87020. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87021. * @returns the current mesh
  87022. */
  87023. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87024. /** @hidden */
  87025. _preActivate(): InstancedMesh;
  87026. /** @hidden */
  87027. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87028. /** @hidden */
  87029. _postActivate(): void;
  87030. getWorldMatrix(): Matrix;
  87031. readonly isAnInstance: boolean;
  87032. /**
  87033. * Returns the current associated LOD AbstractMesh.
  87034. */
  87035. getLOD(camera: Camera): AbstractMesh;
  87036. /** @hidden */
  87037. _syncSubMeshes(): InstancedMesh;
  87038. /** @hidden */
  87039. _generatePointsArray(): boolean;
  87040. /**
  87041. * Creates a new InstancedMesh from the current mesh.
  87042. * - name (string) : the cloned mesh name
  87043. * - newParent (optional Node) : the optional Node to parent the clone to.
  87044. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87045. *
  87046. * Returns the clone.
  87047. */
  87048. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87049. /**
  87050. * Disposes the InstancedMesh.
  87051. * Returns nothing.
  87052. */
  87053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87054. }
  87055. interface Mesh {
  87056. /**
  87057. * Register a custom buffer that will be instanced
  87058. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87059. * @param kind defines the buffer kind
  87060. * @param stride defines the stride in floats
  87061. */
  87062. registerInstancedBuffer(kind: string, stride: number): void;
  87063. /** @hidden */
  87064. _userInstancedBuffersStorage: {
  87065. data: {
  87066. [key: string]: Float32Array;
  87067. };
  87068. sizes: {
  87069. [key: string]: number;
  87070. };
  87071. vertexBuffers: {
  87072. [key: string]: Nullable<VertexBuffer>;
  87073. };
  87074. strides: {
  87075. [key: string]: number;
  87076. };
  87077. };
  87078. }
  87079. interface AbstractMesh {
  87080. /**
  87081. * Object used to store instanced buffers defined by user
  87082. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87083. */
  87084. instancedBuffers: {
  87085. [key: string]: any;
  87086. };
  87087. }
  87088. }
  87089. declare module BABYLON {
  87090. /**
  87091. * Defines the options associated with the creation of a shader material.
  87092. */
  87093. export interface IShaderMaterialOptions {
  87094. /**
  87095. * Does the material work in alpha blend mode
  87096. */
  87097. needAlphaBlending: boolean;
  87098. /**
  87099. * Does the material work in alpha test mode
  87100. */
  87101. needAlphaTesting: boolean;
  87102. /**
  87103. * The list of attribute names used in the shader
  87104. */
  87105. attributes: string[];
  87106. /**
  87107. * The list of unifrom names used in the shader
  87108. */
  87109. uniforms: string[];
  87110. /**
  87111. * The list of UBO names used in the shader
  87112. */
  87113. uniformBuffers: string[];
  87114. /**
  87115. * The list of sampler names used in the shader
  87116. */
  87117. samplers: string[];
  87118. /**
  87119. * The list of defines used in the shader
  87120. */
  87121. defines: string[];
  87122. }
  87123. /**
  87124. * 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.
  87125. *
  87126. * This returned material effects how the mesh will look based on the code in the shaders.
  87127. *
  87128. * @see http://doc.babylonjs.com/how_to/shader_material
  87129. */
  87130. export class ShaderMaterial extends Material {
  87131. private _shaderPath;
  87132. private _options;
  87133. private _textures;
  87134. private _textureArrays;
  87135. private _floats;
  87136. private _ints;
  87137. private _floatsArrays;
  87138. private _colors3;
  87139. private _colors3Arrays;
  87140. private _colors4;
  87141. private _colors4Arrays;
  87142. private _vectors2;
  87143. private _vectors3;
  87144. private _vectors4;
  87145. private _matrices;
  87146. private _matrixArrays;
  87147. private _matrices3x3;
  87148. private _matrices2x2;
  87149. private _vectors2Arrays;
  87150. private _vectors3Arrays;
  87151. private _vectors4Arrays;
  87152. private _cachedWorldViewMatrix;
  87153. private _cachedWorldViewProjectionMatrix;
  87154. private _renderId;
  87155. /**
  87156. * Instantiate a new shader material.
  87157. * 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.
  87158. * This returned material effects how the mesh will look based on the code in the shaders.
  87159. * @see http://doc.babylonjs.com/how_to/shader_material
  87160. * @param name Define the name of the material in the scene
  87161. * @param scene Define the scene the material belongs to
  87162. * @param shaderPath Defines the route to the shader code in one of three ways:
  87163. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87164. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87165. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87166. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87167. * @param options Define the options used to create the shader
  87168. */
  87169. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87170. /**
  87171. * Gets the options used to compile the shader.
  87172. * They can be modified to trigger a new compilation
  87173. */
  87174. readonly options: IShaderMaterialOptions;
  87175. /**
  87176. * Gets the current class name of the material e.g. "ShaderMaterial"
  87177. * Mainly use in serialization.
  87178. * @returns the class name
  87179. */
  87180. getClassName(): string;
  87181. /**
  87182. * Specifies if the material will require alpha blending
  87183. * @returns a boolean specifying if alpha blending is needed
  87184. */
  87185. needAlphaBlending(): boolean;
  87186. /**
  87187. * Specifies if this material should be rendered in alpha test mode
  87188. * @returns a boolean specifying if an alpha test is needed.
  87189. */
  87190. needAlphaTesting(): boolean;
  87191. private _checkUniform;
  87192. /**
  87193. * Set a texture in the shader.
  87194. * @param name Define the name of the uniform samplers as defined in the shader
  87195. * @param texture Define the texture to bind to this sampler
  87196. * @return the material itself allowing "fluent" like uniform updates
  87197. */
  87198. setTexture(name: string, texture: Texture): ShaderMaterial;
  87199. /**
  87200. * Set a texture array in the shader.
  87201. * @param name Define the name of the uniform sampler array as defined in the shader
  87202. * @param textures Define the list of textures to bind to this sampler
  87203. * @return the material itself allowing "fluent" like uniform updates
  87204. */
  87205. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87206. /**
  87207. * Set a float in the shader.
  87208. * @param name Define the name of the uniform as defined in the shader
  87209. * @param value Define the value to give to the uniform
  87210. * @return the material itself allowing "fluent" like uniform updates
  87211. */
  87212. setFloat(name: string, value: number): ShaderMaterial;
  87213. /**
  87214. * Set a int in the shader.
  87215. * @param name Define the name of the uniform as defined in the shader
  87216. * @param value Define the value to give to the uniform
  87217. * @return the material itself allowing "fluent" like uniform updates
  87218. */
  87219. setInt(name: string, value: number): ShaderMaterial;
  87220. /**
  87221. * Set an array of floats in the shader.
  87222. * @param name Define the name of the uniform as defined in the shader
  87223. * @param value Define the value to give to the uniform
  87224. * @return the material itself allowing "fluent" like uniform updates
  87225. */
  87226. setFloats(name: string, value: number[]): ShaderMaterial;
  87227. /**
  87228. * Set a vec3 in the shader from a Color3.
  87229. * @param name Define the name of the uniform as defined in the shader
  87230. * @param value Define the value to give to the uniform
  87231. * @return the material itself allowing "fluent" like uniform updates
  87232. */
  87233. setColor3(name: string, value: Color3): ShaderMaterial;
  87234. /**
  87235. * Set a vec3 array in the shader from a Color3 array.
  87236. * @param name Define the name of the uniform as defined in the shader
  87237. * @param value Define the value to give to the uniform
  87238. * @return the material itself allowing "fluent" like uniform updates
  87239. */
  87240. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87241. /**
  87242. * Set a vec4 in the shader from a Color4.
  87243. * @param name Define the name of the uniform as defined in the shader
  87244. * @param value Define the value to give to the uniform
  87245. * @return the material itself allowing "fluent" like uniform updates
  87246. */
  87247. setColor4(name: string, value: Color4): ShaderMaterial;
  87248. /**
  87249. * Set a vec4 array in the shader from a Color4 array.
  87250. * @param name Define the name of the uniform as defined in the shader
  87251. * @param value Define the value to give to the uniform
  87252. * @return the material itself allowing "fluent" like uniform updates
  87253. */
  87254. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87255. /**
  87256. * Set a vec2 in the shader from a Vector2.
  87257. * @param name Define the name of the uniform as defined in the shader
  87258. * @param value Define the value to give to the uniform
  87259. * @return the material itself allowing "fluent" like uniform updates
  87260. */
  87261. setVector2(name: string, value: Vector2): ShaderMaterial;
  87262. /**
  87263. * Set a vec3 in the shader from a Vector3.
  87264. * @param name Define the name of the uniform as defined in the shader
  87265. * @param value Define the value to give to the uniform
  87266. * @return the material itself allowing "fluent" like uniform updates
  87267. */
  87268. setVector3(name: string, value: Vector3): ShaderMaterial;
  87269. /**
  87270. * Set a vec4 in the shader from a Vector4.
  87271. * @param name Define the name of the uniform as defined in the shader
  87272. * @param value Define the value to give to the uniform
  87273. * @return the material itself allowing "fluent" like uniform updates
  87274. */
  87275. setVector4(name: string, value: Vector4): ShaderMaterial;
  87276. /**
  87277. * Set a mat4 in the shader from a Matrix.
  87278. * @param name Define the name of the uniform as defined in the shader
  87279. * @param value Define the value to give to the uniform
  87280. * @return the material itself allowing "fluent" like uniform updates
  87281. */
  87282. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87283. /**
  87284. * Set a float32Array in the shader from a matrix array.
  87285. * @param name Define the name of the uniform as defined in the shader
  87286. * @param value Define the value to give to the uniform
  87287. * @return the material itself allowing "fluent" like uniform updates
  87288. */
  87289. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87290. /**
  87291. * Set a mat3 in the shader from a Float32Array.
  87292. * @param name Define the name of the uniform as defined in the shader
  87293. * @param value Define the value to give to the uniform
  87294. * @return the material itself allowing "fluent" like uniform updates
  87295. */
  87296. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87297. /**
  87298. * Set a mat2 in the shader from a Float32Array.
  87299. * @param name Define the name of the uniform as defined in the shader
  87300. * @param value Define the value to give to the uniform
  87301. * @return the material itself allowing "fluent" like uniform updates
  87302. */
  87303. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87304. /**
  87305. * Set a vec2 array in the shader from a number array.
  87306. * @param name Define the name of the uniform as defined in the shader
  87307. * @param value Define the value to give to the uniform
  87308. * @return the material itself allowing "fluent" like uniform updates
  87309. */
  87310. setArray2(name: string, value: number[]): ShaderMaterial;
  87311. /**
  87312. * Set a vec3 array in the shader from a number array.
  87313. * @param name Define the name of the uniform as defined in the shader
  87314. * @param value Define the value to give to the uniform
  87315. * @return the material itself allowing "fluent" like uniform updates
  87316. */
  87317. setArray3(name: string, value: number[]): ShaderMaterial;
  87318. /**
  87319. * Set a vec4 array in the shader from a number array.
  87320. * @param name Define the name of the uniform as defined in the shader
  87321. * @param value Define the value to give to the uniform
  87322. * @return the material itself allowing "fluent" like uniform updates
  87323. */
  87324. setArray4(name: string, value: number[]): ShaderMaterial;
  87325. private _checkCache;
  87326. /**
  87327. * Specifies that the submesh is ready to be used
  87328. * @param mesh defines the mesh to check
  87329. * @param subMesh defines which submesh to check
  87330. * @param useInstances specifies that instances should be used
  87331. * @returns a boolean indicating that the submesh is ready or not
  87332. */
  87333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87334. /**
  87335. * Checks if the material is ready to render the requested mesh
  87336. * @param mesh Define the mesh to render
  87337. * @param useInstances Define whether or not the material is used with instances
  87338. * @returns true if ready, otherwise false
  87339. */
  87340. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87341. /**
  87342. * Binds the world matrix to the material
  87343. * @param world defines the world transformation matrix
  87344. */
  87345. bindOnlyWorldMatrix(world: Matrix): void;
  87346. /**
  87347. * Binds the material to the mesh
  87348. * @param world defines the world transformation matrix
  87349. * @param mesh defines the mesh to bind the material to
  87350. */
  87351. bind(world: Matrix, mesh?: Mesh): void;
  87352. /**
  87353. * Gets the active textures from the material
  87354. * @returns an array of textures
  87355. */
  87356. getActiveTextures(): BaseTexture[];
  87357. /**
  87358. * Specifies if the material uses a texture
  87359. * @param texture defines the texture to check against the material
  87360. * @returns a boolean specifying if the material uses the texture
  87361. */
  87362. hasTexture(texture: BaseTexture): boolean;
  87363. /**
  87364. * Makes a duplicate of the material, and gives it a new name
  87365. * @param name defines the new name for the duplicated material
  87366. * @returns the cloned material
  87367. */
  87368. clone(name: string): ShaderMaterial;
  87369. /**
  87370. * Disposes the material
  87371. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87372. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87373. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87374. */
  87375. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87376. /**
  87377. * Serializes this material in a JSON representation
  87378. * @returns the serialized material object
  87379. */
  87380. serialize(): any;
  87381. /**
  87382. * Creates a shader material from parsed shader material data
  87383. * @param source defines the JSON represnetation of the material
  87384. * @param scene defines the hosting scene
  87385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87386. * @returns a new material
  87387. */
  87388. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87389. }
  87390. }
  87391. declare module BABYLON {
  87392. /** @hidden */
  87393. export var colorPixelShader: {
  87394. name: string;
  87395. shader: string;
  87396. };
  87397. }
  87398. declare module BABYLON {
  87399. /** @hidden */
  87400. export var colorVertexShader: {
  87401. name: string;
  87402. shader: string;
  87403. };
  87404. }
  87405. declare module BABYLON {
  87406. /**
  87407. * Line mesh
  87408. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87409. */
  87410. export class LinesMesh extends Mesh {
  87411. /**
  87412. * If vertex color should be applied to the mesh
  87413. */
  87414. readonly useVertexColor?: boolean | undefined;
  87415. /**
  87416. * If vertex alpha should be applied to the mesh
  87417. */
  87418. readonly useVertexAlpha?: boolean | undefined;
  87419. /**
  87420. * Color of the line (Default: White)
  87421. */
  87422. color: Color3;
  87423. /**
  87424. * Alpha of the line (Default: 1)
  87425. */
  87426. alpha: number;
  87427. /**
  87428. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87429. * This margin is expressed in world space coordinates, so its value may vary.
  87430. * Default value is 0.1
  87431. */
  87432. intersectionThreshold: number;
  87433. private _colorShader;
  87434. private color4;
  87435. /**
  87436. * Creates a new LinesMesh
  87437. * @param name defines the name
  87438. * @param scene defines the hosting scene
  87439. * @param parent defines the parent mesh if any
  87440. * @param source defines the optional source LinesMesh used to clone data from
  87441. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87442. * When false, achieved by calling a clone(), also passing False.
  87443. * This will make creation of children, recursive.
  87444. * @param useVertexColor defines if this LinesMesh supports vertex color
  87445. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87446. */
  87447. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87448. /**
  87449. * If vertex color should be applied to the mesh
  87450. */
  87451. useVertexColor?: boolean | undefined,
  87452. /**
  87453. * If vertex alpha should be applied to the mesh
  87454. */
  87455. useVertexAlpha?: boolean | undefined);
  87456. private _addClipPlaneDefine;
  87457. private _removeClipPlaneDefine;
  87458. isReady(): boolean;
  87459. /**
  87460. * Returns the string "LineMesh"
  87461. */
  87462. getClassName(): string;
  87463. /**
  87464. * @hidden
  87465. */
  87466. /**
  87467. * @hidden
  87468. */
  87469. material: Material;
  87470. /**
  87471. * @hidden
  87472. */
  87473. readonly checkCollisions: boolean;
  87474. /** @hidden */
  87475. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87476. /** @hidden */
  87477. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87478. /**
  87479. * Disposes of the line mesh
  87480. * @param doNotRecurse If children should be disposed
  87481. */
  87482. dispose(doNotRecurse?: boolean): void;
  87483. /**
  87484. * Returns a new LineMesh object cloned from the current one.
  87485. */
  87486. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87487. /**
  87488. * Creates a new InstancedLinesMesh object from the mesh model.
  87489. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87490. * @param name defines the name of the new instance
  87491. * @returns a new InstancedLinesMesh
  87492. */
  87493. createInstance(name: string): InstancedLinesMesh;
  87494. }
  87495. /**
  87496. * Creates an instance based on a source LinesMesh
  87497. */
  87498. export class InstancedLinesMesh extends InstancedMesh {
  87499. /**
  87500. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87501. * This margin is expressed in world space coordinates, so its value may vary.
  87502. * Initilized with the intersectionThreshold value of the source LinesMesh
  87503. */
  87504. intersectionThreshold: number;
  87505. constructor(name: string, source: LinesMesh);
  87506. /**
  87507. * Returns the string "InstancedLinesMesh".
  87508. */
  87509. getClassName(): string;
  87510. }
  87511. }
  87512. declare module BABYLON {
  87513. /** @hidden */
  87514. export var linePixelShader: {
  87515. name: string;
  87516. shader: string;
  87517. };
  87518. }
  87519. declare module BABYLON {
  87520. /** @hidden */
  87521. export var lineVertexShader: {
  87522. name: string;
  87523. shader: string;
  87524. };
  87525. }
  87526. declare module BABYLON {
  87527. interface AbstractMesh {
  87528. /**
  87529. * Gets the edgesRenderer associated with the mesh
  87530. */
  87531. edgesRenderer: Nullable<EdgesRenderer>;
  87532. }
  87533. interface LinesMesh {
  87534. /**
  87535. * Enables the edge rendering mode on the mesh.
  87536. * This mode makes the mesh edges visible
  87537. * @param epsilon defines the maximal distance between two angles to detect a face
  87538. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87539. * @returns the currentAbstractMesh
  87540. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87541. */
  87542. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87543. }
  87544. interface InstancedLinesMesh {
  87545. /**
  87546. * Enables the edge rendering mode on the mesh.
  87547. * This mode makes the mesh edges visible
  87548. * @param epsilon defines the maximal distance between two angles to detect a face
  87549. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87550. * @returns the current InstancedLinesMesh
  87551. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87552. */
  87553. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87554. }
  87555. /**
  87556. * Defines the minimum contract an Edges renderer should follow.
  87557. */
  87558. export interface IEdgesRenderer extends IDisposable {
  87559. /**
  87560. * Gets or sets a boolean indicating if the edgesRenderer is active
  87561. */
  87562. isEnabled: boolean;
  87563. /**
  87564. * Renders the edges of the attached mesh,
  87565. */
  87566. render(): void;
  87567. /**
  87568. * Checks wether or not the edges renderer is ready to render.
  87569. * @return true if ready, otherwise false.
  87570. */
  87571. isReady(): boolean;
  87572. }
  87573. /**
  87574. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87575. */
  87576. export class EdgesRenderer implements IEdgesRenderer {
  87577. /**
  87578. * Define the size of the edges with an orthographic camera
  87579. */
  87580. edgesWidthScalerForOrthographic: number;
  87581. /**
  87582. * Define the size of the edges with a perspective camera
  87583. */
  87584. edgesWidthScalerForPerspective: number;
  87585. protected _source: AbstractMesh;
  87586. protected _linesPositions: number[];
  87587. protected _linesNormals: number[];
  87588. protected _linesIndices: number[];
  87589. protected _epsilon: number;
  87590. protected _indicesCount: number;
  87591. protected _lineShader: ShaderMaterial;
  87592. protected _ib: DataBuffer;
  87593. protected _buffers: {
  87594. [key: string]: Nullable<VertexBuffer>;
  87595. };
  87596. protected _checkVerticesInsteadOfIndices: boolean;
  87597. private _meshRebuildObserver;
  87598. private _meshDisposeObserver;
  87599. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87600. isEnabled: boolean;
  87601. /**
  87602. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87603. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87604. * @param source Mesh used to create edges
  87605. * @param epsilon sum of angles in adjacency to check for edge
  87606. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87607. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87608. */
  87609. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87610. protected _prepareRessources(): void;
  87611. /** @hidden */
  87612. _rebuild(): void;
  87613. /**
  87614. * Releases the required resources for the edges renderer
  87615. */
  87616. dispose(): void;
  87617. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87618. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87619. /**
  87620. * Checks if the pair of p0 and p1 is en edge
  87621. * @param faceIndex
  87622. * @param edge
  87623. * @param faceNormals
  87624. * @param p0
  87625. * @param p1
  87626. * @private
  87627. */
  87628. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87629. /**
  87630. * push line into the position, normal and index buffer
  87631. * @protected
  87632. */
  87633. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87634. /**
  87635. * Generates lines edges from adjacencjes
  87636. * @private
  87637. */
  87638. _generateEdgesLines(): void;
  87639. /**
  87640. * Checks wether or not the edges renderer is ready to render.
  87641. * @return true if ready, otherwise false.
  87642. */
  87643. isReady(): boolean;
  87644. /**
  87645. * Renders the edges of the attached mesh,
  87646. */
  87647. render(): void;
  87648. }
  87649. /**
  87650. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87651. */
  87652. export class LineEdgesRenderer extends EdgesRenderer {
  87653. /**
  87654. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87655. * @param source LineMesh used to generate edges
  87656. * @param epsilon not important (specified angle for edge detection)
  87657. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87658. */
  87659. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87660. /**
  87661. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87662. */
  87663. _generateEdgesLines(): void;
  87664. }
  87665. }
  87666. declare module BABYLON {
  87667. /**
  87668. * This represents the object necessary to create a rendering group.
  87669. * This is exclusively used and created by the rendering manager.
  87670. * To modify the behavior, you use the available helpers in your scene or meshes.
  87671. * @hidden
  87672. */
  87673. export class RenderingGroup {
  87674. index: number;
  87675. private static _zeroVector;
  87676. private _scene;
  87677. private _opaqueSubMeshes;
  87678. private _transparentSubMeshes;
  87679. private _alphaTestSubMeshes;
  87680. private _depthOnlySubMeshes;
  87681. private _particleSystems;
  87682. private _spriteManagers;
  87683. private _opaqueSortCompareFn;
  87684. private _alphaTestSortCompareFn;
  87685. private _transparentSortCompareFn;
  87686. private _renderOpaque;
  87687. private _renderAlphaTest;
  87688. private _renderTransparent;
  87689. /** @hidden */
  87690. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87691. onBeforeTransparentRendering: () => void;
  87692. /**
  87693. * Set the opaque sort comparison function.
  87694. * If null the sub meshes will be render in the order they were created
  87695. */
  87696. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87697. /**
  87698. * Set the alpha test sort comparison function.
  87699. * If null the sub meshes will be render in the order they were created
  87700. */
  87701. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87702. /**
  87703. * Set the transparent sort comparison function.
  87704. * If null the sub meshes will be render in the order they were created
  87705. */
  87706. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87707. /**
  87708. * Creates a new rendering group.
  87709. * @param index The rendering group index
  87710. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87711. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87712. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87713. */
  87714. 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>);
  87715. /**
  87716. * Render all the sub meshes contained in the group.
  87717. * @param customRenderFunction Used to override the default render behaviour of the group.
  87718. * @returns true if rendered some submeshes.
  87719. */
  87720. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87721. /**
  87722. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87723. * @param subMeshes The submeshes to render
  87724. */
  87725. private renderOpaqueSorted;
  87726. /**
  87727. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87728. * @param subMeshes The submeshes to render
  87729. */
  87730. private renderAlphaTestSorted;
  87731. /**
  87732. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87733. * @param subMeshes The submeshes to render
  87734. */
  87735. private renderTransparentSorted;
  87736. /**
  87737. * Renders the submeshes in a specified order.
  87738. * @param subMeshes The submeshes to sort before render
  87739. * @param sortCompareFn The comparison function use to sort
  87740. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87741. * @param transparent Specifies to activate blending if true
  87742. */
  87743. private static renderSorted;
  87744. /**
  87745. * Renders the submeshes in the order they were dispatched (no sort applied).
  87746. * @param subMeshes The submeshes to render
  87747. */
  87748. private static renderUnsorted;
  87749. /**
  87750. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87751. * are rendered back to front if in the same alpha index.
  87752. *
  87753. * @param a The first submesh
  87754. * @param b The second submesh
  87755. * @returns The result of the comparison
  87756. */
  87757. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87758. /**
  87759. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87760. * are rendered back to front.
  87761. *
  87762. * @param a The first submesh
  87763. * @param b The second submesh
  87764. * @returns The result of the comparison
  87765. */
  87766. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87767. /**
  87768. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87769. * are rendered front to back (prevent overdraw).
  87770. *
  87771. * @param a The first submesh
  87772. * @param b The second submesh
  87773. * @returns The result of the comparison
  87774. */
  87775. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87776. /**
  87777. * Resets the different lists of submeshes to prepare a new frame.
  87778. */
  87779. prepare(): void;
  87780. dispose(): void;
  87781. /**
  87782. * Inserts the submesh in its correct queue depending on its material.
  87783. * @param subMesh The submesh to dispatch
  87784. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87785. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87786. */
  87787. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87788. dispatchSprites(spriteManager: ISpriteManager): void;
  87789. dispatchParticles(particleSystem: IParticleSystem): void;
  87790. private _renderParticles;
  87791. private _renderSprites;
  87792. }
  87793. }
  87794. declare module BABYLON {
  87795. /**
  87796. * Interface describing the different options available in the rendering manager
  87797. * regarding Auto Clear between groups.
  87798. */
  87799. export interface IRenderingManagerAutoClearSetup {
  87800. /**
  87801. * Defines whether or not autoclear is enable.
  87802. */
  87803. autoClear: boolean;
  87804. /**
  87805. * Defines whether or not to autoclear the depth buffer.
  87806. */
  87807. depth: boolean;
  87808. /**
  87809. * Defines whether or not to autoclear the stencil buffer.
  87810. */
  87811. stencil: boolean;
  87812. }
  87813. /**
  87814. * This class is used by the onRenderingGroupObservable
  87815. */
  87816. export class RenderingGroupInfo {
  87817. /**
  87818. * The Scene that being rendered
  87819. */
  87820. scene: Scene;
  87821. /**
  87822. * The camera currently used for the rendering pass
  87823. */
  87824. camera: Nullable<Camera>;
  87825. /**
  87826. * The ID of the renderingGroup being processed
  87827. */
  87828. renderingGroupId: number;
  87829. }
  87830. /**
  87831. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87832. * It is enable to manage the different groups as well as the different necessary sort functions.
  87833. * This should not be used directly aside of the few static configurations
  87834. */
  87835. export class RenderingManager {
  87836. /**
  87837. * The max id used for rendering groups (not included)
  87838. */
  87839. static MAX_RENDERINGGROUPS: number;
  87840. /**
  87841. * The min id used for rendering groups (included)
  87842. */
  87843. static MIN_RENDERINGGROUPS: number;
  87844. /**
  87845. * Used to globally prevent autoclearing scenes.
  87846. */
  87847. static AUTOCLEAR: boolean;
  87848. /**
  87849. * @hidden
  87850. */
  87851. _useSceneAutoClearSetup: boolean;
  87852. private _scene;
  87853. private _renderingGroups;
  87854. private _depthStencilBufferAlreadyCleaned;
  87855. private _autoClearDepthStencil;
  87856. private _customOpaqueSortCompareFn;
  87857. private _customAlphaTestSortCompareFn;
  87858. private _customTransparentSortCompareFn;
  87859. private _renderingGroupInfo;
  87860. /**
  87861. * Instantiates a new rendering group for a particular scene
  87862. * @param scene Defines the scene the groups belongs to
  87863. */
  87864. constructor(scene: Scene);
  87865. private _clearDepthStencilBuffer;
  87866. /**
  87867. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87868. * @hidden
  87869. */
  87870. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87871. /**
  87872. * Resets the different information of the group to prepare a new frame
  87873. * @hidden
  87874. */
  87875. reset(): void;
  87876. /**
  87877. * Dispose and release the group and its associated resources.
  87878. * @hidden
  87879. */
  87880. dispose(): void;
  87881. /**
  87882. * Clear the info related to rendering groups preventing retention points during dispose.
  87883. */
  87884. freeRenderingGroups(): void;
  87885. private _prepareRenderingGroup;
  87886. /**
  87887. * Add a sprite manager to the rendering manager in order to render it this frame.
  87888. * @param spriteManager Define the sprite manager to render
  87889. */
  87890. dispatchSprites(spriteManager: ISpriteManager): void;
  87891. /**
  87892. * Add a particle system to the rendering manager in order to render it this frame.
  87893. * @param particleSystem Define the particle system to render
  87894. */
  87895. dispatchParticles(particleSystem: IParticleSystem): void;
  87896. /**
  87897. * Add a submesh to the manager in order to render it this frame
  87898. * @param subMesh The submesh to dispatch
  87899. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87900. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87901. */
  87902. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87903. /**
  87904. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87905. * This allowed control for front to back rendering or reversly depending of the special needs.
  87906. *
  87907. * @param renderingGroupId The rendering group id corresponding to its index
  87908. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87909. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87910. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87911. */
  87912. 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;
  87913. /**
  87914. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87915. *
  87916. * @param renderingGroupId The rendering group id corresponding to its index
  87917. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87918. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87919. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87920. */
  87921. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87922. /**
  87923. * Gets the current auto clear configuration for one rendering group of the rendering
  87924. * manager.
  87925. * @param index the rendering group index to get the information for
  87926. * @returns The auto clear setup for the requested rendering group
  87927. */
  87928. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87929. }
  87930. }
  87931. declare module BABYLON {
  87932. /**
  87933. * This Helps creating a texture that will be created from a camera in your scene.
  87934. * It is basically a dynamic texture that could be used to create special effects for instance.
  87935. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87936. */
  87937. export class RenderTargetTexture extends Texture {
  87938. isCube: boolean;
  87939. /**
  87940. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87941. */
  87942. static readonly REFRESHRATE_RENDER_ONCE: number;
  87943. /**
  87944. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87945. */
  87946. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87947. /**
  87948. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87949. * the central point of your effect and can save a lot of performances.
  87950. */
  87951. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87952. /**
  87953. * Use this predicate to dynamically define the list of mesh you want to render.
  87954. * If set, the renderList property will be overwritten.
  87955. */
  87956. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87957. private _renderList;
  87958. /**
  87959. * Use this list to define the list of mesh you want to render.
  87960. */
  87961. renderList: Nullable<Array<AbstractMesh>>;
  87962. private _hookArray;
  87963. /**
  87964. * Define if particles should be rendered in your texture.
  87965. */
  87966. renderParticles: boolean;
  87967. /**
  87968. * Define if sprites should be rendered in your texture.
  87969. */
  87970. renderSprites: boolean;
  87971. /**
  87972. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87973. */
  87974. coordinatesMode: number;
  87975. /**
  87976. * Define the camera used to render the texture.
  87977. */
  87978. activeCamera: Nullable<Camera>;
  87979. /**
  87980. * Override the render function of the texture with your own one.
  87981. */
  87982. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87983. /**
  87984. * Define if camera post processes should be use while rendering the texture.
  87985. */
  87986. useCameraPostProcesses: boolean;
  87987. /**
  87988. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87989. */
  87990. ignoreCameraViewport: boolean;
  87991. private _postProcessManager;
  87992. private _postProcesses;
  87993. private _resizeObserver;
  87994. /**
  87995. * An event triggered when the texture is unbind.
  87996. */
  87997. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87998. /**
  87999. * An event triggered when the texture is unbind.
  88000. */
  88001. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88002. private _onAfterUnbindObserver;
  88003. /**
  88004. * Set a after unbind callback in the texture.
  88005. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88006. */
  88007. onAfterUnbind: () => void;
  88008. /**
  88009. * An event triggered before rendering the texture
  88010. */
  88011. onBeforeRenderObservable: Observable<number>;
  88012. private _onBeforeRenderObserver;
  88013. /**
  88014. * Set a before render callback in the texture.
  88015. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88016. */
  88017. onBeforeRender: (faceIndex: number) => void;
  88018. /**
  88019. * An event triggered after rendering the texture
  88020. */
  88021. onAfterRenderObservable: Observable<number>;
  88022. private _onAfterRenderObserver;
  88023. /**
  88024. * Set a after render callback in the texture.
  88025. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88026. */
  88027. onAfterRender: (faceIndex: number) => void;
  88028. /**
  88029. * An event triggered after the texture clear
  88030. */
  88031. onClearObservable: Observable<Engine>;
  88032. private _onClearObserver;
  88033. /**
  88034. * Set a clear callback in the texture.
  88035. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88036. */
  88037. onClear: (Engine: Engine) => void;
  88038. /**
  88039. * An event triggered when the texture is resized.
  88040. */
  88041. onResizeObservable: Observable<RenderTargetTexture>;
  88042. /**
  88043. * Define the clear color of the Render Target if it should be different from the scene.
  88044. */
  88045. clearColor: Color4;
  88046. protected _size: number | {
  88047. width: number;
  88048. height: number;
  88049. };
  88050. protected _initialSizeParameter: number | {
  88051. width: number;
  88052. height: number;
  88053. } | {
  88054. ratio: number;
  88055. };
  88056. protected _sizeRatio: Nullable<number>;
  88057. /** @hidden */
  88058. _generateMipMaps: boolean;
  88059. protected _renderingManager: RenderingManager;
  88060. /** @hidden */
  88061. _waitingRenderList: string[];
  88062. protected _doNotChangeAspectRatio: boolean;
  88063. protected _currentRefreshId: number;
  88064. protected _refreshRate: number;
  88065. protected _textureMatrix: Matrix;
  88066. protected _samples: number;
  88067. protected _renderTargetOptions: RenderTargetCreationOptions;
  88068. /**
  88069. * Gets render target creation options that were used.
  88070. */
  88071. readonly renderTargetOptions: RenderTargetCreationOptions;
  88072. protected _engine: Engine;
  88073. protected _onRatioRescale(): void;
  88074. /**
  88075. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88076. * It must define where the camera used to render the texture is set
  88077. */
  88078. boundingBoxPosition: Vector3;
  88079. private _boundingBoxSize;
  88080. /**
  88081. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88082. * When defined, the cubemap will switch to local mode
  88083. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88084. * @example https://www.babylonjs-playground.com/#RNASML
  88085. */
  88086. boundingBoxSize: Vector3;
  88087. /**
  88088. * In case the RTT has been created with a depth texture, get the associated
  88089. * depth texture.
  88090. * Otherwise, return null.
  88091. */
  88092. depthStencilTexture: Nullable<InternalTexture>;
  88093. /**
  88094. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88095. * or used a shadow, depth texture...
  88096. * @param name The friendly name of the texture
  88097. * @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)
  88098. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88099. * @param generateMipMaps True if mip maps need to be generated after render.
  88100. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88101. * @param type The type of the buffer in the RTT (int, half float, float...)
  88102. * @param isCube True if a cube texture needs to be created
  88103. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88104. * @param generateDepthBuffer True to generate a depth buffer
  88105. * @param generateStencilBuffer True to generate a stencil buffer
  88106. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88107. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88108. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88109. */
  88110. constructor(name: string, size: number | {
  88111. width: number;
  88112. height: number;
  88113. } | {
  88114. ratio: number;
  88115. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88116. /**
  88117. * Creates a depth stencil texture.
  88118. * This is only available in WebGL 2 or with the depth texture extension available.
  88119. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88120. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88121. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88122. */
  88123. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88124. private _processSizeParameter;
  88125. /**
  88126. * Define the number of samples to use in case of MSAA.
  88127. * It defaults to one meaning no MSAA has been enabled.
  88128. */
  88129. samples: number;
  88130. /**
  88131. * Resets the refresh counter of the texture and start bak from scratch.
  88132. * Could be useful to regenerate the texture if it is setup to render only once.
  88133. */
  88134. resetRefreshCounter(): void;
  88135. /**
  88136. * Define the refresh rate of the texture or the rendering frequency.
  88137. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88138. */
  88139. refreshRate: number;
  88140. /**
  88141. * Adds a post process to the render target rendering passes.
  88142. * @param postProcess define the post process to add
  88143. */
  88144. addPostProcess(postProcess: PostProcess): void;
  88145. /**
  88146. * Clear all the post processes attached to the render target
  88147. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88148. */
  88149. clearPostProcesses(dispose?: boolean): void;
  88150. /**
  88151. * Remove one of the post process from the list of attached post processes to the texture
  88152. * @param postProcess define the post process to remove from the list
  88153. */
  88154. removePostProcess(postProcess: PostProcess): void;
  88155. /** @hidden */
  88156. _shouldRender(): boolean;
  88157. /**
  88158. * Gets the actual render size of the texture.
  88159. * @returns the width of the render size
  88160. */
  88161. getRenderSize(): number;
  88162. /**
  88163. * Gets the actual render width of the texture.
  88164. * @returns the width of the render size
  88165. */
  88166. getRenderWidth(): number;
  88167. /**
  88168. * Gets the actual render height of the texture.
  88169. * @returns the height of the render size
  88170. */
  88171. getRenderHeight(): number;
  88172. /**
  88173. * Get if the texture can be rescaled or not.
  88174. */
  88175. readonly canRescale: boolean;
  88176. /**
  88177. * Resize the texture using a ratio.
  88178. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88179. */
  88180. scale(ratio: number): void;
  88181. /**
  88182. * Get the texture reflection matrix used to rotate/transform the reflection.
  88183. * @returns the reflection matrix
  88184. */
  88185. getReflectionTextureMatrix(): Matrix;
  88186. /**
  88187. * Resize the texture to a new desired size.
  88188. * Be carrefull as it will recreate all the data in the new texture.
  88189. * @param size Define the new size. It can be:
  88190. * - a number for squared texture,
  88191. * - an object containing { width: number, height: number }
  88192. * - or an object containing a ratio { ratio: number }
  88193. */
  88194. resize(size: number | {
  88195. width: number;
  88196. height: number;
  88197. } | {
  88198. ratio: number;
  88199. }): void;
  88200. /**
  88201. * Renders all the objects from the render list into the texture.
  88202. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88203. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88204. */
  88205. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88206. private _bestReflectionRenderTargetDimension;
  88207. /**
  88208. * @hidden
  88209. * @param faceIndex face index to bind to if this is a cubetexture
  88210. */
  88211. _bindFrameBuffer(faceIndex?: number): void;
  88212. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88213. private renderToTarget;
  88214. /**
  88215. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88216. * This allowed control for front to back rendering or reversly depending of the special needs.
  88217. *
  88218. * @param renderingGroupId The rendering group id corresponding to its index
  88219. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88220. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88221. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88222. */
  88223. 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;
  88224. /**
  88225. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88226. *
  88227. * @param renderingGroupId The rendering group id corresponding to its index
  88228. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88229. */
  88230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88231. /**
  88232. * Clones the texture.
  88233. * @returns the cloned texture
  88234. */
  88235. clone(): RenderTargetTexture;
  88236. /**
  88237. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88238. * @returns The JSON representation of the texture
  88239. */
  88240. serialize(): any;
  88241. /**
  88242. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88243. */
  88244. disposeFramebufferObjects(): void;
  88245. /**
  88246. * Dispose the texture and release its associated resources.
  88247. */
  88248. dispose(): void;
  88249. /** @hidden */
  88250. _rebuild(): void;
  88251. /**
  88252. * Clear the info related to rendering groups preventing retention point in material dispose.
  88253. */
  88254. freeRenderingGroups(): void;
  88255. /**
  88256. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88257. * @returns the view count
  88258. */
  88259. getViewCount(): number;
  88260. }
  88261. }
  88262. declare module BABYLON {
  88263. /**
  88264. * Options for compiling materials.
  88265. */
  88266. export interface IMaterialCompilationOptions {
  88267. /**
  88268. * Defines whether clip planes are enabled.
  88269. */
  88270. clipPlane: boolean;
  88271. /**
  88272. * Defines whether instances are enabled.
  88273. */
  88274. useInstances: boolean;
  88275. }
  88276. /**
  88277. * Base class for the main features of a material in Babylon.js
  88278. */
  88279. export class Material implements IAnimatable {
  88280. /**
  88281. * Returns the triangle fill mode
  88282. */
  88283. static readonly TriangleFillMode: number;
  88284. /**
  88285. * Returns the wireframe mode
  88286. */
  88287. static readonly WireFrameFillMode: number;
  88288. /**
  88289. * Returns the point fill mode
  88290. */
  88291. static readonly PointFillMode: number;
  88292. /**
  88293. * Returns the point list draw mode
  88294. */
  88295. static readonly PointListDrawMode: number;
  88296. /**
  88297. * Returns the line list draw mode
  88298. */
  88299. static readonly LineListDrawMode: number;
  88300. /**
  88301. * Returns the line loop draw mode
  88302. */
  88303. static readonly LineLoopDrawMode: number;
  88304. /**
  88305. * Returns the line strip draw mode
  88306. */
  88307. static readonly LineStripDrawMode: number;
  88308. /**
  88309. * Returns the triangle strip draw mode
  88310. */
  88311. static readonly TriangleStripDrawMode: number;
  88312. /**
  88313. * Returns the triangle fan draw mode
  88314. */
  88315. static readonly TriangleFanDrawMode: number;
  88316. /**
  88317. * Stores the clock-wise side orientation
  88318. */
  88319. static readonly ClockWiseSideOrientation: number;
  88320. /**
  88321. * Stores the counter clock-wise side orientation
  88322. */
  88323. static readonly CounterClockWiseSideOrientation: number;
  88324. /**
  88325. * The dirty texture flag value
  88326. */
  88327. static readonly TextureDirtyFlag: number;
  88328. /**
  88329. * The dirty light flag value
  88330. */
  88331. static readonly LightDirtyFlag: number;
  88332. /**
  88333. * The dirty fresnel flag value
  88334. */
  88335. static readonly FresnelDirtyFlag: number;
  88336. /**
  88337. * The dirty attribute flag value
  88338. */
  88339. static readonly AttributesDirtyFlag: number;
  88340. /**
  88341. * The dirty misc flag value
  88342. */
  88343. static readonly MiscDirtyFlag: number;
  88344. /**
  88345. * The all dirty flag value
  88346. */
  88347. static readonly AllDirtyFlag: number;
  88348. /**
  88349. * The ID of the material
  88350. */
  88351. id: string;
  88352. /**
  88353. * Gets or sets the unique id of the material
  88354. */
  88355. uniqueId: number;
  88356. /**
  88357. * The name of the material
  88358. */
  88359. name: string;
  88360. /**
  88361. * Gets or sets user defined metadata
  88362. */
  88363. metadata: any;
  88364. /**
  88365. * For internal use only. Please do not use.
  88366. */
  88367. reservedDataStore: any;
  88368. /**
  88369. * Specifies if the ready state should be checked on each call
  88370. */
  88371. checkReadyOnEveryCall: boolean;
  88372. /**
  88373. * Specifies if the ready state should be checked once
  88374. */
  88375. checkReadyOnlyOnce: boolean;
  88376. /**
  88377. * The state of the material
  88378. */
  88379. state: string;
  88380. /**
  88381. * The alpha value of the material
  88382. */
  88383. protected _alpha: number;
  88384. /**
  88385. * List of inspectable custom properties (used by the Inspector)
  88386. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88387. */
  88388. inspectableCustomProperties: IInspectable[];
  88389. /**
  88390. * Sets the alpha value of the material
  88391. */
  88392. /**
  88393. * Gets the alpha value of the material
  88394. */
  88395. alpha: number;
  88396. /**
  88397. * Specifies if back face culling is enabled
  88398. */
  88399. protected _backFaceCulling: boolean;
  88400. /**
  88401. * Sets the back-face culling state
  88402. */
  88403. /**
  88404. * Gets the back-face culling state
  88405. */
  88406. backFaceCulling: boolean;
  88407. /**
  88408. * Stores the value for side orientation
  88409. */
  88410. sideOrientation: number;
  88411. /**
  88412. * Callback triggered when the material is compiled
  88413. */
  88414. onCompiled: Nullable<(effect: Effect) => void>;
  88415. /**
  88416. * Callback triggered when an error occurs
  88417. */
  88418. onError: Nullable<(effect: Effect, errors: string) => void>;
  88419. /**
  88420. * Callback triggered to get the render target textures
  88421. */
  88422. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88423. /**
  88424. * Gets a boolean indicating that current material needs to register RTT
  88425. */
  88426. readonly hasRenderTargetTextures: boolean;
  88427. /**
  88428. * Specifies if the material should be serialized
  88429. */
  88430. doNotSerialize: boolean;
  88431. /**
  88432. * @hidden
  88433. */
  88434. _storeEffectOnSubMeshes: boolean;
  88435. /**
  88436. * Stores the animations for the material
  88437. */
  88438. animations: Nullable<Array<Animation>>;
  88439. /**
  88440. * An event triggered when the material is disposed
  88441. */
  88442. onDisposeObservable: Observable<Material>;
  88443. /**
  88444. * An observer which watches for dispose events
  88445. */
  88446. private _onDisposeObserver;
  88447. private _onUnBindObservable;
  88448. /**
  88449. * Called during a dispose event
  88450. */
  88451. onDispose: () => void;
  88452. private _onBindObservable;
  88453. /**
  88454. * An event triggered when the material is bound
  88455. */
  88456. readonly onBindObservable: Observable<AbstractMesh>;
  88457. /**
  88458. * An observer which watches for bind events
  88459. */
  88460. private _onBindObserver;
  88461. /**
  88462. * Called during a bind event
  88463. */
  88464. onBind: (Mesh: AbstractMesh) => void;
  88465. /**
  88466. * An event triggered when the material is unbound
  88467. */
  88468. readonly onUnBindObservable: Observable<Material>;
  88469. /**
  88470. * Stores the value of the alpha mode
  88471. */
  88472. private _alphaMode;
  88473. /**
  88474. * Sets the value of the alpha mode.
  88475. *
  88476. * | Value | Type | Description |
  88477. * | --- | --- | --- |
  88478. * | 0 | ALPHA_DISABLE | |
  88479. * | 1 | ALPHA_ADD | |
  88480. * | 2 | ALPHA_COMBINE | |
  88481. * | 3 | ALPHA_SUBTRACT | |
  88482. * | 4 | ALPHA_MULTIPLY | |
  88483. * | 5 | ALPHA_MAXIMIZED | |
  88484. * | 6 | ALPHA_ONEONE | |
  88485. * | 7 | ALPHA_PREMULTIPLIED | |
  88486. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88487. * | 9 | ALPHA_INTERPOLATE | |
  88488. * | 10 | ALPHA_SCREENMODE | |
  88489. *
  88490. */
  88491. /**
  88492. * Gets the value of the alpha mode
  88493. */
  88494. alphaMode: number;
  88495. /**
  88496. * Stores the state of the need depth pre-pass value
  88497. */
  88498. private _needDepthPrePass;
  88499. /**
  88500. * Sets the need depth pre-pass value
  88501. */
  88502. /**
  88503. * Gets the depth pre-pass value
  88504. */
  88505. needDepthPrePass: boolean;
  88506. /**
  88507. * Specifies if depth writing should be disabled
  88508. */
  88509. disableDepthWrite: boolean;
  88510. /**
  88511. * Specifies if depth writing should be forced
  88512. */
  88513. forceDepthWrite: boolean;
  88514. /**
  88515. * Specifies if there should be a separate pass for culling
  88516. */
  88517. separateCullingPass: boolean;
  88518. /**
  88519. * Stores the state specifing if fog should be enabled
  88520. */
  88521. private _fogEnabled;
  88522. /**
  88523. * Sets the state for enabling fog
  88524. */
  88525. /**
  88526. * Gets the value of the fog enabled state
  88527. */
  88528. fogEnabled: boolean;
  88529. /**
  88530. * Stores the size of points
  88531. */
  88532. pointSize: number;
  88533. /**
  88534. * Stores the z offset value
  88535. */
  88536. zOffset: number;
  88537. /**
  88538. * Gets a value specifying if wireframe mode is enabled
  88539. */
  88540. /**
  88541. * Sets the state of wireframe mode
  88542. */
  88543. wireframe: boolean;
  88544. /**
  88545. * Gets the value specifying if point clouds are enabled
  88546. */
  88547. /**
  88548. * Sets the state of point cloud mode
  88549. */
  88550. pointsCloud: boolean;
  88551. /**
  88552. * Gets the material fill mode
  88553. */
  88554. /**
  88555. * Sets the material fill mode
  88556. */
  88557. fillMode: number;
  88558. /**
  88559. * @hidden
  88560. * Stores the effects for the material
  88561. */
  88562. _effect: Nullable<Effect>;
  88563. /**
  88564. * @hidden
  88565. * Specifies if the material was previously ready
  88566. */
  88567. _wasPreviouslyReady: boolean;
  88568. /**
  88569. * Specifies if uniform buffers should be used
  88570. */
  88571. private _useUBO;
  88572. /**
  88573. * Stores a reference to the scene
  88574. */
  88575. private _scene;
  88576. /**
  88577. * Stores the fill mode state
  88578. */
  88579. private _fillMode;
  88580. /**
  88581. * Specifies if the depth write state should be cached
  88582. */
  88583. private _cachedDepthWriteState;
  88584. /**
  88585. * Stores the uniform buffer
  88586. */
  88587. protected _uniformBuffer: UniformBuffer;
  88588. /** @hidden */
  88589. _indexInSceneMaterialArray: number;
  88590. /** @hidden */
  88591. meshMap: Nullable<{
  88592. [id: string]: AbstractMesh | undefined;
  88593. }>;
  88594. /**
  88595. * Creates a material instance
  88596. * @param name defines the name of the material
  88597. * @param scene defines the scene to reference
  88598. * @param doNotAdd specifies if the material should be added to the scene
  88599. */
  88600. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88601. /**
  88602. * Returns a string representation of the current material
  88603. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88604. * @returns a string with material information
  88605. */
  88606. toString(fullDetails?: boolean): string;
  88607. /**
  88608. * Gets the class name of the material
  88609. * @returns a string with the class name of the material
  88610. */
  88611. getClassName(): string;
  88612. /**
  88613. * Specifies if updates for the material been locked
  88614. */
  88615. readonly isFrozen: boolean;
  88616. /**
  88617. * Locks updates for the material
  88618. */
  88619. freeze(): void;
  88620. /**
  88621. * Unlocks updates for the material
  88622. */
  88623. unfreeze(): void;
  88624. /**
  88625. * Specifies if the material is ready to be used
  88626. * @param mesh defines the mesh to check
  88627. * @param useInstances specifies if instances should be used
  88628. * @returns a boolean indicating if the material is ready to be used
  88629. */
  88630. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88631. /**
  88632. * Specifies that the submesh is ready to be used
  88633. * @param mesh defines the mesh to check
  88634. * @param subMesh defines which submesh to check
  88635. * @param useInstances specifies that instances should be used
  88636. * @returns a boolean indicating that the submesh is ready or not
  88637. */
  88638. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88639. /**
  88640. * Returns the material effect
  88641. * @returns the effect associated with the material
  88642. */
  88643. getEffect(): Nullable<Effect>;
  88644. /**
  88645. * Returns the current scene
  88646. * @returns a Scene
  88647. */
  88648. getScene(): Scene;
  88649. /**
  88650. * Specifies if the material will require alpha blending
  88651. * @returns a boolean specifying if alpha blending is needed
  88652. */
  88653. needAlphaBlending(): boolean;
  88654. /**
  88655. * Specifies if the mesh will require alpha blending
  88656. * @param mesh defines the mesh to check
  88657. * @returns a boolean specifying if alpha blending is needed for the mesh
  88658. */
  88659. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88660. /**
  88661. * Specifies if this material should be rendered in alpha test mode
  88662. * @returns a boolean specifying if an alpha test is needed.
  88663. */
  88664. needAlphaTesting(): boolean;
  88665. /**
  88666. * Gets the texture used for the alpha test
  88667. * @returns the texture to use for alpha testing
  88668. */
  88669. getAlphaTestTexture(): Nullable<BaseTexture>;
  88670. /**
  88671. * Marks the material to indicate that it needs to be re-calculated
  88672. */
  88673. markDirty(): void;
  88674. /** @hidden */
  88675. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88676. /**
  88677. * Binds the material to the mesh
  88678. * @param world defines the world transformation matrix
  88679. * @param mesh defines the mesh to bind the material to
  88680. */
  88681. bind(world: Matrix, mesh?: Mesh): void;
  88682. /**
  88683. * Binds the submesh to the material
  88684. * @param world defines the world transformation matrix
  88685. * @param mesh defines the mesh containing the submesh
  88686. * @param subMesh defines the submesh to bind the material to
  88687. */
  88688. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88689. /**
  88690. * Binds the world matrix to the material
  88691. * @param world defines the world transformation matrix
  88692. */
  88693. bindOnlyWorldMatrix(world: Matrix): void;
  88694. /**
  88695. * Binds the scene's uniform buffer to the effect.
  88696. * @param effect defines the effect to bind to the scene uniform buffer
  88697. * @param sceneUbo defines the uniform buffer storing scene data
  88698. */
  88699. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88700. /**
  88701. * Binds the view matrix to the effect
  88702. * @param effect defines the effect to bind the view matrix to
  88703. */
  88704. bindView(effect: Effect): void;
  88705. /**
  88706. * Binds the view projection matrix to the effect
  88707. * @param effect defines the effect to bind the view projection matrix to
  88708. */
  88709. bindViewProjection(effect: Effect): void;
  88710. /**
  88711. * Specifies if material alpha testing should be turned on for the mesh
  88712. * @param mesh defines the mesh to check
  88713. */
  88714. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88715. /**
  88716. * Processes to execute after binding the material to a mesh
  88717. * @param mesh defines the rendered mesh
  88718. */
  88719. protected _afterBind(mesh?: Mesh): void;
  88720. /**
  88721. * Unbinds the material from the mesh
  88722. */
  88723. unbind(): void;
  88724. /**
  88725. * Gets the active textures from the material
  88726. * @returns an array of textures
  88727. */
  88728. getActiveTextures(): BaseTexture[];
  88729. /**
  88730. * Specifies if the material uses a texture
  88731. * @param texture defines the texture to check against the material
  88732. * @returns a boolean specifying if the material uses the texture
  88733. */
  88734. hasTexture(texture: BaseTexture): boolean;
  88735. /**
  88736. * Makes a duplicate of the material, and gives it a new name
  88737. * @param name defines the new name for the duplicated material
  88738. * @returns the cloned material
  88739. */
  88740. clone(name: string): Nullable<Material>;
  88741. /**
  88742. * Gets the meshes bound to the material
  88743. * @returns an array of meshes bound to the material
  88744. */
  88745. getBindedMeshes(): AbstractMesh[];
  88746. /**
  88747. * Force shader compilation
  88748. * @param mesh defines the mesh associated with this material
  88749. * @param onCompiled defines a function to execute once the material is compiled
  88750. * @param options defines the options to configure the compilation
  88751. * @param onError defines a function to execute if the material fails compiling
  88752. */
  88753. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88754. /**
  88755. * Force shader compilation
  88756. * @param mesh defines the mesh that will use this material
  88757. * @param options defines additional options for compiling the shaders
  88758. * @returns a promise that resolves when the compilation completes
  88759. */
  88760. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88761. private static readonly _AllDirtyCallBack;
  88762. private static readonly _ImageProcessingDirtyCallBack;
  88763. private static readonly _TextureDirtyCallBack;
  88764. private static readonly _FresnelDirtyCallBack;
  88765. private static readonly _MiscDirtyCallBack;
  88766. private static readonly _LightsDirtyCallBack;
  88767. private static readonly _AttributeDirtyCallBack;
  88768. private static _FresnelAndMiscDirtyCallBack;
  88769. private static _TextureAndMiscDirtyCallBack;
  88770. private static readonly _DirtyCallbackArray;
  88771. private static readonly _RunDirtyCallBacks;
  88772. /**
  88773. * Marks a define in the material to indicate that it needs to be re-computed
  88774. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88775. */
  88776. markAsDirty(flag: number): void;
  88777. /**
  88778. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88779. * @param func defines a function which checks material defines against the submeshes
  88780. */
  88781. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88782. /**
  88783. * Indicates that we need to re-calculated for all submeshes
  88784. */
  88785. protected _markAllSubMeshesAsAllDirty(): void;
  88786. /**
  88787. * Indicates that image processing needs to be re-calculated for all submeshes
  88788. */
  88789. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88790. /**
  88791. * Indicates that textures need to be re-calculated for all submeshes
  88792. */
  88793. protected _markAllSubMeshesAsTexturesDirty(): void;
  88794. /**
  88795. * Indicates that fresnel needs to be re-calculated for all submeshes
  88796. */
  88797. protected _markAllSubMeshesAsFresnelDirty(): void;
  88798. /**
  88799. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88800. */
  88801. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88802. /**
  88803. * Indicates that lights need to be re-calculated for all submeshes
  88804. */
  88805. protected _markAllSubMeshesAsLightsDirty(): void;
  88806. /**
  88807. * Indicates that attributes need to be re-calculated for all submeshes
  88808. */
  88809. protected _markAllSubMeshesAsAttributesDirty(): void;
  88810. /**
  88811. * Indicates that misc needs to be re-calculated for all submeshes
  88812. */
  88813. protected _markAllSubMeshesAsMiscDirty(): void;
  88814. /**
  88815. * Indicates that textures and misc need to be re-calculated for all submeshes
  88816. */
  88817. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88818. /**
  88819. * Disposes the material
  88820. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88821. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88822. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88823. */
  88824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88825. /** @hidden */
  88826. private releaseVertexArrayObject;
  88827. /**
  88828. * Serializes this material
  88829. * @returns the serialized material object
  88830. */
  88831. serialize(): any;
  88832. /**
  88833. * Creates a material from parsed material data
  88834. * @param parsedMaterial defines parsed material data
  88835. * @param scene defines the hosting scene
  88836. * @param rootUrl defines the root URL to use to load textures
  88837. * @returns a new material
  88838. */
  88839. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88840. }
  88841. }
  88842. declare module BABYLON {
  88843. /**
  88844. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88845. * separate meshes. This can be use to improve performances.
  88846. * @see http://doc.babylonjs.com/how_to/multi_materials
  88847. */
  88848. export class MultiMaterial extends Material {
  88849. private _subMaterials;
  88850. /**
  88851. * Gets or Sets the list of Materials used within the multi material.
  88852. * They need to be ordered according to the submeshes order in the associated mesh
  88853. */
  88854. subMaterials: Nullable<Material>[];
  88855. /**
  88856. * Function used to align with Node.getChildren()
  88857. * @returns the list of Materials used within the multi material
  88858. */
  88859. getChildren(): Nullable<Material>[];
  88860. /**
  88861. * Instantiates a new Multi Material
  88862. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88863. * separate meshes. This can be use to improve performances.
  88864. * @see http://doc.babylonjs.com/how_to/multi_materials
  88865. * @param name Define the name in the scene
  88866. * @param scene Define the scene the material belongs to
  88867. */
  88868. constructor(name: string, scene: Scene);
  88869. private _hookArray;
  88870. /**
  88871. * Get one of the submaterial by its index in the submaterials array
  88872. * @param index The index to look the sub material at
  88873. * @returns The Material if the index has been defined
  88874. */
  88875. getSubMaterial(index: number): Nullable<Material>;
  88876. /**
  88877. * Get the list of active textures for the whole sub materials list.
  88878. * @returns All the textures that will be used during the rendering
  88879. */
  88880. getActiveTextures(): BaseTexture[];
  88881. /**
  88882. * Gets the current class name of the material e.g. "MultiMaterial"
  88883. * Mainly use in serialization.
  88884. * @returns the class name
  88885. */
  88886. getClassName(): string;
  88887. /**
  88888. * Checks if the material is ready to render the requested sub mesh
  88889. * @param mesh Define the mesh the submesh belongs to
  88890. * @param subMesh Define the sub mesh to look readyness for
  88891. * @param useInstances Define whether or not the material is used with instances
  88892. * @returns true if ready, otherwise false
  88893. */
  88894. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88895. /**
  88896. * Clones the current material and its related sub materials
  88897. * @param name Define the name of the newly cloned material
  88898. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88899. * @returns the cloned material
  88900. */
  88901. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88902. /**
  88903. * Serializes the materials into a JSON representation.
  88904. * @returns the JSON representation
  88905. */
  88906. serialize(): any;
  88907. /**
  88908. * Dispose the material and release its associated resources
  88909. * @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)
  88910. * @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)
  88911. * @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)
  88912. */
  88913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88914. /**
  88915. * Creates a MultiMaterial from parsed MultiMaterial data.
  88916. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88917. * @param scene defines the hosting scene
  88918. * @returns a new MultiMaterial
  88919. */
  88920. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88921. }
  88922. }
  88923. declare module BABYLON {
  88924. /**
  88925. * Base class for submeshes
  88926. */
  88927. export class BaseSubMesh {
  88928. /** @hidden */
  88929. _materialDefines: Nullable<MaterialDefines>;
  88930. /** @hidden */
  88931. _materialEffect: Nullable<Effect>;
  88932. /**
  88933. * Gets associated effect
  88934. */
  88935. readonly effect: Nullable<Effect>;
  88936. /**
  88937. * Sets associated effect (effect used to render this submesh)
  88938. * @param effect defines the effect to associate with
  88939. * @param defines defines the set of defines used to compile this effect
  88940. */
  88941. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88942. }
  88943. /**
  88944. * Defines a subdivision inside a mesh
  88945. */
  88946. export class SubMesh extends BaseSubMesh implements ICullable {
  88947. /** the material index to use */
  88948. materialIndex: number;
  88949. /** vertex index start */
  88950. verticesStart: number;
  88951. /** vertices count */
  88952. verticesCount: number;
  88953. /** index start */
  88954. indexStart: number;
  88955. /** indices count */
  88956. indexCount: number;
  88957. /** @hidden */
  88958. _linesIndexCount: number;
  88959. private _mesh;
  88960. private _renderingMesh;
  88961. private _boundingInfo;
  88962. private _linesIndexBuffer;
  88963. /** @hidden */
  88964. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88965. /** @hidden */
  88966. _trianglePlanes: Plane[];
  88967. /** @hidden */
  88968. _lastColliderTransformMatrix: Nullable<Matrix>;
  88969. /** @hidden */
  88970. _renderId: number;
  88971. /** @hidden */
  88972. _alphaIndex: number;
  88973. /** @hidden */
  88974. _distanceToCamera: number;
  88975. /** @hidden */
  88976. _id: number;
  88977. private _currentMaterial;
  88978. /**
  88979. * Add a new submesh to a mesh
  88980. * @param materialIndex defines the material index to use
  88981. * @param verticesStart defines vertex index start
  88982. * @param verticesCount defines vertices count
  88983. * @param indexStart defines index start
  88984. * @param indexCount defines indices count
  88985. * @param mesh defines the parent mesh
  88986. * @param renderingMesh defines an optional rendering mesh
  88987. * @param createBoundingBox defines if bounding box should be created for this submesh
  88988. * @returns the new submesh
  88989. */
  88990. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88991. /**
  88992. * Creates a new submesh
  88993. * @param materialIndex defines the material index to use
  88994. * @param verticesStart defines vertex index start
  88995. * @param verticesCount defines vertices count
  88996. * @param indexStart defines index start
  88997. * @param indexCount defines indices count
  88998. * @param mesh defines the parent mesh
  88999. * @param renderingMesh defines an optional rendering mesh
  89000. * @param createBoundingBox defines if bounding box should be created for this submesh
  89001. */
  89002. constructor(
  89003. /** the material index to use */
  89004. materialIndex: number,
  89005. /** vertex index start */
  89006. verticesStart: number,
  89007. /** vertices count */
  89008. verticesCount: number,
  89009. /** index start */
  89010. indexStart: number,
  89011. /** indices count */
  89012. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89013. /**
  89014. * Returns true if this submesh covers the entire parent mesh
  89015. * @ignorenaming
  89016. */
  89017. readonly IsGlobal: boolean;
  89018. /**
  89019. * Returns the submesh BoudingInfo object
  89020. * @returns current bounding info (or mesh's one if the submesh is global)
  89021. */
  89022. getBoundingInfo(): BoundingInfo;
  89023. /**
  89024. * Sets the submesh BoundingInfo
  89025. * @param boundingInfo defines the new bounding info to use
  89026. * @returns the SubMesh
  89027. */
  89028. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89029. /**
  89030. * Returns the mesh of the current submesh
  89031. * @return the parent mesh
  89032. */
  89033. getMesh(): AbstractMesh;
  89034. /**
  89035. * Returns the rendering mesh of the submesh
  89036. * @returns the rendering mesh (could be different from parent mesh)
  89037. */
  89038. getRenderingMesh(): Mesh;
  89039. /**
  89040. * Returns the submesh material
  89041. * @returns null or the current material
  89042. */
  89043. getMaterial(): Nullable<Material>;
  89044. /**
  89045. * Sets a new updated BoundingInfo object to the submesh
  89046. * @param data defines an optional position array to use to determine the bounding info
  89047. * @returns the SubMesh
  89048. */
  89049. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89050. /** @hidden */
  89051. _checkCollision(collider: Collider): boolean;
  89052. /**
  89053. * Updates the submesh BoundingInfo
  89054. * @param world defines the world matrix to use to update the bounding info
  89055. * @returns the submesh
  89056. */
  89057. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89058. /**
  89059. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89060. * @param frustumPlanes defines the frustum planes
  89061. * @returns true if the submesh is intersecting with the frustum
  89062. */
  89063. isInFrustum(frustumPlanes: Plane[]): boolean;
  89064. /**
  89065. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89066. * @param frustumPlanes defines the frustum planes
  89067. * @returns true if the submesh is inside the frustum
  89068. */
  89069. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89070. /**
  89071. * Renders the submesh
  89072. * @param enableAlphaMode defines if alpha needs to be used
  89073. * @returns the submesh
  89074. */
  89075. render(enableAlphaMode: boolean): SubMesh;
  89076. /**
  89077. * @hidden
  89078. */
  89079. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89080. /**
  89081. * Checks if the submesh intersects with a ray
  89082. * @param ray defines the ray to test
  89083. * @returns true is the passed ray intersects the submesh bounding box
  89084. */
  89085. canIntersects(ray: Ray): boolean;
  89086. /**
  89087. * Intersects current submesh with a ray
  89088. * @param ray defines the ray to test
  89089. * @param positions defines mesh's positions array
  89090. * @param indices defines mesh's indices array
  89091. * @param fastCheck defines if only bounding info should be used
  89092. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89093. * @returns intersection info or null if no intersection
  89094. */
  89095. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89096. /** @hidden */
  89097. private _intersectLines;
  89098. /** @hidden */
  89099. private _intersectUnIndexedLines;
  89100. /** @hidden */
  89101. private _intersectTriangles;
  89102. /** @hidden */
  89103. private _intersectUnIndexedTriangles;
  89104. /** @hidden */
  89105. _rebuild(): void;
  89106. /**
  89107. * Creates a new submesh from the passed mesh
  89108. * @param newMesh defines the new hosting mesh
  89109. * @param newRenderingMesh defines an optional rendering mesh
  89110. * @returns the new submesh
  89111. */
  89112. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89113. /**
  89114. * Release associated resources
  89115. */
  89116. dispose(): void;
  89117. /**
  89118. * Gets the class name
  89119. * @returns the string "SubMesh".
  89120. */
  89121. getClassName(): string;
  89122. /**
  89123. * Creates a new submesh from indices data
  89124. * @param materialIndex the index of the main mesh material
  89125. * @param startIndex the index where to start the copy in the mesh indices array
  89126. * @param indexCount the number of indices to copy then from the startIndex
  89127. * @param mesh the main mesh to create the submesh from
  89128. * @param renderingMesh the optional rendering mesh
  89129. * @returns a new submesh
  89130. */
  89131. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89132. }
  89133. }
  89134. declare module BABYLON {
  89135. /**
  89136. * Class used to represent data loading progression
  89137. */
  89138. export class SceneLoaderFlags {
  89139. private static _ForceFullSceneLoadingForIncremental;
  89140. private static _ShowLoadingScreen;
  89141. private static _CleanBoneMatrixWeights;
  89142. private static _loggingLevel;
  89143. /**
  89144. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89145. */
  89146. static ForceFullSceneLoadingForIncremental: boolean;
  89147. /**
  89148. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89149. */
  89150. static ShowLoadingScreen: boolean;
  89151. /**
  89152. * Defines the current logging level (while loading the scene)
  89153. * @ignorenaming
  89154. */
  89155. static loggingLevel: number;
  89156. /**
  89157. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89158. */
  89159. static CleanBoneMatrixWeights: boolean;
  89160. }
  89161. }
  89162. declare module BABYLON {
  89163. /**
  89164. * Class used to store geometry data (vertex buffers + index buffer)
  89165. */
  89166. export class Geometry implements IGetSetVerticesData {
  89167. /**
  89168. * Gets or sets the ID of the geometry
  89169. */
  89170. id: string;
  89171. /**
  89172. * Gets or sets the unique ID of the geometry
  89173. */
  89174. uniqueId: number;
  89175. /**
  89176. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89177. */
  89178. delayLoadState: number;
  89179. /**
  89180. * Gets the file containing the data to load when running in delay load state
  89181. */
  89182. delayLoadingFile: Nullable<string>;
  89183. /**
  89184. * Callback called when the geometry is updated
  89185. */
  89186. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89187. private _scene;
  89188. private _engine;
  89189. private _meshes;
  89190. private _totalVertices;
  89191. /** @hidden */
  89192. _indices: IndicesArray;
  89193. /** @hidden */
  89194. _vertexBuffers: {
  89195. [key: string]: VertexBuffer;
  89196. };
  89197. private _isDisposed;
  89198. private _extend;
  89199. private _boundingBias;
  89200. /** @hidden */
  89201. _delayInfo: Array<string>;
  89202. private _indexBuffer;
  89203. private _indexBufferIsUpdatable;
  89204. /** @hidden */
  89205. _boundingInfo: Nullable<BoundingInfo>;
  89206. /** @hidden */
  89207. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89208. /** @hidden */
  89209. _softwareSkinningFrameId: number;
  89210. private _vertexArrayObjects;
  89211. private _updatable;
  89212. /** @hidden */
  89213. _positions: Nullable<Vector3[]>;
  89214. /**
  89215. * 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
  89216. */
  89217. /**
  89218. * 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
  89219. */
  89220. boundingBias: Vector2;
  89221. /**
  89222. * Static function used to attach a new empty geometry to a mesh
  89223. * @param mesh defines the mesh to attach the geometry to
  89224. * @returns the new Geometry
  89225. */
  89226. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89227. /**
  89228. * Creates a new geometry
  89229. * @param id defines the unique ID
  89230. * @param scene defines the hosting scene
  89231. * @param vertexData defines the VertexData used to get geometry data
  89232. * @param updatable defines if geometry must be updatable (false by default)
  89233. * @param mesh defines the mesh that will be associated with the geometry
  89234. */
  89235. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89236. /**
  89237. * Gets the current extend of the geometry
  89238. */
  89239. readonly extend: {
  89240. minimum: Vector3;
  89241. maximum: Vector3;
  89242. };
  89243. /**
  89244. * Gets the hosting scene
  89245. * @returns the hosting Scene
  89246. */
  89247. getScene(): Scene;
  89248. /**
  89249. * Gets the hosting engine
  89250. * @returns the hosting Engine
  89251. */
  89252. getEngine(): Engine;
  89253. /**
  89254. * Defines if the geometry is ready to use
  89255. * @returns true if the geometry is ready to be used
  89256. */
  89257. isReady(): boolean;
  89258. /**
  89259. * Gets a value indicating that the geometry should not be serialized
  89260. */
  89261. readonly doNotSerialize: boolean;
  89262. /** @hidden */
  89263. _rebuild(): void;
  89264. /**
  89265. * Affects all geometry data in one call
  89266. * @param vertexData defines the geometry data
  89267. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89268. */
  89269. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89270. /**
  89271. * Set specific vertex data
  89272. * @param kind defines the data kind (Position, normal, etc...)
  89273. * @param data defines the vertex data to use
  89274. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89275. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89276. */
  89277. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89278. /**
  89279. * Removes a specific vertex data
  89280. * @param kind defines the data kind (Position, normal, etc...)
  89281. */
  89282. removeVerticesData(kind: string): void;
  89283. /**
  89284. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89285. * @param buffer defines the vertex buffer to use
  89286. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89287. */
  89288. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89289. /**
  89290. * Update a specific vertex buffer
  89291. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89292. * It will do nothing if the buffer is not updatable
  89293. * @param kind defines the data kind (Position, normal, etc...)
  89294. * @param data defines the data to use
  89295. * @param offset defines the offset in the target buffer where to store the data
  89296. * @param useBytes set to true if the offset is in bytes
  89297. */
  89298. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89299. /**
  89300. * Update a specific vertex buffer
  89301. * This function will create a new buffer if the current one is not updatable
  89302. * @param kind defines the data kind (Position, normal, etc...)
  89303. * @param data defines the data to use
  89304. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89305. */
  89306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89307. private _updateBoundingInfo;
  89308. /** @hidden */
  89309. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89310. /**
  89311. * Gets total number of vertices
  89312. * @returns the total number of vertices
  89313. */
  89314. getTotalVertices(): number;
  89315. /**
  89316. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89317. * @param kind defines the data kind (Position, normal, etc...)
  89318. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89319. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89320. * @returns a float array containing vertex data
  89321. */
  89322. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89323. /**
  89324. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89325. * @param kind defines the data kind (Position, normal, etc...)
  89326. * @returns true if the vertex buffer with the specified kind is updatable
  89327. */
  89328. isVertexBufferUpdatable(kind: string): boolean;
  89329. /**
  89330. * Gets a specific vertex buffer
  89331. * @param kind defines the data kind (Position, normal, etc...)
  89332. * @returns a VertexBuffer
  89333. */
  89334. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89335. /**
  89336. * Returns all vertex buffers
  89337. * @return an object holding all vertex buffers indexed by kind
  89338. */
  89339. getVertexBuffers(): Nullable<{
  89340. [key: string]: VertexBuffer;
  89341. }>;
  89342. /**
  89343. * Gets a boolean indicating if specific vertex buffer is present
  89344. * @param kind defines the data kind (Position, normal, etc...)
  89345. * @returns true if data is present
  89346. */
  89347. isVerticesDataPresent(kind: string): boolean;
  89348. /**
  89349. * Gets a list of all attached data kinds (Position, normal, etc...)
  89350. * @returns a list of string containing all kinds
  89351. */
  89352. getVerticesDataKinds(): string[];
  89353. /**
  89354. * Update index buffer
  89355. * @param indices defines the indices to store in the index buffer
  89356. * @param offset defines the offset in the target buffer where to store the data
  89357. * @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)
  89358. */
  89359. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89360. /**
  89361. * Creates a new index buffer
  89362. * @param indices defines the indices to store in the index buffer
  89363. * @param totalVertices defines the total number of vertices (could be null)
  89364. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89365. */
  89366. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89367. /**
  89368. * Return the total number of indices
  89369. * @returns the total number of indices
  89370. */
  89371. getTotalIndices(): number;
  89372. /**
  89373. * Gets the index buffer array
  89374. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89375. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89376. * @returns the index buffer array
  89377. */
  89378. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89379. /**
  89380. * Gets the index buffer
  89381. * @return the index buffer
  89382. */
  89383. getIndexBuffer(): Nullable<DataBuffer>;
  89384. /** @hidden */
  89385. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89386. /**
  89387. * Release the associated resources for a specific mesh
  89388. * @param mesh defines the source mesh
  89389. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89390. */
  89391. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89392. /**
  89393. * Apply current geometry to a given mesh
  89394. * @param mesh defines the mesh to apply geometry to
  89395. */
  89396. applyToMesh(mesh: Mesh): void;
  89397. private _updateExtend;
  89398. private _applyToMesh;
  89399. private notifyUpdate;
  89400. /**
  89401. * Load the geometry if it was flagged as delay loaded
  89402. * @param scene defines the hosting scene
  89403. * @param onLoaded defines a callback called when the geometry is loaded
  89404. */
  89405. load(scene: Scene, onLoaded?: () => void): void;
  89406. private _queueLoad;
  89407. /**
  89408. * Invert the geometry to move from a right handed system to a left handed one.
  89409. */
  89410. toLeftHanded(): void;
  89411. /** @hidden */
  89412. _resetPointsArrayCache(): void;
  89413. /** @hidden */
  89414. _generatePointsArray(): boolean;
  89415. /**
  89416. * Gets a value indicating if the geometry is disposed
  89417. * @returns true if the geometry was disposed
  89418. */
  89419. isDisposed(): boolean;
  89420. private _disposeVertexArrayObjects;
  89421. /**
  89422. * Free all associated resources
  89423. */
  89424. dispose(): void;
  89425. /**
  89426. * Clone the current geometry into a new geometry
  89427. * @param id defines the unique ID of the new geometry
  89428. * @returns a new geometry object
  89429. */
  89430. copy(id: string): Geometry;
  89431. /**
  89432. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89433. * @return a JSON representation of the current geometry data (without the vertices data)
  89434. */
  89435. serialize(): any;
  89436. private toNumberArray;
  89437. /**
  89438. * Serialize all vertices data into a JSON oject
  89439. * @returns a JSON representation of the current geometry data
  89440. */
  89441. serializeVerticeData(): any;
  89442. /**
  89443. * Extracts a clone of a mesh geometry
  89444. * @param mesh defines the source mesh
  89445. * @param id defines the unique ID of the new geometry object
  89446. * @returns the new geometry object
  89447. */
  89448. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89449. /**
  89450. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89451. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89452. * Be aware Math.random() could cause collisions, but:
  89453. * "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"
  89454. * @returns a string containing a new GUID
  89455. */
  89456. static RandomId(): string;
  89457. /** @hidden */
  89458. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89459. private static _CleanMatricesWeights;
  89460. /**
  89461. * Create a new geometry from persisted data (Using .babylon file format)
  89462. * @param parsedVertexData defines the persisted data
  89463. * @param scene defines the hosting scene
  89464. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89465. * @returns the new geometry object
  89466. */
  89467. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89468. }
  89469. }
  89470. declare module BABYLON {
  89471. /**
  89472. * Define an interface for all classes that will get and set the data on vertices
  89473. */
  89474. export interface IGetSetVerticesData {
  89475. /**
  89476. * Gets a boolean indicating if specific vertex data is present
  89477. * @param kind defines the vertex data kind to use
  89478. * @returns true is data kind is present
  89479. */
  89480. isVerticesDataPresent(kind: string): boolean;
  89481. /**
  89482. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89483. * @param kind defines the data kind (Position, normal, etc...)
  89484. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89485. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89486. * @returns a float array containing vertex data
  89487. */
  89488. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89489. /**
  89490. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89491. * @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.
  89492. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89493. * @returns the indices array or an empty array if the mesh has no geometry
  89494. */
  89495. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89496. /**
  89497. * Set specific vertex data
  89498. * @param kind defines the data kind (Position, normal, etc...)
  89499. * @param data defines the vertex data to use
  89500. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89501. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89502. */
  89503. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89504. /**
  89505. * Update a specific associated vertex buffer
  89506. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89507. * - VertexBuffer.PositionKind
  89508. * - VertexBuffer.UVKind
  89509. * - VertexBuffer.UV2Kind
  89510. * - VertexBuffer.UV3Kind
  89511. * - VertexBuffer.UV4Kind
  89512. * - VertexBuffer.UV5Kind
  89513. * - VertexBuffer.UV6Kind
  89514. * - VertexBuffer.ColorKind
  89515. * - VertexBuffer.MatricesIndicesKind
  89516. * - VertexBuffer.MatricesIndicesExtraKind
  89517. * - VertexBuffer.MatricesWeightsKind
  89518. * - VertexBuffer.MatricesWeightsExtraKind
  89519. * @param data defines the data source
  89520. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89521. * @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)
  89522. */
  89523. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89524. /**
  89525. * Creates a new index buffer
  89526. * @param indices defines the indices to store in the index buffer
  89527. * @param totalVertices defines the total number of vertices (could be null)
  89528. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89529. */
  89530. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89531. }
  89532. /**
  89533. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89534. */
  89535. export class VertexData {
  89536. /**
  89537. * Mesh side orientation : usually the external or front surface
  89538. */
  89539. static readonly FRONTSIDE: number;
  89540. /**
  89541. * Mesh side orientation : usually the internal or back surface
  89542. */
  89543. static readonly BACKSIDE: number;
  89544. /**
  89545. * Mesh side orientation : both internal and external or front and back surfaces
  89546. */
  89547. static readonly DOUBLESIDE: number;
  89548. /**
  89549. * Mesh side orientation : by default, `FRONTSIDE`
  89550. */
  89551. static readonly DEFAULTSIDE: number;
  89552. /**
  89553. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89554. */
  89555. positions: Nullable<FloatArray>;
  89556. /**
  89557. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89558. */
  89559. normals: Nullable<FloatArray>;
  89560. /**
  89561. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89562. */
  89563. tangents: Nullable<FloatArray>;
  89564. /**
  89565. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89566. */
  89567. uvs: Nullable<FloatArray>;
  89568. /**
  89569. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89570. */
  89571. uvs2: Nullable<FloatArray>;
  89572. /**
  89573. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89574. */
  89575. uvs3: Nullable<FloatArray>;
  89576. /**
  89577. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89578. */
  89579. uvs4: Nullable<FloatArray>;
  89580. /**
  89581. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89582. */
  89583. uvs5: Nullable<FloatArray>;
  89584. /**
  89585. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89586. */
  89587. uvs6: Nullable<FloatArray>;
  89588. /**
  89589. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89590. */
  89591. colors: Nullable<FloatArray>;
  89592. /**
  89593. * 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).
  89594. */
  89595. matricesIndices: Nullable<FloatArray>;
  89596. /**
  89597. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89598. */
  89599. matricesWeights: Nullable<FloatArray>;
  89600. /**
  89601. * An array extending the number of possible indices
  89602. */
  89603. matricesIndicesExtra: Nullable<FloatArray>;
  89604. /**
  89605. * An array extending the number of possible weights when the number of indices is extended
  89606. */
  89607. matricesWeightsExtra: Nullable<FloatArray>;
  89608. /**
  89609. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89610. */
  89611. indices: Nullable<IndicesArray>;
  89612. /**
  89613. * Uses the passed data array to set the set the values for the specified kind of data
  89614. * @param data a linear array of floating numbers
  89615. * @param kind the type of data that is being set, eg positions, colors etc
  89616. */
  89617. set(data: FloatArray, kind: string): void;
  89618. /**
  89619. * Associates the vertexData to the passed Mesh.
  89620. * Sets it as updatable or not (default `false`)
  89621. * @param mesh the mesh the vertexData is applied to
  89622. * @param updatable when used and having the value true allows new data to update the vertexData
  89623. * @returns the VertexData
  89624. */
  89625. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89626. /**
  89627. * Associates the vertexData to the passed Geometry.
  89628. * Sets it as updatable or not (default `false`)
  89629. * @param geometry the geometry the vertexData is applied to
  89630. * @param updatable when used and having the value true allows new data to update the vertexData
  89631. * @returns VertexData
  89632. */
  89633. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89634. /**
  89635. * Updates the associated mesh
  89636. * @param mesh the mesh to be updated
  89637. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89638. * @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
  89639. * @returns VertexData
  89640. */
  89641. updateMesh(mesh: Mesh): VertexData;
  89642. /**
  89643. * Updates the associated geometry
  89644. * @param geometry the geometry to be updated
  89645. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89646. * @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
  89647. * @returns VertexData.
  89648. */
  89649. updateGeometry(geometry: Geometry): VertexData;
  89650. private _applyTo;
  89651. private _update;
  89652. /**
  89653. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89654. * @param matrix the transforming matrix
  89655. * @returns the VertexData
  89656. */
  89657. transform(matrix: Matrix): VertexData;
  89658. /**
  89659. * Merges the passed VertexData into the current one
  89660. * @param other the VertexData to be merged into the current one
  89661. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89662. * @returns the modified VertexData
  89663. */
  89664. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89665. private _mergeElement;
  89666. private _validate;
  89667. /**
  89668. * Serializes the VertexData
  89669. * @returns a serialized object
  89670. */
  89671. serialize(): any;
  89672. /**
  89673. * Extracts the vertexData from a mesh
  89674. * @param mesh the mesh from which to extract the VertexData
  89675. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89676. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89677. * @returns the object VertexData associated to the passed mesh
  89678. */
  89679. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89680. /**
  89681. * Extracts the vertexData from the geometry
  89682. * @param geometry the geometry from which to extract the VertexData
  89683. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89684. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89685. * @returns the object VertexData associated to the passed mesh
  89686. */
  89687. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89688. private static _ExtractFrom;
  89689. /**
  89690. * Creates the VertexData for a Ribbon
  89691. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89692. * * pathArray array of paths, each of which an array of successive Vector3
  89693. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89694. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89695. * * 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
  89696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89697. * * 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)
  89698. * * 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)
  89699. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89700. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89701. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89702. * @returns the VertexData of the ribbon
  89703. */
  89704. static CreateRibbon(options: {
  89705. pathArray: Vector3[][];
  89706. closeArray?: boolean;
  89707. closePath?: boolean;
  89708. offset?: number;
  89709. sideOrientation?: number;
  89710. frontUVs?: Vector4;
  89711. backUVs?: Vector4;
  89712. invertUV?: boolean;
  89713. uvs?: Vector2[];
  89714. colors?: Color4[];
  89715. }): VertexData;
  89716. /**
  89717. * Creates the VertexData for a box
  89718. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89719. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89720. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89721. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89722. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89723. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89724. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89726. * * 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)
  89727. * * 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)
  89728. * @returns the VertexData of the box
  89729. */
  89730. static CreateBox(options: {
  89731. size?: number;
  89732. width?: number;
  89733. height?: number;
  89734. depth?: number;
  89735. faceUV?: Vector4[];
  89736. faceColors?: Color4[];
  89737. sideOrientation?: number;
  89738. frontUVs?: Vector4;
  89739. backUVs?: Vector4;
  89740. }): VertexData;
  89741. /**
  89742. * Creates the VertexData for a tiled box
  89743. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89744. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89745. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89746. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89748. * @returns the VertexData of the box
  89749. */
  89750. static CreateTiledBox(options: {
  89751. pattern?: number;
  89752. width?: number;
  89753. height?: number;
  89754. depth?: number;
  89755. tileSize?: number;
  89756. tileWidth?: number;
  89757. tileHeight?: number;
  89758. alignHorizontal?: number;
  89759. alignVertical?: number;
  89760. faceUV?: Vector4[];
  89761. faceColors?: Color4[];
  89762. sideOrientation?: number;
  89763. }): VertexData;
  89764. /**
  89765. * Creates the VertexData for a tiled plane
  89766. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89767. * * pattern a limited pattern arrangement depending on the number
  89768. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89769. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89770. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89771. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89772. * * 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)
  89773. * * 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)
  89774. * @returns the VertexData of the tiled plane
  89775. */
  89776. static CreateTiledPlane(options: {
  89777. pattern?: number;
  89778. tileSize?: number;
  89779. tileWidth?: number;
  89780. tileHeight?: number;
  89781. size?: number;
  89782. width?: number;
  89783. height?: number;
  89784. alignHorizontal?: number;
  89785. alignVertical?: number;
  89786. sideOrientation?: number;
  89787. frontUVs?: Vector4;
  89788. backUVs?: Vector4;
  89789. }): VertexData;
  89790. /**
  89791. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89792. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89793. * * segments sets the number of horizontal strips optional, default 32
  89794. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89795. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89796. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89797. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89798. * * 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
  89799. * * 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
  89800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89801. * * 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)
  89802. * * 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)
  89803. * @returns the VertexData of the ellipsoid
  89804. */
  89805. static CreateSphere(options: {
  89806. segments?: number;
  89807. diameter?: number;
  89808. diameterX?: number;
  89809. diameterY?: number;
  89810. diameterZ?: number;
  89811. arc?: number;
  89812. slice?: number;
  89813. sideOrientation?: number;
  89814. frontUVs?: Vector4;
  89815. backUVs?: Vector4;
  89816. }): VertexData;
  89817. /**
  89818. * Creates the VertexData for a cylinder, cone or prism
  89819. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89820. * * height sets the height (y direction) of the cylinder, optional, default 2
  89821. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89822. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89823. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89824. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89825. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89826. * * 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
  89827. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89828. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89829. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89830. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89832. * * 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)
  89833. * * 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)
  89834. * @returns the VertexData of the cylinder, cone or prism
  89835. */
  89836. static CreateCylinder(options: {
  89837. height?: number;
  89838. diameterTop?: number;
  89839. diameterBottom?: number;
  89840. diameter?: number;
  89841. tessellation?: number;
  89842. subdivisions?: number;
  89843. arc?: number;
  89844. faceColors?: Color4[];
  89845. faceUV?: Vector4[];
  89846. hasRings?: boolean;
  89847. enclose?: boolean;
  89848. sideOrientation?: number;
  89849. frontUVs?: Vector4;
  89850. backUVs?: Vector4;
  89851. }): VertexData;
  89852. /**
  89853. * Creates the VertexData for a torus
  89854. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89855. * * diameter the diameter of the torus, optional default 1
  89856. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89857. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89859. * * 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)
  89860. * * 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)
  89861. * @returns the VertexData of the torus
  89862. */
  89863. static CreateTorus(options: {
  89864. diameter?: number;
  89865. thickness?: number;
  89866. tessellation?: number;
  89867. sideOrientation?: number;
  89868. frontUVs?: Vector4;
  89869. backUVs?: Vector4;
  89870. }): VertexData;
  89871. /**
  89872. * Creates the VertexData of the LineSystem
  89873. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89874. * - lines an array of lines, each line being an array of successive Vector3
  89875. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89876. * @returns the VertexData of the LineSystem
  89877. */
  89878. static CreateLineSystem(options: {
  89879. lines: Vector3[][];
  89880. colors?: Nullable<Color4[][]>;
  89881. }): VertexData;
  89882. /**
  89883. * Create the VertexData for a DashedLines
  89884. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89885. * - points an array successive Vector3
  89886. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89887. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89888. * - dashNb the intended total number of dashes, optional, default 200
  89889. * @returns the VertexData for the DashedLines
  89890. */
  89891. static CreateDashedLines(options: {
  89892. points: Vector3[];
  89893. dashSize?: number;
  89894. gapSize?: number;
  89895. dashNb?: number;
  89896. }): VertexData;
  89897. /**
  89898. * Creates the VertexData for a Ground
  89899. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89900. * - width the width (x direction) of the ground, optional, default 1
  89901. * - height the height (z direction) of the ground, optional, default 1
  89902. * - subdivisions the number of subdivisions per side, optional, default 1
  89903. * @returns the VertexData of the Ground
  89904. */
  89905. static CreateGround(options: {
  89906. width?: number;
  89907. height?: number;
  89908. subdivisions?: number;
  89909. subdivisionsX?: number;
  89910. subdivisionsY?: number;
  89911. }): VertexData;
  89912. /**
  89913. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89914. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89915. * * xmin the ground minimum X coordinate, optional, default -1
  89916. * * zmin the ground minimum Z coordinate, optional, default -1
  89917. * * xmax the ground maximum X coordinate, optional, default 1
  89918. * * zmax the ground maximum Z coordinate, optional, default 1
  89919. * * 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}
  89920. * * 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}
  89921. * @returns the VertexData of the TiledGround
  89922. */
  89923. static CreateTiledGround(options: {
  89924. xmin: number;
  89925. zmin: number;
  89926. xmax: number;
  89927. zmax: number;
  89928. subdivisions?: {
  89929. w: number;
  89930. h: number;
  89931. };
  89932. precision?: {
  89933. w: number;
  89934. h: number;
  89935. };
  89936. }): VertexData;
  89937. /**
  89938. * Creates the VertexData of the Ground designed from a heightmap
  89939. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89940. * * width the width (x direction) of the ground
  89941. * * height the height (z direction) of the ground
  89942. * * subdivisions the number of subdivisions per side
  89943. * * minHeight the minimum altitude on the ground, optional, default 0
  89944. * * maxHeight the maximum altitude on the ground, optional default 1
  89945. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89946. * * buffer the array holding the image color data
  89947. * * bufferWidth the width of image
  89948. * * bufferHeight the height of image
  89949. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89950. * @returns the VertexData of the Ground designed from a heightmap
  89951. */
  89952. static CreateGroundFromHeightMap(options: {
  89953. width: number;
  89954. height: number;
  89955. subdivisions: number;
  89956. minHeight: number;
  89957. maxHeight: number;
  89958. colorFilter: Color3;
  89959. buffer: Uint8Array;
  89960. bufferWidth: number;
  89961. bufferHeight: number;
  89962. alphaFilter: number;
  89963. }): VertexData;
  89964. /**
  89965. * Creates the VertexData for a Plane
  89966. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89967. * * size sets the width and height of the plane to the value of size, optional default 1
  89968. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89969. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89971. * * 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)
  89972. * * 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)
  89973. * @returns the VertexData of the box
  89974. */
  89975. static CreatePlane(options: {
  89976. size?: number;
  89977. width?: number;
  89978. height?: number;
  89979. sideOrientation?: number;
  89980. frontUVs?: Vector4;
  89981. backUVs?: Vector4;
  89982. }): VertexData;
  89983. /**
  89984. * Creates the VertexData of the Disc or regular Polygon
  89985. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89986. * * radius the radius of the disc, optional default 0.5
  89987. * * tessellation the number of polygon sides, optional, default 64
  89988. * * 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
  89989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89990. * * 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)
  89991. * * 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)
  89992. * @returns the VertexData of the box
  89993. */
  89994. static CreateDisc(options: {
  89995. radius?: number;
  89996. tessellation?: number;
  89997. arc?: number;
  89998. sideOrientation?: number;
  89999. frontUVs?: Vector4;
  90000. backUVs?: Vector4;
  90001. }): VertexData;
  90002. /**
  90003. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90004. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90005. * @param polygon a mesh built from polygonTriangulation.build()
  90006. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90007. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90008. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90009. * @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)
  90010. * @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)
  90011. * @returns the VertexData of the Polygon
  90012. */
  90013. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90014. /**
  90015. * Creates the VertexData of the IcoSphere
  90016. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90017. * * radius the radius of the IcoSphere, optional default 1
  90018. * * radiusX allows stretching in the x direction, optional, default radius
  90019. * * radiusY allows stretching in the y direction, optional, default radius
  90020. * * radiusZ allows stretching in the z direction, optional, default radius
  90021. * * flat when true creates a flat shaded mesh, optional, default true
  90022. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90024. * * 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)
  90025. * * 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)
  90026. * @returns the VertexData of the IcoSphere
  90027. */
  90028. static CreateIcoSphere(options: {
  90029. radius?: number;
  90030. radiusX?: number;
  90031. radiusY?: number;
  90032. radiusZ?: number;
  90033. flat?: boolean;
  90034. subdivisions?: number;
  90035. sideOrientation?: number;
  90036. frontUVs?: Vector4;
  90037. backUVs?: Vector4;
  90038. }): VertexData;
  90039. /**
  90040. * Creates the VertexData for a Polyhedron
  90041. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90042. * * type provided types are:
  90043. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90044. * * 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)
  90045. * * size the size of the IcoSphere, optional default 1
  90046. * * sizeX allows stretching in the x direction, optional, default size
  90047. * * sizeY allows stretching in the y direction, optional, default size
  90048. * * sizeZ allows stretching in the z direction, optional, default size
  90049. * * 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
  90050. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90051. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90052. * * flat when true creates a flat shaded mesh, optional, default true
  90053. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90055. * * 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)
  90056. * * 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)
  90057. * @returns the VertexData of the Polyhedron
  90058. */
  90059. static CreatePolyhedron(options: {
  90060. type?: number;
  90061. size?: number;
  90062. sizeX?: number;
  90063. sizeY?: number;
  90064. sizeZ?: number;
  90065. custom?: any;
  90066. faceUV?: Vector4[];
  90067. faceColors?: Color4[];
  90068. flat?: boolean;
  90069. sideOrientation?: number;
  90070. frontUVs?: Vector4;
  90071. backUVs?: Vector4;
  90072. }): VertexData;
  90073. /**
  90074. * Creates the VertexData for a TorusKnot
  90075. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90076. * * radius the radius of the torus knot, optional, default 2
  90077. * * tube the thickness of the tube, optional, default 0.5
  90078. * * radialSegments the number of sides on each tube segments, optional, default 32
  90079. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90080. * * p the number of windings around the z axis, optional, default 2
  90081. * * q the number of windings around the x axis, optional, default 3
  90082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90083. * * 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)
  90084. * * 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)
  90085. * @returns the VertexData of the Torus Knot
  90086. */
  90087. static CreateTorusKnot(options: {
  90088. radius?: number;
  90089. tube?: number;
  90090. radialSegments?: number;
  90091. tubularSegments?: number;
  90092. p?: number;
  90093. q?: number;
  90094. sideOrientation?: number;
  90095. frontUVs?: Vector4;
  90096. backUVs?: Vector4;
  90097. }): VertexData;
  90098. /**
  90099. * Compute normals for given positions and indices
  90100. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90101. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90102. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90103. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90104. * * facetNormals : optional array of facet normals (vector3)
  90105. * * facetPositions : optional array of facet positions (vector3)
  90106. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90107. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90108. * * bInfo : optional bounding info, required for facetPartitioning computation
  90109. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90110. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90111. * * useRightHandedSystem: optional boolean to for right handed system computation
  90112. * * depthSort : optional boolean to enable the facet depth sort computation
  90113. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90114. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90115. */
  90116. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90117. facetNormals?: any;
  90118. facetPositions?: any;
  90119. facetPartitioning?: any;
  90120. ratio?: number;
  90121. bInfo?: any;
  90122. bbSize?: Vector3;
  90123. subDiv?: any;
  90124. useRightHandedSystem?: boolean;
  90125. depthSort?: boolean;
  90126. distanceTo?: Vector3;
  90127. depthSortedFacets?: any;
  90128. }): void;
  90129. /** @hidden */
  90130. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90131. /**
  90132. * Applies VertexData created from the imported parameters to the geometry
  90133. * @param parsedVertexData the parsed data from an imported file
  90134. * @param geometry the geometry to apply the VertexData to
  90135. */
  90136. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90137. }
  90138. }
  90139. declare module BABYLON {
  90140. /**
  90141. * Defines a target to use with MorphTargetManager
  90142. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90143. */
  90144. export class MorphTarget implements IAnimatable {
  90145. /** defines the name of the target */
  90146. name: string;
  90147. /**
  90148. * Gets or sets the list of animations
  90149. */
  90150. animations: Animation[];
  90151. private _scene;
  90152. private _positions;
  90153. private _normals;
  90154. private _tangents;
  90155. private _uvs;
  90156. private _influence;
  90157. private _uniqueId;
  90158. /**
  90159. * Observable raised when the influence changes
  90160. */
  90161. onInfluenceChanged: Observable<boolean>;
  90162. /** @hidden */
  90163. _onDataLayoutChanged: Observable<void>;
  90164. /**
  90165. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90166. */
  90167. influence: number;
  90168. /**
  90169. * Gets or sets the id of the morph Target
  90170. */
  90171. id: string;
  90172. private _animationPropertiesOverride;
  90173. /**
  90174. * Gets or sets the animation properties override
  90175. */
  90176. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90177. /**
  90178. * Creates a new MorphTarget
  90179. * @param name defines the name of the target
  90180. * @param influence defines the influence to use
  90181. * @param scene defines the scene the morphtarget belongs to
  90182. */
  90183. constructor(
  90184. /** defines the name of the target */
  90185. name: string, influence?: number, scene?: Nullable<Scene>);
  90186. /**
  90187. * Gets the unique ID of this manager
  90188. */
  90189. readonly uniqueId: number;
  90190. /**
  90191. * Gets a boolean defining if the target contains position data
  90192. */
  90193. readonly hasPositions: boolean;
  90194. /**
  90195. * Gets a boolean defining if the target contains normal data
  90196. */
  90197. readonly hasNormals: boolean;
  90198. /**
  90199. * Gets a boolean defining if the target contains tangent data
  90200. */
  90201. readonly hasTangents: boolean;
  90202. /**
  90203. * Gets a boolean defining if the target contains texture coordinates data
  90204. */
  90205. readonly hasUVs: boolean;
  90206. /**
  90207. * Affects position data to this target
  90208. * @param data defines the position data to use
  90209. */
  90210. setPositions(data: Nullable<FloatArray>): void;
  90211. /**
  90212. * Gets the position data stored in this target
  90213. * @returns a FloatArray containing the position data (or null if not present)
  90214. */
  90215. getPositions(): Nullable<FloatArray>;
  90216. /**
  90217. * Affects normal data to this target
  90218. * @param data defines the normal data to use
  90219. */
  90220. setNormals(data: Nullable<FloatArray>): void;
  90221. /**
  90222. * Gets the normal data stored in this target
  90223. * @returns a FloatArray containing the normal data (or null if not present)
  90224. */
  90225. getNormals(): Nullable<FloatArray>;
  90226. /**
  90227. * Affects tangent data to this target
  90228. * @param data defines the tangent data to use
  90229. */
  90230. setTangents(data: Nullable<FloatArray>): void;
  90231. /**
  90232. * Gets the tangent data stored in this target
  90233. * @returns a FloatArray containing the tangent data (or null if not present)
  90234. */
  90235. getTangents(): Nullable<FloatArray>;
  90236. /**
  90237. * Affects texture coordinates data to this target
  90238. * @param data defines the texture coordinates data to use
  90239. */
  90240. setUVs(data: Nullable<FloatArray>): void;
  90241. /**
  90242. * Gets the texture coordinates data stored in this target
  90243. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90244. */
  90245. getUVs(): Nullable<FloatArray>;
  90246. /**
  90247. * Clone the current target
  90248. * @returns a new MorphTarget
  90249. */
  90250. clone(): MorphTarget;
  90251. /**
  90252. * Serializes the current target into a Serialization object
  90253. * @returns the serialized object
  90254. */
  90255. serialize(): any;
  90256. /**
  90257. * Returns the string "MorphTarget"
  90258. * @returns "MorphTarget"
  90259. */
  90260. getClassName(): string;
  90261. /**
  90262. * Creates a new target from serialized data
  90263. * @param serializationObject defines the serialized data to use
  90264. * @returns a new MorphTarget
  90265. */
  90266. static Parse(serializationObject: any): MorphTarget;
  90267. /**
  90268. * Creates a MorphTarget from mesh data
  90269. * @param mesh defines the source mesh
  90270. * @param name defines the name to use for the new target
  90271. * @param influence defines the influence to attach to the target
  90272. * @returns a new MorphTarget
  90273. */
  90274. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90275. }
  90276. }
  90277. declare module BABYLON {
  90278. /**
  90279. * This class is used to deform meshes using morphing between different targets
  90280. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90281. */
  90282. export class MorphTargetManager {
  90283. private _targets;
  90284. private _targetInfluenceChangedObservers;
  90285. private _targetDataLayoutChangedObservers;
  90286. private _activeTargets;
  90287. private _scene;
  90288. private _influences;
  90289. private _supportsNormals;
  90290. private _supportsTangents;
  90291. private _supportsUVs;
  90292. private _vertexCount;
  90293. private _uniqueId;
  90294. private _tempInfluences;
  90295. /**
  90296. * Gets or sets a boolean indicating if normals must be morphed
  90297. */
  90298. enableNormalMorphing: boolean;
  90299. /**
  90300. * Gets or sets a boolean indicating if tangents must be morphed
  90301. */
  90302. enableTangentMorphing: boolean;
  90303. /**
  90304. * Gets or sets a boolean indicating if UV must be morphed
  90305. */
  90306. enableUVMorphing: boolean;
  90307. /**
  90308. * Creates a new MorphTargetManager
  90309. * @param scene defines the current scene
  90310. */
  90311. constructor(scene?: Nullable<Scene>);
  90312. /**
  90313. * Gets the unique ID of this manager
  90314. */
  90315. readonly uniqueId: number;
  90316. /**
  90317. * Gets the number of vertices handled by this manager
  90318. */
  90319. readonly vertexCount: number;
  90320. /**
  90321. * Gets a boolean indicating if this manager supports morphing of normals
  90322. */
  90323. readonly supportsNormals: boolean;
  90324. /**
  90325. * Gets a boolean indicating if this manager supports morphing of tangents
  90326. */
  90327. readonly supportsTangents: boolean;
  90328. /**
  90329. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90330. */
  90331. readonly supportsUVs: boolean;
  90332. /**
  90333. * Gets the number of targets stored in this manager
  90334. */
  90335. readonly numTargets: number;
  90336. /**
  90337. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90338. */
  90339. readonly numInfluencers: number;
  90340. /**
  90341. * Gets the list of influences (one per target)
  90342. */
  90343. readonly influences: Float32Array;
  90344. /**
  90345. * Gets the active target at specified index. An active target is a target with an influence > 0
  90346. * @param index defines the index to check
  90347. * @returns the requested target
  90348. */
  90349. getActiveTarget(index: number): MorphTarget;
  90350. /**
  90351. * Gets the target at specified index
  90352. * @param index defines the index to check
  90353. * @returns the requested target
  90354. */
  90355. getTarget(index: number): MorphTarget;
  90356. /**
  90357. * Add a new target to this manager
  90358. * @param target defines the target to add
  90359. */
  90360. addTarget(target: MorphTarget): void;
  90361. /**
  90362. * Removes a target from the manager
  90363. * @param target defines the target to remove
  90364. */
  90365. removeTarget(target: MorphTarget): void;
  90366. /**
  90367. * Clone the current manager
  90368. * @returns a new MorphTargetManager
  90369. */
  90370. clone(): MorphTargetManager;
  90371. /**
  90372. * Serializes the current manager into a Serialization object
  90373. * @returns the serialized object
  90374. */
  90375. serialize(): any;
  90376. private _syncActiveTargets;
  90377. /**
  90378. * Syncrhonize the targets with all the meshes using this morph target manager
  90379. */
  90380. synchronize(): void;
  90381. /**
  90382. * Creates a new MorphTargetManager from serialized data
  90383. * @param serializationObject defines the serialized data
  90384. * @param scene defines the hosting scene
  90385. * @returns the new MorphTargetManager
  90386. */
  90387. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90388. }
  90389. }
  90390. declare module BABYLON {
  90391. /**
  90392. * Class used to represent a specific level of detail of a mesh
  90393. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90394. */
  90395. export class MeshLODLevel {
  90396. /** Defines the distance where this level should start being displayed */
  90397. distance: number;
  90398. /** Defines the mesh to use to render this level */
  90399. mesh: Nullable<Mesh>;
  90400. /**
  90401. * Creates a new LOD level
  90402. * @param distance defines the distance where this level should star being displayed
  90403. * @param mesh defines the mesh to use to render this level
  90404. */
  90405. constructor(
  90406. /** Defines the distance where this level should start being displayed */
  90407. distance: number,
  90408. /** Defines the mesh to use to render this level */
  90409. mesh: Nullable<Mesh>);
  90410. }
  90411. }
  90412. declare module BABYLON {
  90413. /**
  90414. * Mesh representing the gorund
  90415. */
  90416. export class GroundMesh extends Mesh {
  90417. /** If octree should be generated */
  90418. generateOctree: boolean;
  90419. private _heightQuads;
  90420. /** @hidden */
  90421. _subdivisionsX: number;
  90422. /** @hidden */
  90423. _subdivisionsY: number;
  90424. /** @hidden */
  90425. _width: number;
  90426. /** @hidden */
  90427. _height: number;
  90428. /** @hidden */
  90429. _minX: number;
  90430. /** @hidden */
  90431. _maxX: number;
  90432. /** @hidden */
  90433. _minZ: number;
  90434. /** @hidden */
  90435. _maxZ: number;
  90436. constructor(name: string, scene: Scene);
  90437. /**
  90438. * "GroundMesh"
  90439. * @returns "GroundMesh"
  90440. */
  90441. getClassName(): string;
  90442. /**
  90443. * The minimum of x and y subdivisions
  90444. */
  90445. readonly subdivisions: number;
  90446. /**
  90447. * X subdivisions
  90448. */
  90449. readonly subdivisionsX: number;
  90450. /**
  90451. * Y subdivisions
  90452. */
  90453. readonly subdivisionsY: number;
  90454. /**
  90455. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90456. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90457. * @param chunksCount the number of subdivisions for x and y
  90458. * @param octreeBlocksSize (Default: 32)
  90459. */
  90460. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90461. /**
  90462. * Returns a height (y) value in the Worl system :
  90463. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90464. * @param x x coordinate
  90465. * @param z z coordinate
  90466. * @returns the ground y position if (x, z) are outside the ground surface.
  90467. */
  90468. getHeightAtCoordinates(x: number, z: number): number;
  90469. /**
  90470. * Returns a normalized vector (Vector3) orthogonal to the ground
  90471. * at the ground coordinates (x, z) expressed in the World system.
  90472. * @param x x coordinate
  90473. * @param z z coordinate
  90474. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90475. */
  90476. getNormalAtCoordinates(x: number, z: number): Vector3;
  90477. /**
  90478. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90479. * at the ground coordinates (x, z) expressed in the World system.
  90480. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90481. * @param x x coordinate
  90482. * @param z z coordinate
  90483. * @param ref vector to store the result
  90484. * @returns the GroundMesh.
  90485. */
  90486. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90487. /**
  90488. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90489. * if the ground has been updated.
  90490. * This can be used in the render loop.
  90491. * @returns the GroundMesh.
  90492. */
  90493. updateCoordinateHeights(): GroundMesh;
  90494. private _getFacetAt;
  90495. private _initHeightQuads;
  90496. private _computeHeightQuads;
  90497. /**
  90498. * Serializes this ground mesh
  90499. * @param serializationObject object to write serialization to
  90500. */
  90501. serialize(serializationObject: any): void;
  90502. /**
  90503. * Parses a serialized ground mesh
  90504. * @param parsedMesh the serialized mesh
  90505. * @param scene the scene to create the ground mesh in
  90506. * @returns the created ground mesh
  90507. */
  90508. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90509. }
  90510. }
  90511. declare module BABYLON {
  90512. /**
  90513. * Interface for Physics-Joint data
  90514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90515. */
  90516. export interface PhysicsJointData {
  90517. /**
  90518. * The main pivot of the joint
  90519. */
  90520. mainPivot?: Vector3;
  90521. /**
  90522. * The connected pivot of the joint
  90523. */
  90524. connectedPivot?: Vector3;
  90525. /**
  90526. * The main axis of the joint
  90527. */
  90528. mainAxis?: Vector3;
  90529. /**
  90530. * The connected axis of the joint
  90531. */
  90532. connectedAxis?: Vector3;
  90533. /**
  90534. * The collision of the joint
  90535. */
  90536. collision?: boolean;
  90537. /**
  90538. * Native Oimo/Cannon/Energy data
  90539. */
  90540. nativeParams?: any;
  90541. }
  90542. /**
  90543. * This is a holder class for the physics joint created by the physics plugin
  90544. * It holds a set of functions to control the underlying joint
  90545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90546. */
  90547. export class PhysicsJoint {
  90548. /**
  90549. * The type of the physics joint
  90550. */
  90551. type: number;
  90552. /**
  90553. * The data for the physics joint
  90554. */
  90555. jointData: PhysicsJointData;
  90556. private _physicsJoint;
  90557. protected _physicsPlugin: IPhysicsEnginePlugin;
  90558. /**
  90559. * Initializes the physics joint
  90560. * @param type The type of the physics joint
  90561. * @param jointData The data for the physics joint
  90562. */
  90563. constructor(
  90564. /**
  90565. * The type of the physics joint
  90566. */
  90567. type: number,
  90568. /**
  90569. * The data for the physics joint
  90570. */
  90571. jointData: PhysicsJointData);
  90572. /**
  90573. * Gets the physics joint
  90574. */
  90575. /**
  90576. * Sets the physics joint
  90577. */
  90578. physicsJoint: any;
  90579. /**
  90580. * Sets the physics plugin
  90581. */
  90582. physicsPlugin: IPhysicsEnginePlugin;
  90583. /**
  90584. * Execute a function that is physics-plugin specific.
  90585. * @param {Function} func the function that will be executed.
  90586. * It accepts two parameters: the physics world and the physics joint
  90587. */
  90588. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90589. /**
  90590. * Distance-Joint type
  90591. */
  90592. static DistanceJoint: number;
  90593. /**
  90594. * Hinge-Joint type
  90595. */
  90596. static HingeJoint: number;
  90597. /**
  90598. * Ball-and-Socket joint type
  90599. */
  90600. static BallAndSocketJoint: number;
  90601. /**
  90602. * Wheel-Joint type
  90603. */
  90604. static WheelJoint: number;
  90605. /**
  90606. * Slider-Joint type
  90607. */
  90608. static SliderJoint: number;
  90609. /**
  90610. * Prismatic-Joint type
  90611. */
  90612. static PrismaticJoint: number;
  90613. /**
  90614. * Universal-Joint type
  90615. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90616. */
  90617. static UniversalJoint: number;
  90618. /**
  90619. * Hinge-Joint 2 type
  90620. */
  90621. static Hinge2Joint: number;
  90622. /**
  90623. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90624. */
  90625. static PointToPointJoint: number;
  90626. /**
  90627. * Spring-Joint type
  90628. */
  90629. static SpringJoint: number;
  90630. /**
  90631. * Lock-Joint type
  90632. */
  90633. static LockJoint: number;
  90634. }
  90635. /**
  90636. * A class representing a physics distance joint
  90637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90638. */
  90639. export class DistanceJoint extends PhysicsJoint {
  90640. /**
  90641. *
  90642. * @param jointData The data for the Distance-Joint
  90643. */
  90644. constructor(jointData: DistanceJointData);
  90645. /**
  90646. * Update the predefined distance.
  90647. * @param maxDistance The maximum preferred distance
  90648. * @param minDistance The minimum preferred distance
  90649. */
  90650. updateDistance(maxDistance: number, minDistance?: number): void;
  90651. }
  90652. /**
  90653. * Represents a Motor-Enabled Joint
  90654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90655. */
  90656. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90657. /**
  90658. * Initializes the Motor-Enabled Joint
  90659. * @param type The type of the joint
  90660. * @param jointData The physica joint data for the joint
  90661. */
  90662. constructor(type: number, jointData: PhysicsJointData);
  90663. /**
  90664. * Set the motor values.
  90665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90666. * @param force the force to apply
  90667. * @param maxForce max force for this motor.
  90668. */
  90669. setMotor(force?: number, maxForce?: number): void;
  90670. /**
  90671. * Set the motor's limits.
  90672. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90673. * @param upperLimit The upper limit of the motor
  90674. * @param lowerLimit The lower limit of the motor
  90675. */
  90676. setLimit(upperLimit: number, lowerLimit?: number): void;
  90677. }
  90678. /**
  90679. * This class represents a single physics Hinge-Joint
  90680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90681. */
  90682. export class HingeJoint extends MotorEnabledJoint {
  90683. /**
  90684. * Initializes the Hinge-Joint
  90685. * @param jointData The joint data for the Hinge-Joint
  90686. */
  90687. constructor(jointData: PhysicsJointData);
  90688. /**
  90689. * Set the motor values.
  90690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90691. * @param {number} force the force to apply
  90692. * @param {number} maxForce max force for this motor.
  90693. */
  90694. setMotor(force?: number, maxForce?: number): void;
  90695. /**
  90696. * Set the motor's limits.
  90697. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90698. * @param upperLimit The upper limit of the motor
  90699. * @param lowerLimit The lower limit of the motor
  90700. */
  90701. setLimit(upperLimit: number, lowerLimit?: number): void;
  90702. }
  90703. /**
  90704. * This class represents a dual hinge physics joint (same as wheel joint)
  90705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90706. */
  90707. export class Hinge2Joint extends MotorEnabledJoint {
  90708. /**
  90709. * Initializes the Hinge2-Joint
  90710. * @param jointData The joint data for the Hinge2-Joint
  90711. */
  90712. constructor(jointData: PhysicsJointData);
  90713. /**
  90714. * Set the motor values.
  90715. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90716. * @param {number} targetSpeed the speed the motor is to reach
  90717. * @param {number} maxForce max force for this motor.
  90718. * @param {motorIndex} the motor's index, 0 or 1.
  90719. */
  90720. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90721. /**
  90722. * Set the motor limits.
  90723. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90724. * @param {number} upperLimit the upper limit
  90725. * @param {number} lowerLimit lower limit
  90726. * @param {motorIndex} the motor's index, 0 or 1.
  90727. */
  90728. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90729. }
  90730. /**
  90731. * Interface for a motor enabled joint
  90732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90733. */
  90734. export interface IMotorEnabledJoint {
  90735. /**
  90736. * Physics joint
  90737. */
  90738. physicsJoint: any;
  90739. /**
  90740. * Sets the motor of the motor-enabled joint
  90741. * @param force The force of the motor
  90742. * @param maxForce The maximum force of the motor
  90743. * @param motorIndex The index of the motor
  90744. */
  90745. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90746. /**
  90747. * Sets the limit of the motor
  90748. * @param upperLimit The upper limit of the motor
  90749. * @param lowerLimit The lower limit of the motor
  90750. * @param motorIndex The index of the motor
  90751. */
  90752. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90753. }
  90754. /**
  90755. * Joint data for a Distance-Joint
  90756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90757. */
  90758. export interface DistanceJointData extends PhysicsJointData {
  90759. /**
  90760. * Max distance the 2 joint objects can be apart
  90761. */
  90762. maxDistance: number;
  90763. }
  90764. /**
  90765. * Joint data from a spring joint
  90766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90767. */
  90768. export interface SpringJointData extends PhysicsJointData {
  90769. /**
  90770. * Length of the spring
  90771. */
  90772. length: number;
  90773. /**
  90774. * Stiffness of the spring
  90775. */
  90776. stiffness: number;
  90777. /**
  90778. * Damping of the spring
  90779. */
  90780. damping: number;
  90781. /** this callback will be called when applying the force to the impostors. */
  90782. forceApplicationCallback: () => void;
  90783. }
  90784. }
  90785. declare module BABYLON {
  90786. /**
  90787. * Holds the data for the raycast result
  90788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90789. */
  90790. export class PhysicsRaycastResult {
  90791. private _hasHit;
  90792. private _hitDistance;
  90793. private _hitNormalWorld;
  90794. private _hitPointWorld;
  90795. private _rayFromWorld;
  90796. private _rayToWorld;
  90797. /**
  90798. * Gets if there was a hit
  90799. */
  90800. readonly hasHit: boolean;
  90801. /**
  90802. * Gets the distance from the hit
  90803. */
  90804. readonly hitDistance: number;
  90805. /**
  90806. * Gets the hit normal/direction in the world
  90807. */
  90808. readonly hitNormalWorld: Vector3;
  90809. /**
  90810. * Gets the hit point in the world
  90811. */
  90812. readonly hitPointWorld: Vector3;
  90813. /**
  90814. * Gets the ray "start point" of the ray in the world
  90815. */
  90816. readonly rayFromWorld: Vector3;
  90817. /**
  90818. * Gets the ray "end point" of the ray in the world
  90819. */
  90820. readonly rayToWorld: Vector3;
  90821. /**
  90822. * Sets the hit data (normal & point in world space)
  90823. * @param hitNormalWorld defines the normal in world space
  90824. * @param hitPointWorld defines the point in world space
  90825. */
  90826. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90827. /**
  90828. * Sets the distance from the start point to the hit point
  90829. * @param distance
  90830. */
  90831. setHitDistance(distance: number): void;
  90832. /**
  90833. * Calculates the distance manually
  90834. */
  90835. calculateHitDistance(): void;
  90836. /**
  90837. * Resets all the values to default
  90838. * @param from The from point on world space
  90839. * @param to The to point on world space
  90840. */
  90841. reset(from?: Vector3, to?: Vector3): void;
  90842. }
  90843. /**
  90844. * Interface for the size containing width and height
  90845. */
  90846. interface IXYZ {
  90847. /**
  90848. * X
  90849. */
  90850. x: number;
  90851. /**
  90852. * Y
  90853. */
  90854. y: number;
  90855. /**
  90856. * Z
  90857. */
  90858. z: number;
  90859. }
  90860. }
  90861. declare module BABYLON {
  90862. /**
  90863. * Interface used to describe a physics joint
  90864. */
  90865. export interface PhysicsImpostorJoint {
  90866. /** Defines the main impostor to which the joint is linked */
  90867. mainImpostor: PhysicsImpostor;
  90868. /** Defines the impostor that is connected to the main impostor using this joint */
  90869. connectedImpostor: PhysicsImpostor;
  90870. /** Defines the joint itself */
  90871. joint: PhysicsJoint;
  90872. }
  90873. /** @hidden */
  90874. export interface IPhysicsEnginePlugin {
  90875. world: any;
  90876. name: string;
  90877. setGravity(gravity: Vector3): void;
  90878. setTimeStep(timeStep: number): void;
  90879. getTimeStep(): number;
  90880. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90881. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90882. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90883. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90884. removePhysicsBody(impostor: PhysicsImpostor): void;
  90885. generateJoint(joint: PhysicsImpostorJoint): void;
  90886. removeJoint(joint: PhysicsImpostorJoint): void;
  90887. isSupported(): boolean;
  90888. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90889. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90890. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90891. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90893. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90894. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90895. getBodyMass(impostor: PhysicsImpostor): number;
  90896. getBodyFriction(impostor: PhysicsImpostor): number;
  90897. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90898. getBodyRestitution(impostor: PhysicsImpostor): number;
  90899. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90900. getBodyPressure?(impostor: PhysicsImpostor): number;
  90901. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90902. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90903. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90904. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90905. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90906. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90907. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90908. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90909. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90910. sleepBody(impostor: PhysicsImpostor): void;
  90911. wakeUpBody(impostor: PhysicsImpostor): void;
  90912. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90913. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90914. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90915. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90916. getRadius(impostor: PhysicsImpostor): number;
  90917. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90918. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90919. dispose(): void;
  90920. }
  90921. /**
  90922. * Interface used to define a physics engine
  90923. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90924. */
  90925. export interface IPhysicsEngine {
  90926. /**
  90927. * Gets the gravity vector used by the simulation
  90928. */
  90929. gravity: Vector3;
  90930. /**
  90931. * Sets the gravity vector used by the simulation
  90932. * @param gravity defines the gravity vector to use
  90933. */
  90934. setGravity(gravity: Vector3): void;
  90935. /**
  90936. * Set the time step of the physics engine.
  90937. * Default is 1/60.
  90938. * To slow it down, enter 1/600 for example.
  90939. * To speed it up, 1/30
  90940. * @param newTimeStep the new timestep to apply to this world.
  90941. */
  90942. setTimeStep(newTimeStep: number): void;
  90943. /**
  90944. * Get the time step of the physics engine.
  90945. * @returns the current time step
  90946. */
  90947. getTimeStep(): number;
  90948. /**
  90949. * Release all resources
  90950. */
  90951. dispose(): void;
  90952. /**
  90953. * Gets the name of the current physics plugin
  90954. * @returns the name of the plugin
  90955. */
  90956. getPhysicsPluginName(): string;
  90957. /**
  90958. * Adding a new impostor for the impostor tracking.
  90959. * This will be done by the impostor itself.
  90960. * @param impostor the impostor to add
  90961. */
  90962. addImpostor(impostor: PhysicsImpostor): void;
  90963. /**
  90964. * Remove an impostor from the engine.
  90965. * This impostor and its mesh will not longer be updated by the physics engine.
  90966. * @param impostor the impostor to remove
  90967. */
  90968. removeImpostor(impostor: PhysicsImpostor): void;
  90969. /**
  90970. * Add a joint to the physics engine
  90971. * @param mainImpostor defines the main impostor to which the joint is added.
  90972. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90973. * @param joint defines the joint that will connect both impostors.
  90974. */
  90975. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90976. /**
  90977. * Removes a joint from the simulation
  90978. * @param mainImpostor defines the impostor used with the joint
  90979. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90980. * @param joint defines the joint to remove
  90981. */
  90982. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90983. /**
  90984. * Gets the current plugin used to run the simulation
  90985. * @returns current plugin
  90986. */
  90987. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90988. /**
  90989. * Gets the list of physic impostors
  90990. * @returns an array of PhysicsImpostor
  90991. */
  90992. getImpostors(): Array<PhysicsImpostor>;
  90993. /**
  90994. * Gets the impostor for a physics enabled object
  90995. * @param object defines the object impersonated by the impostor
  90996. * @returns the PhysicsImpostor or null if not found
  90997. */
  90998. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90999. /**
  91000. * Gets the impostor for a physics body object
  91001. * @param body defines physics body used by the impostor
  91002. * @returns the PhysicsImpostor or null if not found
  91003. */
  91004. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91005. /**
  91006. * Does a raycast in the physics world
  91007. * @param from when should the ray start?
  91008. * @param to when should the ray end?
  91009. * @returns PhysicsRaycastResult
  91010. */
  91011. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91012. /**
  91013. * Called by the scene. No need to call it.
  91014. * @param delta defines the timespam between frames
  91015. */
  91016. _step(delta: number): void;
  91017. }
  91018. }
  91019. declare module BABYLON {
  91020. /**
  91021. * The interface for the physics imposter parameters
  91022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91023. */
  91024. export interface PhysicsImpostorParameters {
  91025. /**
  91026. * The mass of the physics imposter
  91027. */
  91028. mass: number;
  91029. /**
  91030. * The friction of the physics imposter
  91031. */
  91032. friction?: number;
  91033. /**
  91034. * The coefficient of restitution of the physics imposter
  91035. */
  91036. restitution?: number;
  91037. /**
  91038. * The native options of the physics imposter
  91039. */
  91040. nativeOptions?: any;
  91041. /**
  91042. * Specifies if the parent should be ignored
  91043. */
  91044. ignoreParent?: boolean;
  91045. /**
  91046. * Specifies if bi-directional transformations should be disabled
  91047. */
  91048. disableBidirectionalTransformation?: boolean;
  91049. /**
  91050. * The pressure inside the physics imposter, soft object only
  91051. */
  91052. pressure?: number;
  91053. /**
  91054. * The stiffness the physics imposter, soft object only
  91055. */
  91056. stiffness?: number;
  91057. /**
  91058. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91059. */
  91060. velocityIterations?: number;
  91061. /**
  91062. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91063. */
  91064. positionIterations?: number;
  91065. /**
  91066. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91067. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91068. * Add to fix multiple points
  91069. */
  91070. fixedPoints?: number;
  91071. /**
  91072. * The collision margin around a soft object
  91073. */
  91074. margin?: number;
  91075. /**
  91076. * The collision margin around a soft object
  91077. */
  91078. damping?: number;
  91079. /**
  91080. * The path for a rope based on an extrusion
  91081. */
  91082. path?: any;
  91083. /**
  91084. * The shape of an extrusion used for a rope based on an extrusion
  91085. */
  91086. shape?: any;
  91087. }
  91088. /**
  91089. * Interface for a physics-enabled object
  91090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91091. */
  91092. export interface IPhysicsEnabledObject {
  91093. /**
  91094. * The position of the physics-enabled object
  91095. */
  91096. position: Vector3;
  91097. /**
  91098. * The rotation of the physics-enabled object
  91099. */
  91100. rotationQuaternion: Nullable<Quaternion>;
  91101. /**
  91102. * The scale of the physics-enabled object
  91103. */
  91104. scaling: Vector3;
  91105. /**
  91106. * The rotation of the physics-enabled object
  91107. */
  91108. rotation?: Vector3;
  91109. /**
  91110. * The parent of the physics-enabled object
  91111. */
  91112. parent?: any;
  91113. /**
  91114. * The bounding info of the physics-enabled object
  91115. * @returns The bounding info of the physics-enabled object
  91116. */
  91117. getBoundingInfo(): BoundingInfo;
  91118. /**
  91119. * Computes the world matrix
  91120. * @param force Specifies if the world matrix should be computed by force
  91121. * @returns A world matrix
  91122. */
  91123. computeWorldMatrix(force: boolean): Matrix;
  91124. /**
  91125. * Gets the world matrix
  91126. * @returns A world matrix
  91127. */
  91128. getWorldMatrix?(): Matrix;
  91129. /**
  91130. * Gets the child meshes
  91131. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91132. * @returns An array of abstract meshes
  91133. */
  91134. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91135. /**
  91136. * Gets the vertex data
  91137. * @param kind The type of vertex data
  91138. * @returns A nullable array of numbers, or a float32 array
  91139. */
  91140. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91141. /**
  91142. * Gets the indices from the mesh
  91143. * @returns A nullable array of index arrays
  91144. */
  91145. getIndices?(): Nullable<IndicesArray>;
  91146. /**
  91147. * Gets the scene from the mesh
  91148. * @returns the indices array or null
  91149. */
  91150. getScene?(): Scene;
  91151. /**
  91152. * Gets the absolute position from the mesh
  91153. * @returns the absolute position
  91154. */
  91155. getAbsolutePosition(): Vector3;
  91156. /**
  91157. * Gets the absolute pivot point from the mesh
  91158. * @returns the absolute pivot point
  91159. */
  91160. getAbsolutePivotPoint(): Vector3;
  91161. /**
  91162. * Rotates the mesh
  91163. * @param axis The axis of rotation
  91164. * @param amount The amount of rotation
  91165. * @param space The space of the rotation
  91166. * @returns The rotation transform node
  91167. */
  91168. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91169. /**
  91170. * Translates the mesh
  91171. * @param axis The axis of translation
  91172. * @param distance The distance of translation
  91173. * @param space The space of the translation
  91174. * @returns The transform node
  91175. */
  91176. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91177. /**
  91178. * Sets the absolute position of the mesh
  91179. * @param absolutePosition The absolute position of the mesh
  91180. * @returns The transform node
  91181. */
  91182. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91183. /**
  91184. * Gets the class name of the mesh
  91185. * @returns The class name
  91186. */
  91187. getClassName(): string;
  91188. }
  91189. /**
  91190. * Represents a physics imposter
  91191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91192. */
  91193. export class PhysicsImpostor {
  91194. /**
  91195. * The physics-enabled object used as the physics imposter
  91196. */
  91197. object: IPhysicsEnabledObject;
  91198. /**
  91199. * The type of the physics imposter
  91200. */
  91201. type: number;
  91202. private _options;
  91203. private _scene?;
  91204. /**
  91205. * The default object size of the imposter
  91206. */
  91207. static DEFAULT_OBJECT_SIZE: Vector3;
  91208. /**
  91209. * The identity quaternion of the imposter
  91210. */
  91211. static IDENTITY_QUATERNION: Quaternion;
  91212. /** @hidden */
  91213. _pluginData: any;
  91214. private _physicsEngine;
  91215. private _physicsBody;
  91216. private _bodyUpdateRequired;
  91217. private _onBeforePhysicsStepCallbacks;
  91218. private _onAfterPhysicsStepCallbacks;
  91219. /** @hidden */
  91220. _onPhysicsCollideCallbacks: Array<{
  91221. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91222. otherImpostors: Array<PhysicsImpostor>;
  91223. }>;
  91224. private _deltaPosition;
  91225. private _deltaRotation;
  91226. private _deltaRotationConjugated;
  91227. /** @hidden */
  91228. _isFromLine: boolean;
  91229. private _parent;
  91230. private _isDisposed;
  91231. private static _tmpVecs;
  91232. private static _tmpQuat;
  91233. /**
  91234. * Specifies if the physics imposter is disposed
  91235. */
  91236. readonly isDisposed: boolean;
  91237. /**
  91238. * Gets the mass of the physics imposter
  91239. */
  91240. mass: number;
  91241. /**
  91242. * Gets the coefficient of friction
  91243. */
  91244. /**
  91245. * Sets the coefficient of friction
  91246. */
  91247. friction: number;
  91248. /**
  91249. * Gets the coefficient of restitution
  91250. */
  91251. /**
  91252. * Sets the coefficient of restitution
  91253. */
  91254. restitution: number;
  91255. /**
  91256. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91257. */
  91258. /**
  91259. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91260. */
  91261. pressure: number;
  91262. /**
  91263. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91264. */
  91265. /**
  91266. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91267. */
  91268. stiffness: number;
  91269. /**
  91270. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91271. */
  91272. /**
  91273. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91274. */
  91275. velocityIterations: number;
  91276. /**
  91277. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91278. */
  91279. /**
  91280. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91281. */
  91282. positionIterations: number;
  91283. /**
  91284. * The unique id of the physics imposter
  91285. * set by the physics engine when adding this impostor to the array
  91286. */
  91287. uniqueId: number;
  91288. /**
  91289. * @hidden
  91290. */
  91291. soft: boolean;
  91292. /**
  91293. * @hidden
  91294. */
  91295. segments: number;
  91296. private _joints;
  91297. /**
  91298. * Initializes the physics imposter
  91299. * @param object The physics-enabled object used as the physics imposter
  91300. * @param type The type of the physics imposter
  91301. * @param _options The options for the physics imposter
  91302. * @param _scene The Babylon scene
  91303. */
  91304. constructor(
  91305. /**
  91306. * The physics-enabled object used as the physics imposter
  91307. */
  91308. object: IPhysicsEnabledObject,
  91309. /**
  91310. * The type of the physics imposter
  91311. */
  91312. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91313. /**
  91314. * This function will completly initialize this impostor.
  91315. * It will create a new body - but only if this mesh has no parent.
  91316. * If it has, this impostor will not be used other than to define the impostor
  91317. * of the child mesh.
  91318. * @hidden
  91319. */
  91320. _init(): void;
  91321. private _getPhysicsParent;
  91322. /**
  91323. * Should a new body be generated.
  91324. * @returns boolean specifying if body initialization is required
  91325. */
  91326. isBodyInitRequired(): boolean;
  91327. /**
  91328. * Sets the updated scaling
  91329. * @param updated Specifies if the scaling is updated
  91330. */
  91331. setScalingUpdated(): void;
  91332. /**
  91333. * Force a regeneration of this or the parent's impostor's body.
  91334. * Use under cautious - This will remove all joints already implemented.
  91335. */
  91336. forceUpdate(): void;
  91337. /**
  91338. * Gets the body that holds this impostor. Either its own, or its parent.
  91339. */
  91340. /**
  91341. * Set the physics body. Used mainly by the physics engine/plugin
  91342. */
  91343. physicsBody: any;
  91344. /**
  91345. * Get the parent of the physics imposter
  91346. * @returns Physics imposter or null
  91347. */
  91348. /**
  91349. * Sets the parent of the physics imposter
  91350. */
  91351. parent: Nullable<PhysicsImpostor>;
  91352. /**
  91353. * Resets the update flags
  91354. */
  91355. resetUpdateFlags(): void;
  91356. /**
  91357. * Gets the object extend size
  91358. * @returns the object extend size
  91359. */
  91360. getObjectExtendSize(): Vector3;
  91361. /**
  91362. * Gets the object center
  91363. * @returns The object center
  91364. */
  91365. getObjectCenter(): Vector3;
  91366. /**
  91367. * Get a specific parametes from the options parameter
  91368. * @param paramName The object parameter name
  91369. * @returns The object parameter
  91370. */
  91371. getParam(paramName: string): any;
  91372. /**
  91373. * Sets a specific parameter in the options given to the physics plugin
  91374. * @param paramName The parameter name
  91375. * @param value The value of the parameter
  91376. */
  91377. setParam(paramName: string, value: number): void;
  91378. /**
  91379. * Specifically change the body's mass option. Won't recreate the physics body object
  91380. * @param mass The mass of the physics imposter
  91381. */
  91382. setMass(mass: number): void;
  91383. /**
  91384. * Gets the linear velocity
  91385. * @returns linear velocity or null
  91386. */
  91387. getLinearVelocity(): Nullable<Vector3>;
  91388. /**
  91389. * Sets the linear velocity
  91390. * @param velocity linear velocity or null
  91391. */
  91392. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91393. /**
  91394. * Gets the angular velocity
  91395. * @returns angular velocity or null
  91396. */
  91397. getAngularVelocity(): Nullable<Vector3>;
  91398. /**
  91399. * Sets the angular velocity
  91400. * @param velocity The velocity or null
  91401. */
  91402. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91403. /**
  91404. * Execute a function with the physics plugin native code
  91405. * Provide a function the will have two variables - the world object and the physics body object
  91406. * @param func The function to execute with the physics plugin native code
  91407. */
  91408. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91409. /**
  91410. * Register a function that will be executed before the physics world is stepping forward
  91411. * @param func The function to execute before the physics world is stepped forward
  91412. */
  91413. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91414. /**
  91415. * Unregister a function that will be executed before the physics world is stepping forward
  91416. * @param func The function to execute before the physics world is stepped forward
  91417. */
  91418. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91419. /**
  91420. * Register a function that will be executed after the physics step
  91421. * @param func The function to execute after physics step
  91422. */
  91423. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91424. /**
  91425. * Unregisters a function that will be executed after the physics step
  91426. * @param func The function to execute after physics step
  91427. */
  91428. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91429. /**
  91430. * register a function that will be executed when this impostor collides against a different body
  91431. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91432. * @param func Callback that is executed on collision
  91433. */
  91434. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91435. /**
  91436. * Unregisters the physics imposter on contact
  91437. * @param collideAgainst The physics object to collide against
  91438. * @param func Callback to execute on collision
  91439. */
  91440. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91441. private _tmpQuat;
  91442. private _tmpQuat2;
  91443. /**
  91444. * Get the parent rotation
  91445. * @returns The parent rotation
  91446. */
  91447. getParentsRotation(): Quaternion;
  91448. /**
  91449. * this function is executed by the physics engine.
  91450. */
  91451. beforeStep: () => void;
  91452. /**
  91453. * this function is executed by the physics engine
  91454. */
  91455. afterStep: () => void;
  91456. /**
  91457. * Legacy collision detection event support
  91458. */
  91459. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91460. /**
  91461. * event and body object due to cannon's event-based architecture.
  91462. */
  91463. onCollide: (e: {
  91464. body: any;
  91465. }) => void;
  91466. /**
  91467. * Apply a force
  91468. * @param force The force to apply
  91469. * @param contactPoint The contact point for the force
  91470. * @returns The physics imposter
  91471. */
  91472. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91473. /**
  91474. * Apply an impulse
  91475. * @param force The impulse force
  91476. * @param contactPoint The contact point for the impulse force
  91477. * @returns The physics imposter
  91478. */
  91479. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91480. /**
  91481. * A help function to create a joint
  91482. * @param otherImpostor A physics imposter used to create a joint
  91483. * @param jointType The type of joint
  91484. * @param jointData The data for the joint
  91485. * @returns The physics imposter
  91486. */
  91487. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91488. /**
  91489. * Add a joint to this impostor with a different impostor
  91490. * @param otherImpostor A physics imposter used to add a joint
  91491. * @param joint The joint to add
  91492. * @returns The physics imposter
  91493. */
  91494. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91495. /**
  91496. * Add an anchor to a cloth impostor
  91497. * @param otherImpostor rigid impostor to anchor to
  91498. * @param width ratio across width from 0 to 1
  91499. * @param height ratio up height from 0 to 1
  91500. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91501. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91502. * @returns impostor the soft imposter
  91503. */
  91504. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91505. /**
  91506. * Add a hook to a rope impostor
  91507. * @param otherImpostor rigid impostor to anchor to
  91508. * @param length ratio across rope from 0 to 1
  91509. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91510. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91511. * @returns impostor the rope imposter
  91512. */
  91513. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91514. /**
  91515. * Will keep this body still, in a sleep mode.
  91516. * @returns the physics imposter
  91517. */
  91518. sleep(): PhysicsImpostor;
  91519. /**
  91520. * Wake the body up.
  91521. * @returns The physics imposter
  91522. */
  91523. wakeUp(): PhysicsImpostor;
  91524. /**
  91525. * Clones the physics imposter
  91526. * @param newObject The physics imposter clones to this physics-enabled object
  91527. * @returns A nullable physics imposter
  91528. */
  91529. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91530. /**
  91531. * Disposes the physics imposter
  91532. */
  91533. dispose(): void;
  91534. /**
  91535. * Sets the delta position
  91536. * @param position The delta position amount
  91537. */
  91538. setDeltaPosition(position: Vector3): void;
  91539. /**
  91540. * Sets the delta rotation
  91541. * @param rotation The delta rotation amount
  91542. */
  91543. setDeltaRotation(rotation: Quaternion): void;
  91544. /**
  91545. * Gets the box size of the physics imposter and stores the result in the input parameter
  91546. * @param result Stores the box size
  91547. * @returns The physics imposter
  91548. */
  91549. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91550. /**
  91551. * Gets the radius of the physics imposter
  91552. * @returns Radius of the physics imposter
  91553. */
  91554. getRadius(): number;
  91555. /**
  91556. * Sync a bone with this impostor
  91557. * @param bone The bone to sync to the impostor.
  91558. * @param boneMesh The mesh that the bone is influencing.
  91559. * @param jointPivot The pivot of the joint / bone in local space.
  91560. * @param distToJoint Optional distance from the impostor to the joint.
  91561. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91562. */
  91563. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91564. /**
  91565. * Sync impostor to a bone
  91566. * @param bone The bone that the impostor will be synced to.
  91567. * @param boneMesh The mesh that the bone is influencing.
  91568. * @param jointPivot The pivot of the joint / bone in local space.
  91569. * @param distToJoint Optional distance from the impostor to the joint.
  91570. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91571. * @param boneAxis Optional vector3 axis the bone is aligned with
  91572. */
  91573. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91574. /**
  91575. * No-Imposter type
  91576. */
  91577. static NoImpostor: number;
  91578. /**
  91579. * Sphere-Imposter type
  91580. */
  91581. static SphereImpostor: number;
  91582. /**
  91583. * Box-Imposter type
  91584. */
  91585. static BoxImpostor: number;
  91586. /**
  91587. * Plane-Imposter type
  91588. */
  91589. static PlaneImpostor: number;
  91590. /**
  91591. * Mesh-imposter type
  91592. */
  91593. static MeshImpostor: number;
  91594. /**
  91595. * Capsule-Impostor type (Ammo.js plugin only)
  91596. */
  91597. static CapsuleImpostor: number;
  91598. /**
  91599. * Cylinder-Imposter type
  91600. */
  91601. static CylinderImpostor: number;
  91602. /**
  91603. * Particle-Imposter type
  91604. */
  91605. static ParticleImpostor: number;
  91606. /**
  91607. * Heightmap-Imposter type
  91608. */
  91609. static HeightmapImpostor: number;
  91610. /**
  91611. * ConvexHull-Impostor type (Ammo.js plugin only)
  91612. */
  91613. static ConvexHullImpostor: number;
  91614. /**
  91615. * Rope-Imposter type
  91616. */
  91617. static RopeImpostor: number;
  91618. /**
  91619. * Cloth-Imposter type
  91620. */
  91621. static ClothImpostor: number;
  91622. /**
  91623. * Softbody-Imposter type
  91624. */
  91625. static SoftbodyImpostor: number;
  91626. }
  91627. }
  91628. declare module BABYLON {
  91629. /**
  91630. * @hidden
  91631. **/
  91632. export class _CreationDataStorage {
  91633. closePath?: boolean;
  91634. closeArray?: boolean;
  91635. idx: number[];
  91636. dashSize: number;
  91637. gapSize: number;
  91638. path3D: Path3D;
  91639. pathArray: Vector3[][];
  91640. arc: number;
  91641. radius: number;
  91642. cap: number;
  91643. tessellation: number;
  91644. }
  91645. /**
  91646. * @hidden
  91647. **/
  91648. class _InstanceDataStorage {
  91649. visibleInstances: any;
  91650. batchCache: _InstancesBatch;
  91651. instancesBufferSize: number;
  91652. instancesBuffer: Nullable<Buffer>;
  91653. instancesData: Float32Array;
  91654. overridenInstanceCount: number;
  91655. isFrozen: boolean;
  91656. previousBatch: Nullable<_InstancesBatch>;
  91657. hardwareInstancedRendering: boolean;
  91658. sideOrientation: number;
  91659. }
  91660. /**
  91661. * @hidden
  91662. **/
  91663. export class _InstancesBatch {
  91664. mustReturn: boolean;
  91665. visibleInstances: Nullable<InstancedMesh[]>[];
  91666. renderSelf: boolean[];
  91667. hardwareInstancedRendering: boolean[];
  91668. }
  91669. /**
  91670. * Class used to represent renderable models
  91671. */
  91672. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91673. /**
  91674. * Mesh side orientation : usually the external or front surface
  91675. */
  91676. static readonly FRONTSIDE: number;
  91677. /**
  91678. * Mesh side orientation : usually the internal or back surface
  91679. */
  91680. static readonly BACKSIDE: number;
  91681. /**
  91682. * Mesh side orientation : both internal and external or front and back surfaces
  91683. */
  91684. static readonly DOUBLESIDE: number;
  91685. /**
  91686. * Mesh side orientation : by default, `FRONTSIDE`
  91687. */
  91688. static readonly DEFAULTSIDE: number;
  91689. /**
  91690. * Mesh cap setting : no cap
  91691. */
  91692. static readonly NO_CAP: number;
  91693. /**
  91694. * Mesh cap setting : one cap at the beginning of the mesh
  91695. */
  91696. static readonly CAP_START: number;
  91697. /**
  91698. * Mesh cap setting : one cap at the end of the mesh
  91699. */
  91700. static readonly CAP_END: number;
  91701. /**
  91702. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91703. */
  91704. static readonly CAP_ALL: number;
  91705. /**
  91706. * Mesh pattern setting : no flip or rotate
  91707. */
  91708. static readonly NO_FLIP: number;
  91709. /**
  91710. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91711. */
  91712. static readonly FLIP_TILE: number;
  91713. /**
  91714. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91715. */
  91716. static readonly ROTATE_TILE: number;
  91717. /**
  91718. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91719. */
  91720. static readonly FLIP_ROW: number;
  91721. /**
  91722. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91723. */
  91724. static readonly ROTATE_ROW: number;
  91725. /**
  91726. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91727. */
  91728. static readonly FLIP_N_ROTATE_TILE: number;
  91729. /**
  91730. * Mesh pattern setting : rotate pattern and rotate
  91731. */
  91732. static readonly FLIP_N_ROTATE_ROW: number;
  91733. /**
  91734. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91735. */
  91736. static readonly CENTER: number;
  91737. /**
  91738. * Mesh tile positioning : part tiles on left
  91739. */
  91740. static readonly LEFT: number;
  91741. /**
  91742. * Mesh tile positioning : part tiles on right
  91743. */
  91744. static readonly RIGHT: number;
  91745. /**
  91746. * Mesh tile positioning : part tiles on top
  91747. */
  91748. static readonly TOP: number;
  91749. /**
  91750. * Mesh tile positioning : part tiles on bottom
  91751. */
  91752. static readonly BOTTOM: number;
  91753. /**
  91754. * Gets the default side orientation.
  91755. * @param orientation the orientation to value to attempt to get
  91756. * @returns the default orientation
  91757. * @hidden
  91758. */
  91759. static _GetDefaultSideOrientation(orientation?: number): number;
  91760. private _internalMeshDataInfo;
  91761. /**
  91762. * An event triggered before rendering the mesh
  91763. */
  91764. readonly onBeforeRenderObservable: Observable<Mesh>;
  91765. /**
  91766. * An event triggered before binding the mesh
  91767. */
  91768. readonly onBeforeBindObservable: Observable<Mesh>;
  91769. /**
  91770. * An event triggered after rendering the mesh
  91771. */
  91772. readonly onAfterRenderObservable: Observable<Mesh>;
  91773. /**
  91774. * An event triggered before drawing the mesh
  91775. */
  91776. readonly onBeforeDrawObservable: Observable<Mesh>;
  91777. private _onBeforeDrawObserver;
  91778. /**
  91779. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91780. */
  91781. onBeforeDraw: () => void;
  91782. readonly hasInstances: boolean;
  91783. /**
  91784. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91785. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91786. */
  91787. delayLoadState: number;
  91788. /**
  91789. * Gets the list of instances created from this mesh
  91790. * it is not supposed to be modified manually.
  91791. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91792. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91793. */
  91794. instances: InstancedMesh[];
  91795. /**
  91796. * Gets the file containing delay loading data for this mesh
  91797. */
  91798. delayLoadingFile: string;
  91799. /** @hidden */
  91800. _binaryInfo: any;
  91801. /**
  91802. * User defined function used to change how LOD level selection is done
  91803. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91804. */
  91805. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91806. /**
  91807. * Gets or sets the morph target manager
  91808. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91809. */
  91810. morphTargetManager: Nullable<MorphTargetManager>;
  91811. /** @hidden */
  91812. _creationDataStorage: Nullable<_CreationDataStorage>;
  91813. /** @hidden */
  91814. _geometry: Nullable<Geometry>;
  91815. /** @hidden */
  91816. _delayInfo: Array<string>;
  91817. /** @hidden */
  91818. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91819. /** @hidden */
  91820. _instanceDataStorage: _InstanceDataStorage;
  91821. private _effectiveMaterial;
  91822. /** @hidden */
  91823. _shouldGenerateFlatShading: boolean;
  91824. /** @hidden */
  91825. _originalBuilderSideOrientation: number;
  91826. /**
  91827. * Use this property to change the original side orientation defined at construction time
  91828. */
  91829. overrideMaterialSideOrientation: Nullable<number>;
  91830. /**
  91831. * Gets the source mesh (the one used to clone this one from)
  91832. */
  91833. readonly source: Nullable<Mesh>;
  91834. /**
  91835. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91836. */
  91837. isUnIndexed: boolean;
  91838. /**
  91839. * @constructor
  91840. * @param name The value used by scene.getMeshByName() to do a lookup.
  91841. * @param scene The scene to add this mesh to.
  91842. * @param parent The parent of this mesh, if it has one
  91843. * @param source An optional Mesh from which geometry is shared, cloned.
  91844. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91845. * When false, achieved by calling a clone(), also passing False.
  91846. * This will make creation of children, recursive.
  91847. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91848. */
  91849. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91850. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91851. doNotInstantiate: boolean;
  91852. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91853. /**
  91854. * Gets the class name
  91855. * @returns the string "Mesh".
  91856. */
  91857. getClassName(): string;
  91858. /** @hidden */
  91859. readonly _isMesh: boolean;
  91860. /**
  91861. * Returns a description of this mesh
  91862. * @param fullDetails define if full details about this mesh must be used
  91863. * @returns a descriptive string representing this mesh
  91864. */
  91865. toString(fullDetails?: boolean): string;
  91866. /** @hidden */
  91867. _unBindEffect(): void;
  91868. /**
  91869. * Gets a boolean indicating if this mesh has LOD
  91870. */
  91871. readonly hasLODLevels: boolean;
  91872. /**
  91873. * Gets the list of MeshLODLevel associated with the current mesh
  91874. * @returns an array of MeshLODLevel
  91875. */
  91876. getLODLevels(): MeshLODLevel[];
  91877. private _sortLODLevels;
  91878. /**
  91879. * Add a mesh as LOD level triggered at the given distance.
  91880. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91881. * @param distance The distance from the center of the object to show this level
  91882. * @param mesh The mesh to be added as LOD level (can be null)
  91883. * @return This mesh (for chaining)
  91884. */
  91885. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91886. /**
  91887. * Returns the LOD level mesh at the passed distance or null if not found.
  91888. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91889. * @param distance The distance from the center of the object to show this level
  91890. * @returns a Mesh or `null`
  91891. */
  91892. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91893. /**
  91894. * Remove a mesh from the LOD array
  91895. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91896. * @param mesh defines the mesh to be removed
  91897. * @return This mesh (for chaining)
  91898. */
  91899. removeLODLevel(mesh: Mesh): Mesh;
  91900. /**
  91901. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91902. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91903. * @param camera defines the camera to use to compute distance
  91904. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91905. * @return This mesh (for chaining)
  91906. */
  91907. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91908. /**
  91909. * Gets the mesh internal Geometry object
  91910. */
  91911. readonly geometry: Nullable<Geometry>;
  91912. /**
  91913. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91914. * @returns the total number of vertices
  91915. */
  91916. getTotalVertices(): number;
  91917. /**
  91918. * Returns the content of an associated vertex buffer
  91919. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91920. * - VertexBuffer.PositionKind
  91921. * - VertexBuffer.UVKind
  91922. * - VertexBuffer.UV2Kind
  91923. * - VertexBuffer.UV3Kind
  91924. * - VertexBuffer.UV4Kind
  91925. * - VertexBuffer.UV5Kind
  91926. * - VertexBuffer.UV6Kind
  91927. * - VertexBuffer.ColorKind
  91928. * - VertexBuffer.MatricesIndicesKind
  91929. * - VertexBuffer.MatricesIndicesExtraKind
  91930. * - VertexBuffer.MatricesWeightsKind
  91931. * - VertexBuffer.MatricesWeightsExtraKind
  91932. * @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
  91933. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91934. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91935. */
  91936. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91937. /**
  91938. * Returns the mesh VertexBuffer object from the requested `kind`
  91939. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91940. * - VertexBuffer.PositionKind
  91941. * - VertexBuffer.NormalKind
  91942. * - VertexBuffer.UVKind
  91943. * - VertexBuffer.UV2Kind
  91944. * - VertexBuffer.UV3Kind
  91945. * - VertexBuffer.UV4Kind
  91946. * - VertexBuffer.UV5Kind
  91947. * - VertexBuffer.UV6Kind
  91948. * - VertexBuffer.ColorKind
  91949. * - VertexBuffer.MatricesIndicesKind
  91950. * - VertexBuffer.MatricesIndicesExtraKind
  91951. * - VertexBuffer.MatricesWeightsKind
  91952. * - VertexBuffer.MatricesWeightsExtraKind
  91953. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91954. */
  91955. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91956. /**
  91957. * Tests if a specific vertex buffer is associated with this mesh
  91958. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91959. * - VertexBuffer.PositionKind
  91960. * - VertexBuffer.NormalKind
  91961. * - VertexBuffer.UVKind
  91962. * - VertexBuffer.UV2Kind
  91963. * - VertexBuffer.UV3Kind
  91964. * - VertexBuffer.UV4Kind
  91965. * - VertexBuffer.UV5Kind
  91966. * - VertexBuffer.UV6Kind
  91967. * - VertexBuffer.ColorKind
  91968. * - VertexBuffer.MatricesIndicesKind
  91969. * - VertexBuffer.MatricesIndicesExtraKind
  91970. * - VertexBuffer.MatricesWeightsKind
  91971. * - VertexBuffer.MatricesWeightsExtraKind
  91972. * @returns a boolean
  91973. */
  91974. isVerticesDataPresent(kind: string): boolean;
  91975. /**
  91976. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91977. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91978. * - VertexBuffer.PositionKind
  91979. * - VertexBuffer.UVKind
  91980. * - VertexBuffer.UV2Kind
  91981. * - VertexBuffer.UV3Kind
  91982. * - VertexBuffer.UV4Kind
  91983. * - VertexBuffer.UV5Kind
  91984. * - VertexBuffer.UV6Kind
  91985. * - VertexBuffer.ColorKind
  91986. * - VertexBuffer.MatricesIndicesKind
  91987. * - VertexBuffer.MatricesIndicesExtraKind
  91988. * - VertexBuffer.MatricesWeightsKind
  91989. * - VertexBuffer.MatricesWeightsExtraKind
  91990. * @returns a boolean
  91991. */
  91992. isVertexBufferUpdatable(kind: string): boolean;
  91993. /**
  91994. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91995. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91996. * - VertexBuffer.PositionKind
  91997. * - VertexBuffer.NormalKind
  91998. * - VertexBuffer.UVKind
  91999. * - VertexBuffer.UV2Kind
  92000. * - VertexBuffer.UV3Kind
  92001. * - VertexBuffer.UV4Kind
  92002. * - VertexBuffer.UV5Kind
  92003. * - VertexBuffer.UV6Kind
  92004. * - VertexBuffer.ColorKind
  92005. * - VertexBuffer.MatricesIndicesKind
  92006. * - VertexBuffer.MatricesIndicesExtraKind
  92007. * - VertexBuffer.MatricesWeightsKind
  92008. * - VertexBuffer.MatricesWeightsExtraKind
  92009. * @returns an array of strings
  92010. */
  92011. getVerticesDataKinds(): string[];
  92012. /**
  92013. * Returns a positive integer : the total number of indices in this mesh geometry.
  92014. * @returns the numner of indices or zero if the mesh has no geometry.
  92015. */
  92016. getTotalIndices(): number;
  92017. /**
  92018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92019. * @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.
  92020. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92021. * @returns the indices array or an empty array if the mesh has no geometry
  92022. */
  92023. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92024. readonly isBlocked: boolean;
  92025. /**
  92026. * Determine if the current mesh is ready to be rendered
  92027. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92028. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92029. * @returns true if all associated assets are ready (material, textures, shaders)
  92030. */
  92031. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92032. /**
  92033. * 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.
  92034. */
  92035. readonly areNormalsFrozen: boolean;
  92036. /**
  92037. * 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.
  92038. * @returns the current mesh
  92039. */
  92040. freezeNormals(): Mesh;
  92041. /**
  92042. * 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
  92043. * @returns the current mesh
  92044. */
  92045. unfreezeNormals(): Mesh;
  92046. /**
  92047. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92048. */
  92049. overridenInstanceCount: number;
  92050. /** @hidden */
  92051. _preActivate(): Mesh;
  92052. /** @hidden */
  92053. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92054. /** @hidden */
  92055. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92056. /**
  92057. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92058. * This means the mesh underlying bounding box and sphere are recomputed.
  92059. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92060. * @returns the current mesh
  92061. */
  92062. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92063. /** @hidden */
  92064. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92065. /**
  92066. * This function will subdivide the mesh into multiple submeshes
  92067. * @param count defines the expected number of submeshes
  92068. */
  92069. subdivide(count: number): void;
  92070. /**
  92071. * Copy a FloatArray into a specific associated vertex buffer
  92072. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92073. * - VertexBuffer.PositionKind
  92074. * - VertexBuffer.UVKind
  92075. * - VertexBuffer.UV2Kind
  92076. * - VertexBuffer.UV3Kind
  92077. * - VertexBuffer.UV4Kind
  92078. * - VertexBuffer.UV5Kind
  92079. * - VertexBuffer.UV6Kind
  92080. * - VertexBuffer.ColorKind
  92081. * - VertexBuffer.MatricesIndicesKind
  92082. * - VertexBuffer.MatricesIndicesExtraKind
  92083. * - VertexBuffer.MatricesWeightsKind
  92084. * - VertexBuffer.MatricesWeightsExtraKind
  92085. * @param data defines the data source
  92086. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92087. * @param stride defines the data stride size (can be null)
  92088. * @returns the current mesh
  92089. */
  92090. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92091. /**
  92092. * Delete a vertex buffer associated with this mesh
  92093. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92094. * - VertexBuffer.PositionKind
  92095. * - VertexBuffer.UVKind
  92096. * - VertexBuffer.UV2Kind
  92097. * - VertexBuffer.UV3Kind
  92098. * - VertexBuffer.UV4Kind
  92099. * - VertexBuffer.UV5Kind
  92100. * - VertexBuffer.UV6Kind
  92101. * - VertexBuffer.ColorKind
  92102. * - VertexBuffer.MatricesIndicesKind
  92103. * - VertexBuffer.MatricesIndicesExtraKind
  92104. * - VertexBuffer.MatricesWeightsKind
  92105. * - VertexBuffer.MatricesWeightsExtraKind
  92106. */
  92107. removeVerticesData(kind: string): void;
  92108. /**
  92109. * Flags an associated vertex buffer as updatable
  92110. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92111. * - VertexBuffer.PositionKind
  92112. * - VertexBuffer.UVKind
  92113. * - VertexBuffer.UV2Kind
  92114. * - VertexBuffer.UV3Kind
  92115. * - VertexBuffer.UV4Kind
  92116. * - VertexBuffer.UV5Kind
  92117. * - VertexBuffer.UV6Kind
  92118. * - VertexBuffer.ColorKind
  92119. * - VertexBuffer.MatricesIndicesKind
  92120. * - VertexBuffer.MatricesIndicesExtraKind
  92121. * - VertexBuffer.MatricesWeightsKind
  92122. * - VertexBuffer.MatricesWeightsExtraKind
  92123. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92124. */
  92125. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92126. /**
  92127. * Sets the mesh global Vertex Buffer
  92128. * @param buffer defines the buffer to use
  92129. * @returns the current mesh
  92130. */
  92131. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92132. /**
  92133. * Update a specific associated vertex buffer
  92134. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92135. * - VertexBuffer.PositionKind
  92136. * - VertexBuffer.UVKind
  92137. * - VertexBuffer.UV2Kind
  92138. * - VertexBuffer.UV3Kind
  92139. * - VertexBuffer.UV4Kind
  92140. * - VertexBuffer.UV5Kind
  92141. * - VertexBuffer.UV6Kind
  92142. * - VertexBuffer.ColorKind
  92143. * - VertexBuffer.MatricesIndicesKind
  92144. * - VertexBuffer.MatricesIndicesExtraKind
  92145. * - VertexBuffer.MatricesWeightsKind
  92146. * - VertexBuffer.MatricesWeightsExtraKind
  92147. * @param data defines the data source
  92148. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92149. * @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)
  92150. * @returns the current mesh
  92151. */
  92152. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92153. /**
  92154. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92155. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92156. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92157. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92158. * @returns the current mesh
  92159. */
  92160. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92161. /**
  92162. * Creates a un-shared specific occurence of the geometry for the mesh.
  92163. * @returns the current mesh
  92164. */
  92165. makeGeometryUnique(): Mesh;
  92166. /**
  92167. * Set the index buffer of this mesh
  92168. * @param indices defines the source data
  92169. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92170. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92171. * @returns the current mesh
  92172. */
  92173. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92174. /**
  92175. * Update the current index buffer
  92176. * @param indices defines the source data
  92177. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92178. * @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)
  92179. * @returns the current mesh
  92180. */
  92181. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92182. /**
  92183. * Invert the geometry to move from a right handed system to a left handed one.
  92184. * @returns the current mesh
  92185. */
  92186. toLeftHanded(): Mesh;
  92187. /** @hidden */
  92188. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92189. /** @hidden */
  92190. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92191. /**
  92192. * Registers for this mesh a javascript function called just before the rendering process
  92193. * @param func defines the function to call before rendering this mesh
  92194. * @returns the current mesh
  92195. */
  92196. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92197. /**
  92198. * Disposes a previously registered javascript function called before the rendering
  92199. * @param func defines the function to remove
  92200. * @returns the current mesh
  92201. */
  92202. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92203. /**
  92204. * Registers for this mesh a javascript function called just after the rendering is complete
  92205. * @param func defines the function to call after rendering this mesh
  92206. * @returns the current mesh
  92207. */
  92208. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92209. /**
  92210. * Disposes a previously registered javascript function called after the rendering.
  92211. * @param func defines the function to remove
  92212. * @returns the current mesh
  92213. */
  92214. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92215. /** @hidden */
  92216. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92217. /** @hidden */
  92218. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92219. /** @hidden */
  92220. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92221. /** @hidden */
  92222. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92223. /** @hidden */
  92224. _rebuild(): void;
  92225. /** @hidden */
  92226. _freeze(): void;
  92227. /** @hidden */
  92228. _unFreeze(): void;
  92229. /**
  92230. * 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
  92231. * @param subMesh defines the subMesh to render
  92232. * @param enableAlphaMode defines if alpha mode can be changed
  92233. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92234. * @returns the current mesh
  92235. */
  92236. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92237. private _onBeforeDraw;
  92238. /**
  92239. * Renormalize the mesh and patch it up if there are no weights
  92240. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92241. * However in the case of zero weights then we set just a single influence to 1.
  92242. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92243. */
  92244. cleanMatrixWeights(): void;
  92245. private normalizeSkinFourWeights;
  92246. private normalizeSkinWeightsAndExtra;
  92247. /**
  92248. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92249. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92250. * the user know there was an issue with importing the mesh
  92251. * @returns a validation object with skinned, valid and report string
  92252. */
  92253. validateSkinning(): {
  92254. skinned: boolean;
  92255. valid: boolean;
  92256. report: string;
  92257. };
  92258. /** @hidden */
  92259. _checkDelayState(): Mesh;
  92260. private _queueLoad;
  92261. /**
  92262. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92263. * A mesh is in the frustum if its bounding box intersects the frustum
  92264. * @param frustumPlanes defines the frustum to test
  92265. * @returns true if the mesh is in the frustum planes
  92266. */
  92267. isInFrustum(frustumPlanes: Plane[]): boolean;
  92268. /**
  92269. * Sets the mesh material by the material or multiMaterial `id` property
  92270. * @param id is a string identifying the material or the multiMaterial
  92271. * @returns the current mesh
  92272. */
  92273. setMaterialByID(id: string): Mesh;
  92274. /**
  92275. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92276. * @returns an array of IAnimatable
  92277. */
  92278. getAnimatables(): IAnimatable[];
  92279. /**
  92280. * Modifies the mesh geometry according to the passed transformation matrix.
  92281. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92282. * The mesh normals are modified using the same transformation.
  92283. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92284. * @param transform defines the transform matrix to use
  92285. * @see http://doc.babylonjs.com/resources/baking_transformations
  92286. * @returns the current mesh
  92287. */
  92288. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92289. /**
  92290. * Modifies the mesh geometry according to its own current World Matrix.
  92291. * The mesh World Matrix is then reset.
  92292. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92293. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92294. * @see http://doc.babylonjs.com/resources/baking_transformations
  92295. * @returns the current mesh
  92296. */
  92297. bakeCurrentTransformIntoVertices(): Mesh;
  92298. /** @hidden */
  92299. readonly _positions: Nullable<Vector3[]>;
  92300. /** @hidden */
  92301. _resetPointsArrayCache(): Mesh;
  92302. /** @hidden */
  92303. _generatePointsArray(): boolean;
  92304. /**
  92305. * Returns a new Mesh object generated from the current mesh properties.
  92306. * This method must not get confused with createInstance()
  92307. * @param name is a string, the name given to the new mesh
  92308. * @param newParent can be any Node object (default `null`)
  92309. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92310. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92311. * @returns a new mesh
  92312. */
  92313. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92314. /**
  92315. * Releases resources associated with this mesh.
  92316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92318. */
  92319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92320. /** @hidden */
  92321. _disposeInstanceSpecificData(): void;
  92322. /**
  92323. * Modifies the mesh geometry according to a displacement map.
  92324. * 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.
  92325. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92326. * @param url is a string, the URL from the image file is to be downloaded.
  92327. * @param minHeight is the lower limit of the displacement.
  92328. * @param maxHeight is the upper limit of the displacement.
  92329. * @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.
  92330. * @param uvOffset is an optional vector2 used to offset UV.
  92331. * @param uvScale is an optional vector2 used to scale UV.
  92332. * @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.
  92333. * @returns the Mesh.
  92334. */
  92335. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92336. /**
  92337. * Modifies the mesh geometry according to a displacementMap buffer.
  92338. * 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.
  92339. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92340. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92341. * @param heightMapWidth is the width of the buffer image.
  92342. * @param heightMapHeight is the height of the buffer image.
  92343. * @param minHeight is the lower limit of the displacement.
  92344. * @param maxHeight is the upper limit of the displacement.
  92345. * @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.
  92346. * @param uvOffset is an optional vector2 used to offset UV.
  92347. * @param uvScale is an optional vector2 used to scale UV.
  92348. * @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.
  92349. * @returns the Mesh.
  92350. */
  92351. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92352. /**
  92353. * Modify the mesh to get a flat shading rendering.
  92354. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92355. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92356. * @returns current mesh
  92357. */
  92358. convertToFlatShadedMesh(): Mesh;
  92359. /**
  92360. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92361. * In other words, more vertices, no more indices and a single bigger VBO.
  92362. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92363. * @returns current mesh
  92364. */
  92365. convertToUnIndexedMesh(): Mesh;
  92366. /**
  92367. * Inverses facet orientations.
  92368. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92369. * @param flipNormals will also inverts the normals
  92370. * @returns current mesh
  92371. */
  92372. flipFaces(flipNormals?: boolean): Mesh;
  92373. /**
  92374. * Increase the number of facets and hence vertices in a mesh
  92375. * Vertex normals are interpolated from existing vertex normals
  92376. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92377. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92378. */
  92379. increaseVertices(numberPerEdge: number): void;
  92380. /**
  92381. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92382. * This will undo any application of covertToFlatShadedMesh
  92383. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92384. */
  92385. forceSharedVertices(): void;
  92386. /** @hidden */
  92387. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92388. /** @hidden */
  92389. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92390. /**
  92391. * Creates a new InstancedMesh object from the mesh model.
  92392. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92393. * @param name defines the name of the new instance
  92394. * @returns a new InstancedMesh
  92395. */
  92396. createInstance(name: string): InstancedMesh;
  92397. /**
  92398. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92399. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92400. * @returns the current mesh
  92401. */
  92402. synchronizeInstances(): Mesh;
  92403. /**
  92404. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92405. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92406. * This should be used together with the simplification to avoid disappearing triangles.
  92407. * @param successCallback an optional success callback to be called after the optimization finished.
  92408. * @returns the current mesh
  92409. */
  92410. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92411. /**
  92412. * Serialize current mesh
  92413. * @param serializationObject defines the object which will receive the serialization data
  92414. */
  92415. serialize(serializationObject: any): void;
  92416. /** @hidden */
  92417. _syncGeometryWithMorphTargetManager(): void;
  92418. /** @hidden */
  92419. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92420. /**
  92421. * Returns a new Mesh object parsed from the source provided.
  92422. * @param parsedMesh is the source
  92423. * @param scene defines the hosting scene
  92424. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92425. * @returns a new Mesh
  92426. */
  92427. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92428. /**
  92429. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92430. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92431. * @param name defines the name of the mesh to create
  92432. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92433. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92434. * @param closePath creates a seam between the first and the last points of each path of the path array
  92435. * @param offset is taken in account only if the `pathArray` is containing a single path
  92436. * @param scene defines the hosting scene
  92437. * @param updatable defines if the mesh must be flagged as updatable
  92438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92439. * @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)
  92440. * @returns a new Mesh
  92441. */
  92442. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92443. /**
  92444. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92445. * @param name defines the name of the mesh to create
  92446. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92447. * @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
  92448. * @param scene defines the hosting scene
  92449. * @param updatable defines if the mesh must be flagged as updatable
  92450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92451. * @returns a new Mesh
  92452. */
  92453. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92454. /**
  92455. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92456. * @param name defines the name of the mesh to create
  92457. * @param size sets the size (float) of each box side (default 1)
  92458. * @param scene defines the hosting scene
  92459. * @param updatable defines if the mesh must be flagged as updatable
  92460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92461. * @returns a new Mesh
  92462. */
  92463. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92464. /**
  92465. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92466. * @param name defines the name of the mesh to create
  92467. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92468. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92469. * @param scene defines the hosting scene
  92470. * @param updatable defines if the mesh must be flagged as updatable
  92471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92472. * @returns a new Mesh
  92473. */
  92474. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92475. /**
  92476. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92477. * @param name defines the name of the mesh to create
  92478. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92479. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92480. * @param scene defines the hosting scene
  92481. * @returns a new Mesh
  92482. */
  92483. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92484. /**
  92485. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92486. * @param name defines the name of the mesh to create
  92487. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92488. * @param diameterTop set the top cap diameter (floats, default 1)
  92489. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92490. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92491. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92492. * @param scene defines the hosting scene
  92493. * @param updatable defines if the mesh must be flagged as updatable
  92494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92495. * @returns a new Mesh
  92496. */
  92497. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92498. /**
  92499. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92500. * @param name defines the name of the mesh to create
  92501. * @param diameter sets the diameter size (float) of the torus (default 1)
  92502. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92503. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92504. * @param scene defines the hosting scene
  92505. * @param updatable defines if the mesh must be flagged as updatable
  92506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92507. * @returns a new Mesh
  92508. */
  92509. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92510. /**
  92511. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92512. * @param name defines the name of the mesh to create
  92513. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92514. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92515. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92516. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92517. * @param p the number of windings on X axis (positive integers, default 2)
  92518. * @param q the number of windings on Y axis (positive integers, default 3)
  92519. * @param scene defines the hosting scene
  92520. * @param updatable defines if the mesh must be flagged as updatable
  92521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92522. * @returns a new Mesh
  92523. */
  92524. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92525. /**
  92526. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92527. * @param name defines the name of the mesh to create
  92528. * @param points is an array successive Vector3
  92529. * @param scene defines the hosting scene
  92530. * @param updatable defines if the mesh must be flagged as updatable
  92531. * @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).
  92532. * @returns a new Mesh
  92533. */
  92534. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92535. /**
  92536. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92537. * @param name defines the name of the mesh to create
  92538. * @param points is an array successive Vector3
  92539. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92540. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92541. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92542. * @param scene defines the hosting scene
  92543. * @param updatable defines if the mesh must be flagged as updatable
  92544. * @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)
  92545. * @returns a new Mesh
  92546. */
  92547. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92548. /**
  92549. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92550. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92551. * 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.
  92552. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92553. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92554. * Remember you can only change the shape positions, not their number when updating a polygon.
  92555. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92556. * @param name defines the name of the mesh to create
  92557. * @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
  92558. * @param scene defines the hosting scene
  92559. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92560. * @param updatable defines if the mesh must be flagged as updatable
  92561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92562. * @param earcutInjection can be used to inject your own earcut reference
  92563. * @returns a new Mesh
  92564. */
  92565. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92566. /**
  92567. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92568. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92569. * @param name defines the name of the mesh to create
  92570. * @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
  92571. * @param depth defines the height of extrusion
  92572. * @param scene defines the hosting scene
  92573. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92574. * @param updatable defines if the mesh must be flagged as updatable
  92575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92576. * @param earcutInjection can be used to inject your own earcut reference
  92577. * @returns a new Mesh
  92578. */
  92579. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92580. /**
  92581. * Creates an extruded shape mesh.
  92582. * 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
  92583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92584. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92585. * @param name defines the name of the mesh to create
  92586. * @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
  92587. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92588. * @param scale is the value to scale the shape
  92589. * @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
  92590. * @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
  92591. * @param scene defines the hosting scene
  92592. * @param updatable defines if the mesh must be flagged as updatable
  92593. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92594. * @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)
  92595. * @returns a new Mesh
  92596. */
  92597. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92598. /**
  92599. * Creates an custom extruded shape mesh.
  92600. * The custom extrusion is a parametric shape.
  92601. * It has no predefined shape. Its final shape will depend on the input parameters.
  92602. * Please consider using the same method from the MeshBuilder class instead
  92603. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92604. * @param name defines the name of the mesh to create
  92605. * @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
  92606. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92607. * @param scaleFunction is a custom Javascript function called on each path point
  92608. * @param rotationFunction is a custom Javascript function called on each path point
  92609. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92610. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92611. * @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
  92612. * @param scene defines the hosting scene
  92613. * @param updatable defines if the mesh must be flagged as updatable
  92614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92615. * @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)
  92616. * @returns a new Mesh
  92617. */
  92618. 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;
  92619. /**
  92620. * Creates lathe mesh.
  92621. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92622. * Please consider using the same method from the MeshBuilder class instead
  92623. * @param name defines the name of the mesh to create
  92624. * @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
  92625. * @param radius is the radius value of the lathe
  92626. * @param tessellation is the side number of the lathe.
  92627. * @param scene defines the hosting scene
  92628. * @param updatable defines if the mesh must be flagged as updatable
  92629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92630. * @returns a new Mesh
  92631. */
  92632. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92633. /**
  92634. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92635. * @param name defines the name of the mesh to create
  92636. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92637. * @param scene defines the hosting scene
  92638. * @param updatable defines if the mesh must be flagged as updatable
  92639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92640. * @returns a new Mesh
  92641. */
  92642. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92643. /**
  92644. * Creates a ground mesh.
  92645. * Please consider using the same method from the MeshBuilder class instead
  92646. * @param name defines the name of the mesh to create
  92647. * @param width set the width of the ground
  92648. * @param height set the height of the ground
  92649. * @param subdivisions sets the number of subdivisions per side
  92650. * @param scene defines the hosting scene
  92651. * @param updatable defines if the mesh must be flagged as updatable
  92652. * @returns a new Mesh
  92653. */
  92654. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92655. /**
  92656. * Creates a tiled ground mesh.
  92657. * Please consider using the same method from the MeshBuilder class instead
  92658. * @param name defines the name of the mesh to create
  92659. * @param xmin set the ground minimum X coordinate
  92660. * @param zmin set the ground minimum Y coordinate
  92661. * @param xmax set the ground maximum X coordinate
  92662. * @param zmax set the ground maximum Z coordinate
  92663. * @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
  92664. * @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
  92665. * @param scene defines the hosting scene
  92666. * @param updatable defines if the mesh must be flagged as updatable
  92667. * @returns a new Mesh
  92668. */
  92669. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92670. w: number;
  92671. h: number;
  92672. }, precision: {
  92673. w: number;
  92674. h: number;
  92675. }, scene: Scene, updatable?: boolean): Mesh;
  92676. /**
  92677. * Creates a ground mesh from a height map.
  92678. * Please consider using the same method from the MeshBuilder class instead
  92679. * @see http://doc.babylonjs.com/babylon101/height_map
  92680. * @param name defines the name of the mesh to create
  92681. * @param url sets the URL of the height map image resource
  92682. * @param width set the ground width size
  92683. * @param height set the ground height size
  92684. * @param subdivisions sets the number of subdivision per side
  92685. * @param minHeight is the minimum altitude on the ground
  92686. * @param maxHeight is the maximum altitude on the ground
  92687. * @param scene defines the hosting scene
  92688. * @param updatable defines if the mesh must be flagged as updatable
  92689. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92690. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92691. * @returns a new Mesh
  92692. */
  92693. 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;
  92694. /**
  92695. * Creates a tube mesh.
  92696. * The tube is a parametric shape.
  92697. * It has no predefined shape. Its final shape will depend on the input parameters.
  92698. * Please consider using the same method from the MeshBuilder class instead
  92699. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92700. * @param name defines the name of the mesh to create
  92701. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92702. * @param radius sets the tube radius size
  92703. * @param tessellation is the number of sides on the tubular surface
  92704. * @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
  92705. * @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
  92706. * @param scene defines the hosting scene
  92707. * @param updatable defines if the mesh must be flagged as updatable
  92708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92709. * @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)
  92710. * @returns a new Mesh
  92711. */
  92712. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92713. (i: number, distance: number): number;
  92714. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92715. /**
  92716. * Creates a polyhedron mesh.
  92717. * Please consider using the same method from the MeshBuilder class instead.
  92718. * * 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
  92719. * * The parameter `size` (positive float, default 1) sets the polygon size
  92720. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92721. * * 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`
  92722. * * 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
  92723. * * 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)`)
  92724. * * 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
  92725. * * 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
  92726. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92727. * * If you create a double-sided mesh, you can choose what parts of 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
  92728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92729. * @param name defines the name of the mesh to create
  92730. * @param options defines the options used to create the mesh
  92731. * @param scene defines the hosting scene
  92732. * @returns a new Mesh
  92733. */
  92734. static CreatePolyhedron(name: string, options: {
  92735. type?: number;
  92736. size?: number;
  92737. sizeX?: number;
  92738. sizeY?: number;
  92739. sizeZ?: number;
  92740. custom?: any;
  92741. faceUV?: Vector4[];
  92742. faceColors?: Color4[];
  92743. updatable?: boolean;
  92744. sideOrientation?: number;
  92745. }, scene: Scene): Mesh;
  92746. /**
  92747. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92748. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92749. * * 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`)
  92750. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92751. * * 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
  92752. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92753. * * If you create a double-sided mesh, you can choose what parts of 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
  92754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92755. * @param name defines the name of the mesh
  92756. * @param options defines the options used to create the mesh
  92757. * @param scene defines the hosting scene
  92758. * @returns a new Mesh
  92759. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92760. */
  92761. static CreateIcoSphere(name: string, options: {
  92762. radius?: number;
  92763. flat?: boolean;
  92764. subdivisions?: number;
  92765. sideOrientation?: number;
  92766. updatable?: boolean;
  92767. }, scene: Scene): Mesh;
  92768. /**
  92769. * Creates a decal mesh.
  92770. * Please consider using the same method from the MeshBuilder class instead.
  92771. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92772. * @param name defines the name of the mesh
  92773. * @param sourceMesh defines the mesh receiving the decal
  92774. * @param position sets the position of the decal in world coordinates
  92775. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92776. * @param size sets the decal scaling
  92777. * @param angle sets the angle to rotate the decal
  92778. * @returns a new Mesh
  92779. */
  92780. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92781. /**
  92782. * Prepare internal position array for software CPU skinning
  92783. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92784. */
  92785. setPositionsForCPUSkinning(): Float32Array;
  92786. /**
  92787. * Prepare internal normal array for software CPU skinning
  92788. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92789. */
  92790. setNormalsForCPUSkinning(): Float32Array;
  92791. /**
  92792. * Updates the vertex buffer by applying transformation from the bones
  92793. * @param skeleton defines the skeleton to apply to current mesh
  92794. * @returns the current mesh
  92795. */
  92796. applySkeleton(skeleton: Skeleton): Mesh;
  92797. /**
  92798. * 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
  92799. * @param meshes defines the list of meshes to scan
  92800. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92801. */
  92802. static MinMax(meshes: AbstractMesh[]): {
  92803. min: Vector3;
  92804. max: Vector3;
  92805. };
  92806. /**
  92807. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92808. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92809. * @returns a vector3
  92810. */
  92811. static Center(meshesOrMinMaxVector: {
  92812. min: Vector3;
  92813. max: Vector3;
  92814. } | AbstractMesh[]): Vector3;
  92815. /**
  92816. * Merge the array of meshes into a single mesh for performance reasons.
  92817. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92818. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92819. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92820. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92821. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92822. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92823. * @returns a new mesh
  92824. */
  92825. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92826. /** @hidden */
  92827. addInstance(instance: InstancedMesh): void;
  92828. /** @hidden */
  92829. removeInstance(instance: InstancedMesh): void;
  92830. }
  92831. }
  92832. declare module BABYLON {
  92833. /**
  92834. * This is the base class of all the camera used in the application.
  92835. * @see http://doc.babylonjs.com/features/cameras
  92836. */
  92837. export class Camera extends Node {
  92838. /** @hidden */
  92839. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92840. /**
  92841. * This is the default projection mode used by the cameras.
  92842. * It helps recreating a feeling of perspective and better appreciate depth.
  92843. * This is the best way to simulate real life cameras.
  92844. */
  92845. static readonly PERSPECTIVE_CAMERA: number;
  92846. /**
  92847. * This helps creating camera with an orthographic mode.
  92848. * 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.
  92849. */
  92850. static readonly ORTHOGRAPHIC_CAMERA: number;
  92851. /**
  92852. * This is the default FOV mode for perspective cameras.
  92853. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92854. */
  92855. static readonly FOVMODE_VERTICAL_FIXED: number;
  92856. /**
  92857. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92858. */
  92859. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92860. /**
  92861. * This specifies ther is no need for a camera rig.
  92862. * Basically only one eye is rendered corresponding to the camera.
  92863. */
  92864. static readonly RIG_MODE_NONE: number;
  92865. /**
  92866. * Simulates a camera Rig with one blue eye and one red eye.
  92867. * This can be use with 3d blue and red glasses.
  92868. */
  92869. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92870. /**
  92871. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92872. */
  92873. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92874. /**
  92875. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92876. */
  92877. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92878. /**
  92879. * Defines that both eyes of the camera will be rendered over under each other.
  92880. */
  92881. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92882. /**
  92883. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92884. */
  92885. static readonly RIG_MODE_VR: number;
  92886. /**
  92887. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92888. */
  92889. static readonly RIG_MODE_WEBVR: number;
  92890. /**
  92891. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92892. */
  92893. static readonly RIG_MODE_CUSTOM: number;
  92894. /**
  92895. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92896. */
  92897. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92898. /**
  92899. * Define the input manager associated with the camera.
  92900. */
  92901. inputs: CameraInputsManager<Camera>;
  92902. /** @hidden */
  92903. _position: Vector3;
  92904. /**
  92905. * Define the current local position of the camera in the scene
  92906. */
  92907. position: Vector3;
  92908. /**
  92909. * The vector the camera should consider as up.
  92910. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92911. */
  92912. upVector: Vector3;
  92913. /**
  92914. * Define the current limit on the left side for an orthographic camera
  92915. * In scene unit
  92916. */
  92917. orthoLeft: Nullable<number>;
  92918. /**
  92919. * Define the current limit on the right side for an orthographic camera
  92920. * In scene unit
  92921. */
  92922. orthoRight: Nullable<number>;
  92923. /**
  92924. * Define the current limit on the bottom side for an orthographic camera
  92925. * In scene unit
  92926. */
  92927. orthoBottom: Nullable<number>;
  92928. /**
  92929. * Define the current limit on the top side for an orthographic camera
  92930. * In scene unit
  92931. */
  92932. orthoTop: Nullable<number>;
  92933. /**
  92934. * Field Of View is set in Radians. (default is 0.8)
  92935. */
  92936. fov: number;
  92937. /**
  92938. * Define the minimum distance the camera can see from.
  92939. * This is important to note that the depth buffer are not infinite and the closer it starts
  92940. * the more your scene might encounter depth fighting issue.
  92941. */
  92942. minZ: number;
  92943. /**
  92944. * Define the maximum distance the camera can see to.
  92945. * This is important to note that the depth buffer are not infinite and the further it end
  92946. * the more your scene might encounter depth fighting issue.
  92947. */
  92948. maxZ: number;
  92949. /**
  92950. * Define the default inertia of the camera.
  92951. * This helps giving a smooth feeling to the camera movement.
  92952. */
  92953. inertia: number;
  92954. /**
  92955. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92956. */
  92957. mode: number;
  92958. /**
  92959. * Define wether the camera is intermediate.
  92960. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92961. */
  92962. isIntermediate: boolean;
  92963. /**
  92964. * Define the viewport of the camera.
  92965. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92966. */
  92967. viewport: Viewport;
  92968. /**
  92969. * Restricts the camera to viewing objects with the same layerMask.
  92970. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92971. */
  92972. layerMask: number;
  92973. /**
  92974. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92975. */
  92976. fovMode: number;
  92977. /**
  92978. * Rig mode of the camera.
  92979. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92980. * This is normally controlled byt the camera themselves as internal use.
  92981. */
  92982. cameraRigMode: number;
  92983. /**
  92984. * Defines the distance between both "eyes" in case of a RIG
  92985. */
  92986. interaxialDistance: number;
  92987. /**
  92988. * Defines if stereoscopic rendering is done side by side or over under.
  92989. */
  92990. isStereoscopicSideBySide: boolean;
  92991. /**
  92992. * 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
  92993. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92994. * else in the scene. (Eg. security camera)
  92995. *
  92996. * 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)
  92997. */
  92998. customRenderTargets: RenderTargetTexture[];
  92999. /**
  93000. * When set, the camera will render to this render target instead of the default canvas
  93001. *
  93002. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93003. */
  93004. outputRenderTarget: Nullable<RenderTargetTexture>;
  93005. /**
  93006. * Observable triggered when the camera view matrix has changed.
  93007. */
  93008. onViewMatrixChangedObservable: Observable<Camera>;
  93009. /**
  93010. * Observable triggered when the camera Projection matrix has changed.
  93011. */
  93012. onProjectionMatrixChangedObservable: Observable<Camera>;
  93013. /**
  93014. * Observable triggered when the inputs have been processed.
  93015. */
  93016. onAfterCheckInputsObservable: Observable<Camera>;
  93017. /**
  93018. * Observable triggered when reset has been called and applied to the camera.
  93019. */
  93020. onRestoreStateObservable: Observable<Camera>;
  93021. /** @hidden */
  93022. _cameraRigParams: any;
  93023. /** @hidden */
  93024. _rigCameras: Camera[];
  93025. /** @hidden */
  93026. _rigPostProcess: Nullable<PostProcess>;
  93027. protected _webvrViewMatrix: Matrix;
  93028. /** @hidden */
  93029. _skipRendering: boolean;
  93030. /** @hidden */
  93031. _projectionMatrix: Matrix;
  93032. /** @hidden */
  93033. _postProcesses: Nullable<PostProcess>[];
  93034. /** @hidden */
  93035. _activeMeshes: SmartArray<AbstractMesh>;
  93036. protected _globalPosition: Vector3;
  93037. /** @hidden */
  93038. _computedViewMatrix: Matrix;
  93039. private _doNotComputeProjectionMatrix;
  93040. private _transformMatrix;
  93041. private _frustumPlanes;
  93042. private _refreshFrustumPlanes;
  93043. private _storedFov;
  93044. private _stateStored;
  93045. /**
  93046. * Instantiates a new camera object.
  93047. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93048. * @see http://doc.babylonjs.com/features/cameras
  93049. * @param name Defines the name of the camera in the scene
  93050. * @param position Defines the position of the camera
  93051. * @param scene Defines the scene the camera belongs too
  93052. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93053. */
  93054. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93055. /**
  93056. * Store current camera state (fov, position, etc..)
  93057. * @returns the camera
  93058. */
  93059. storeState(): Camera;
  93060. /**
  93061. * Restores the camera state values if it has been stored. You must call storeState() first
  93062. */
  93063. protected _restoreStateValues(): boolean;
  93064. /**
  93065. * Restored camera state. You must call storeState() first.
  93066. * @returns true if restored and false otherwise
  93067. */
  93068. restoreState(): boolean;
  93069. /**
  93070. * Gets the class name of the camera.
  93071. * @returns the class name
  93072. */
  93073. getClassName(): string;
  93074. /** @hidden */
  93075. readonly _isCamera: boolean;
  93076. /**
  93077. * Gets a string representation of the camera useful for debug purpose.
  93078. * @param fullDetails Defines that a more verboe level of logging is required
  93079. * @returns the string representation
  93080. */
  93081. toString(fullDetails?: boolean): string;
  93082. /**
  93083. * Gets the current world space position of the camera.
  93084. */
  93085. readonly globalPosition: Vector3;
  93086. /**
  93087. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93088. * @returns the active meshe list
  93089. */
  93090. getActiveMeshes(): SmartArray<AbstractMesh>;
  93091. /**
  93092. * Check wether a mesh is part of the current active mesh list of the camera
  93093. * @param mesh Defines the mesh to check
  93094. * @returns true if active, false otherwise
  93095. */
  93096. isActiveMesh(mesh: Mesh): boolean;
  93097. /**
  93098. * Is this camera ready to be used/rendered
  93099. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93100. * @return true if the camera is ready
  93101. */
  93102. isReady(completeCheck?: boolean): boolean;
  93103. /** @hidden */
  93104. _initCache(): void;
  93105. /** @hidden */
  93106. _updateCache(ignoreParentClass?: boolean): void;
  93107. /** @hidden */
  93108. _isSynchronized(): boolean;
  93109. /** @hidden */
  93110. _isSynchronizedViewMatrix(): boolean;
  93111. /** @hidden */
  93112. _isSynchronizedProjectionMatrix(): boolean;
  93113. /**
  93114. * Attach the input controls to a specific dom element to get the input from.
  93115. * @param element Defines the element the controls should be listened from
  93116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93117. */
  93118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93119. /**
  93120. * Detach the current controls from the specified dom element.
  93121. * @param element Defines the element to stop listening the inputs from
  93122. */
  93123. detachControl(element: HTMLElement): void;
  93124. /**
  93125. * Update the camera state according to the different inputs gathered during the frame.
  93126. */
  93127. update(): void;
  93128. /** @hidden */
  93129. _checkInputs(): void;
  93130. /** @hidden */
  93131. readonly rigCameras: Camera[];
  93132. /**
  93133. * Gets the post process used by the rig cameras
  93134. */
  93135. readonly rigPostProcess: Nullable<PostProcess>;
  93136. /**
  93137. * Internal, gets the first post proces.
  93138. * @returns the first post process to be run on this camera.
  93139. */
  93140. _getFirstPostProcess(): Nullable<PostProcess>;
  93141. private _cascadePostProcessesToRigCams;
  93142. /**
  93143. * Attach a post process to the camera.
  93144. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93145. * @param postProcess The post process to attach to the camera
  93146. * @param insertAt The position of the post process in case several of them are in use in the scene
  93147. * @returns the position the post process has been inserted at
  93148. */
  93149. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93150. /**
  93151. * Detach a post process to the camera.
  93152. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93153. * @param postProcess The post process to detach from the camera
  93154. */
  93155. detachPostProcess(postProcess: PostProcess): void;
  93156. /**
  93157. * Gets the current world matrix of the camera
  93158. */
  93159. getWorldMatrix(): Matrix;
  93160. /** @hidden */
  93161. _getViewMatrix(): Matrix;
  93162. /**
  93163. * Gets the current view matrix of the camera.
  93164. * @param force forces the camera to recompute the matrix without looking at the cached state
  93165. * @returns the view matrix
  93166. */
  93167. getViewMatrix(force?: boolean): Matrix;
  93168. /**
  93169. * Freeze the projection matrix.
  93170. * It will prevent the cache check of the camera projection compute and can speed up perf
  93171. * if no parameter of the camera are meant to change
  93172. * @param projection Defines manually a projection if necessary
  93173. */
  93174. freezeProjectionMatrix(projection?: Matrix): void;
  93175. /**
  93176. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93177. */
  93178. unfreezeProjectionMatrix(): void;
  93179. /**
  93180. * Gets the current projection matrix of the camera.
  93181. * @param force forces the camera to recompute the matrix without looking at the cached state
  93182. * @returns the projection matrix
  93183. */
  93184. getProjectionMatrix(force?: boolean): Matrix;
  93185. /**
  93186. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93187. * @returns a Matrix
  93188. */
  93189. getTransformationMatrix(): Matrix;
  93190. private _updateFrustumPlanes;
  93191. /**
  93192. * Checks if a cullable object (mesh...) is in the camera frustum
  93193. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93194. * @param target The object to check
  93195. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93196. * @returns true if the object is in frustum otherwise false
  93197. */
  93198. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93199. /**
  93200. * Checks if a cullable object (mesh...) is in the camera frustum
  93201. * Unlike isInFrustum this cheks the full bounding box
  93202. * @param target The object to check
  93203. * @returns true if the object is in frustum otherwise false
  93204. */
  93205. isCompletelyInFrustum(target: ICullable): boolean;
  93206. /**
  93207. * Gets a ray in the forward direction from the camera.
  93208. * @param length Defines the length of the ray to create
  93209. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93210. * @param origin Defines the start point of the ray which defaults to the camera position
  93211. * @returns the forward ray
  93212. */
  93213. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93214. /**
  93215. * Releases resources associated with this node.
  93216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93218. */
  93219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93220. /** @hidden */
  93221. _isLeftCamera: boolean;
  93222. /**
  93223. * Gets the left camera of a rig setup in case of Rigged Camera
  93224. */
  93225. readonly isLeftCamera: boolean;
  93226. /** @hidden */
  93227. _isRightCamera: boolean;
  93228. /**
  93229. * Gets the right camera of a rig setup in case of Rigged Camera
  93230. */
  93231. readonly isRightCamera: boolean;
  93232. /**
  93233. * Gets the left camera of a rig setup in case of Rigged Camera
  93234. */
  93235. readonly leftCamera: Nullable<FreeCamera>;
  93236. /**
  93237. * Gets the right camera of a rig setup in case of Rigged Camera
  93238. */
  93239. readonly rightCamera: Nullable<FreeCamera>;
  93240. /**
  93241. * Gets the left camera target of a rig setup in case of Rigged Camera
  93242. * @returns the target position
  93243. */
  93244. getLeftTarget(): Nullable<Vector3>;
  93245. /**
  93246. * Gets the right camera target of a rig setup in case of Rigged Camera
  93247. * @returns the target position
  93248. */
  93249. getRightTarget(): Nullable<Vector3>;
  93250. /**
  93251. * @hidden
  93252. */
  93253. setCameraRigMode(mode: number, rigParams: any): void;
  93254. /** @hidden */
  93255. static _setStereoscopicRigMode(camera: Camera): void;
  93256. /** @hidden */
  93257. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93258. /** @hidden */
  93259. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93260. /** @hidden */
  93261. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93262. /** @hidden */
  93263. _getVRProjectionMatrix(): Matrix;
  93264. protected _updateCameraRotationMatrix(): void;
  93265. protected _updateWebVRCameraRotationMatrix(): void;
  93266. /**
  93267. * This function MUST be overwritten by the different WebVR cameras available.
  93268. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93269. * @hidden
  93270. */
  93271. _getWebVRProjectionMatrix(): Matrix;
  93272. /**
  93273. * This function MUST be overwritten by the different WebVR cameras available.
  93274. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93275. * @hidden
  93276. */
  93277. _getWebVRViewMatrix(): Matrix;
  93278. /** @hidden */
  93279. setCameraRigParameter(name: string, value: any): void;
  93280. /**
  93281. * needs to be overridden by children so sub has required properties to be copied
  93282. * @hidden
  93283. */
  93284. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93285. /**
  93286. * May need to be overridden by children
  93287. * @hidden
  93288. */
  93289. _updateRigCameras(): void;
  93290. /** @hidden */
  93291. _setupInputs(): void;
  93292. /**
  93293. * Serialiaze the camera setup to a json represention
  93294. * @returns the JSON representation
  93295. */
  93296. serialize(): any;
  93297. /**
  93298. * Clones the current camera.
  93299. * @param name The cloned camera name
  93300. * @returns the cloned camera
  93301. */
  93302. clone(name: string): Camera;
  93303. /**
  93304. * Gets the direction of the camera relative to a given local axis.
  93305. * @param localAxis Defines the reference axis to provide a relative direction.
  93306. * @return the direction
  93307. */
  93308. getDirection(localAxis: Vector3): Vector3;
  93309. /**
  93310. * Returns the current camera absolute rotation
  93311. */
  93312. readonly absoluteRotation: Quaternion;
  93313. /**
  93314. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93315. * @param localAxis Defines the reference axis to provide a relative direction.
  93316. * @param result Defines the vector to store the result in
  93317. */
  93318. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93319. /**
  93320. * Gets a camera constructor for a given camera type
  93321. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93322. * @param name The name of the camera the result will be able to instantiate
  93323. * @param scene The scene the result will construct the camera in
  93324. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93325. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93326. * @returns a factory method to construc the camera
  93327. */
  93328. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93329. /**
  93330. * Compute the world matrix of the camera.
  93331. * @returns the camera world matrix
  93332. */
  93333. computeWorldMatrix(): Matrix;
  93334. /**
  93335. * Parse a JSON and creates the camera from the parsed information
  93336. * @param parsedCamera The JSON to parse
  93337. * @param scene The scene to instantiate the camera in
  93338. * @returns the newly constructed camera
  93339. */
  93340. static Parse(parsedCamera: any, scene: Scene): Camera;
  93341. }
  93342. }
  93343. declare module BABYLON {
  93344. /**
  93345. * Class containing static functions to help procedurally build meshes
  93346. */
  93347. export class DiscBuilder {
  93348. /**
  93349. * Creates a plane polygonal mesh. By default, this is a disc
  93350. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93351. * * 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
  93352. * * 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
  93353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93356. * @param name defines the name of the mesh
  93357. * @param options defines the options used to create the mesh
  93358. * @param scene defines the hosting scene
  93359. * @returns the plane polygonal mesh
  93360. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93361. */
  93362. static CreateDisc(name: string, options: {
  93363. radius?: number;
  93364. tessellation?: number;
  93365. arc?: number;
  93366. updatable?: boolean;
  93367. sideOrientation?: number;
  93368. frontUVs?: Vector4;
  93369. backUVs?: Vector4;
  93370. }, scene?: Nullable<Scene>): Mesh;
  93371. }
  93372. }
  93373. declare module BABYLON {
  93374. /**
  93375. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93376. *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.
  93377. * The SPS is also a particle system. It provides some methods to manage the particles.
  93378. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93379. *
  93380. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93381. */
  93382. export class SolidParticleSystem implements IDisposable {
  93383. /**
  93384. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93385. * Example : var p = SPS.particles[i];
  93386. */
  93387. particles: SolidParticle[];
  93388. /**
  93389. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93390. */
  93391. nbParticles: number;
  93392. /**
  93393. * If the particles must ever face the camera (default false). Useful for planar particles.
  93394. */
  93395. billboard: boolean;
  93396. /**
  93397. * Recompute normals when adding a shape
  93398. */
  93399. recomputeNormals: boolean;
  93400. /**
  93401. * This a counter ofr your own usage. It's not set by any SPS functions.
  93402. */
  93403. counter: number;
  93404. /**
  93405. * The SPS name. This name is also given to the underlying mesh.
  93406. */
  93407. name: string;
  93408. /**
  93409. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93410. */
  93411. mesh: Mesh;
  93412. /**
  93413. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93414. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93415. */
  93416. vars: any;
  93417. /**
  93418. * This array is populated when the SPS is set as 'pickable'.
  93419. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93420. * Each element of this array is an object `{idx: int, faceId: int}`.
  93421. * `idx` is the picked particle index in the `SPS.particles` array
  93422. * `faceId` is the picked face index counted within this particle.
  93423. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93424. */
  93425. pickedParticles: {
  93426. idx: number;
  93427. faceId: number;
  93428. }[];
  93429. /**
  93430. * This array is populated when `enableDepthSort` is set to true.
  93431. * Each element of this array is an instance of the class DepthSortedParticle.
  93432. */
  93433. depthSortedParticles: DepthSortedParticle[];
  93434. /**
  93435. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93436. * @hidden
  93437. */
  93438. _bSphereOnly: boolean;
  93439. /**
  93440. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93441. * @hidden
  93442. */
  93443. _bSphereRadiusFactor: number;
  93444. private _scene;
  93445. private _positions;
  93446. private _indices;
  93447. private _normals;
  93448. private _colors;
  93449. private _uvs;
  93450. private _indices32;
  93451. private _positions32;
  93452. private _normals32;
  93453. private _fixedNormal32;
  93454. private _colors32;
  93455. private _uvs32;
  93456. private _index;
  93457. private _updatable;
  93458. private _pickable;
  93459. private _isVisibilityBoxLocked;
  93460. private _alwaysVisible;
  93461. private _depthSort;
  93462. private _expandable;
  93463. private _shapeCounter;
  93464. private _copy;
  93465. private _mustResetCopy;
  93466. private _color;
  93467. private _computeParticleColor;
  93468. private _computeParticleTexture;
  93469. private _computeParticleRotation;
  93470. private _computeParticleVertex;
  93471. private _computeBoundingBox;
  93472. private _depthSortParticles;
  93473. private _camera;
  93474. private _mustUnrotateFixedNormals;
  93475. private _particlesIntersect;
  93476. private _needs32Bits;
  93477. private _isNotBuilt;
  93478. private _lastParticleId;
  93479. private _idxOfId;
  93480. /**
  93481. * Creates a SPS (Solid Particle System) object.
  93482. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93483. * @param scene (Scene) is the scene in which the SPS is added.
  93484. * @param options defines the options of the sps e.g.
  93485. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93486. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93487. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93488. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93489. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93490. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93491. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93492. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93493. */
  93494. constructor(name: string, scene: Scene, options?: {
  93495. updatable?: boolean;
  93496. isPickable?: boolean;
  93497. enableDepthSort?: boolean;
  93498. particleIntersection?: boolean;
  93499. boundingSphereOnly?: boolean;
  93500. bSphereRadiusFactor?: number;
  93501. expandable?: boolean;
  93502. });
  93503. /**
  93504. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93505. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93506. * @returns the created mesh
  93507. */
  93508. buildMesh(): Mesh;
  93509. /**
  93510. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93511. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93512. * Thus the particles generated from `digest()` have their property `position` set yet.
  93513. * @param mesh ( Mesh ) is the mesh to be digested
  93514. * @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
  93515. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93516. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93517. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93518. * @returns the current SPS
  93519. */
  93520. digest(mesh: Mesh, options?: {
  93521. facetNb?: number;
  93522. number?: number;
  93523. delta?: number;
  93524. storage?: [];
  93525. }): SolidParticleSystem;
  93526. /**
  93527. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93528. * @hidden
  93529. */
  93530. private _unrotateFixedNormals;
  93531. /**
  93532. * Resets the temporary working copy particle
  93533. * @hidden
  93534. */
  93535. private _resetCopy;
  93536. /**
  93537. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93538. * @param p the current index in the positions array to be updated
  93539. * @param shape a Vector3 array, the shape geometry
  93540. * @param positions the positions array to be updated
  93541. * @param meshInd the shape indices array
  93542. * @param indices the indices array to be updated
  93543. * @param meshUV the shape uv array
  93544. * @param uvs the uv array to be updated
  93545. * @param meshCol the shape color array
  93546. * @param colors the color array to be updated
  93547. * @param meshNor the shape normals array
  93548. * @param normals the normals array to be updated
  93549. * @param idx the particle index
  93550. * @param idxInShape the particle index in its shape
  93551. * @param options the addShape() method passed options
  93552. * @hidden
  93553. */
  93554. private _meshBuilder;
  93555. /**
  93556. * Returns a shape Vector3 array from positions float array
  93557. * @param positions float array
  93558. * @returns a vector3 array
  93559. * @hidden
  93560. */
  93561. private _posToShape;
  93562. /**
  93563. * Returns a shapeUV array from a float uvs (array deep copy)
  93564. * @param uvs as a float array
  93565. * @returns a shapeUV array
  93566. * @hidden
  93567. */
  93568. private _uvsToShapeUV;
  93569. /**
  93570. * Adds a new particle object in the particles array
  93571. * @param idx particle index in particles array
  93572. * @param id particle id
  93573. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93574. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93575. * @param model particle ModelShape object
  93576. * @param shapeId model shape identifier
  93577. * @param idxInShape index of the particle in the current model
  93578. * @param bInfo model bounding info object
  93579. * @param storage target storage array, if any
  93580. * @hidden
  93581. */
  93582. private _addParticle;
  93583. /**
  93584. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93585. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93586. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93587. * @param nb (positive integer) the number of particles to be created from this model
  93588. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93589. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93590. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93591. * @returns the number of shapes in the system
  93592. */
  93593. addShape(mesh: Mesh, nb: number, options?: {
  93594. positionFunction?: any;
  93595. vertexFunction?: any;
  93596. storage?: [];
  93597. }): number;
  93598. /**
  93599. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93600. * @hidden
  93601. */
  93602. private _rebuildParticle;
  93603. /**
  93604. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93605. * @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.
  93606. * @returns the SPS.
  93607. */
  93608. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93609. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93610. * Returns an array with the removed particles.
  93611. * 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.
  93612. * The SPS can't be empty so at least one particle needs to remain in place.
  93613. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93614. * @param start index of the first particle to remove
  93615. * @param end index of the last particle to remove (included)
  93616. * @returns an array populated with the removed particles
  93617. */
  93618. removeParticles(start: number, end: number): SolidParticle[];
  93619. /**
  93620. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93621. * @param solidParticleArray an array populated with Solid Particles objects
  93622. * @returns the SPS
  93623. */
  93624. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93625. /**
  93626. * Creates a new particle and modifies the SPS mesh geometry :
  93627. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93628. * - calls _addParticle() to populate the particle array
  93629. * factorized code from addShape() and insertParticlesFromArray()
  93630. * @param idx particle index in the particles array
  93631. * @param i particle index in its shape
  93632. * @param modelShape particle ModelShape object
  93633. * @param shape shape vertex array
  93634. * @param meshInd shape indices array
  93635. * @param meshUV shape uv array
  93636. * @param meshCol shape color array
  93637. * @param meshNor shape normals array
  93638. * @param bbInfo shape bounding info
  93639. * @param storage target particle storage
  93640. * @options addShape() passed options
  93641. * @hidden
  93642. */
  93643. private _insertNewParticle;
  93644. /**
  93645. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93646. * This method calls `updateParticle()` for each particle of the SPS.
  93647. * For an animated SPS, it is usually called within the render loop.
  93648. * 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.
  93649. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93650. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93651. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93652. * @returns the SPS.
  93653. */
  93654. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93655. /**
  93656. * Disposes the SPS.
  93657. */
  93658. dispose(): void;
  93659. /**
  93660. * Returns a SolidParticle object from its identifier : particle.id
  93661. * @param id (integer) the particle Id
  93662. * @returns the searched particle or null if not found in the SPS.
  93663. */
  93664. getParticleById(id: number): Nullable<SolidParticle>;
  93665. /**
  93666. * Returns a new array populated with the particles having the passed shapeId.
  93667. * @param shapeId (integer) the shape identifier
  93668. * @returns a new solid particle array
  93669. */
  93670. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93671. /**
  93672. * Populates the passed array "ref" with the particles having the passed shapeId.
  93673. * @param shapeId the shape identifier
  93674. * @returns the SPS
  93675. * @param ref
  93676. */
  93677. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93678. /**
  93679. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93680. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93681. * @returns the SPS.
  93682. */
  93683. refreshVisibleSize(): SolidParticleSystem;
  93684. /**
  93685. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93686. * @param size the size (float) of the visibility box
  93687. * note : this doesn't lock the SPS mesh bounding box.
  93688. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93689. */
  93690. setVisibilityBox(size: number): void;
  93691. /**
  93692. * Gets whether the SPS as always visible or not
  93693. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93694. */
  93695. /**
  93696. * Sets the SPS as always visible or not
  93697. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93698. */
  93699. isAlwaysVisible: boolean;
  93700. /**
  93701. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93702. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93703. */
  93704. /**
  93705. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93706. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93707. */
  93708. isVisibilityBoxLocked: boolean;
  93709. /**
  93710. * Tells to `setParticles()` to compute the particle rotations or not.
  93711. * Default value : true. The SPS is faster when it's set to false.
  93712. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93713. */
  93714. /**
  93715. * Gets if `setParticles()` computes the particle rotations or not.
  93716. * Default value : true. The SPS is faster when it's set to false.
  93717. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93718. */
  93719. computeParticleRotation: boolean;
  93720. /**
  93721. * Tells to `setParticles()` to compute the particle colors or not.
  93722. * Default value : true. The SPS is faster when it's set to false.
  93723. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93724. */
  93725. /**
  93726. * Gets if `setParticles()` computes the particle colors or not.
  93727. * Default value : true. The SPS is faster when it's set to false.
  93728. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93729. */
  93730. computeParticleColor: boolean;
  93731. /**
  93732. * Gets if `setParticles()` computes the particle textures or not.
  93733. * Default value : true. The SPS is faster when it's set to false.
  93734. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93735. */
  93736. computeParticleTexture: boolean;
  93737. /**
  93738. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93739. * Default value : false. The SPS is faster when it's set to false.
  93740. * Note : the particle custom vertex positions aren't stored values.
  93741. */
  93742. /**
  93743. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93744. * Default value : false. The SPS is faster when it's set to false.
  93745. * Note : the particle custom vertex positions aren't stored values.
  93746. */
  93747. computeParticleVertex: boolean;
  93748. /**
  93749. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93750. */
  93751. /**
  93752. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93753. */
  93754. computeBoundingBox: boolean;
  93755. /**
  93756. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93757. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93758. * Default : `true`
  93759. */
  93760. /**
  93761. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93762. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93763. * Default : `true`
  93764. */
  93765. depthSortParticles: boolean;
  93766. /**
  93767. * Gets if the SPS is created as expandable at construction time.
  93768. * Default : `false`
  93769. */
  93770. readonly expandable: boolean;
  93771. /**
  93772. * This function does nothing. It may be overwritten to set all the particle first values.
  93773. * The SPS doesn't call this function, you may have to call it by your own.
  93774. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93775. */
  93776. initParticles(): void;
  93777. /**
  93778. * This function does nothing. It may be overwritten to recycle a particle.
  93779. * The SPS doesn't call this function, you may have to call it by your own.
  93780. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93781. * @param particle The particle to recycle
  93782. * @returns the recycled particle
  93783. */
  93784. recycleParticle(particle: SolidParticle): SolidParticle;
  93785. /**
  93786. * Updates a particle : this function should be overwritten by the user.
  93787. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93788. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93789. * @example : just set a particle position or velocity and recycle conditions
  93790. * @param particle The particle to update
  93791. * @returns the updated particle
  93792. */
  93793. updateParticle(particle: SolidParticle): SolidParticle;
  93794. /**
  93795. * Updates a vertex of a particle : it can be overwritten by the user.
  93796. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93797. * @param particle the current particle
  93798. * @param vertex the current index of the current particle
  93799. * @param pt the index of the current vertex in the particle shape
  93800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93801. * @example : just set a vertex particle position
  93802. * @returns the updated vertex
  93803. */
  93804. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93805. /**
  93806. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93807. * This does nothing and may be overwritten by the user.
  93808. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93809. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93810. * @param update the boolean update value actually passed to setParticles()
  93811. */
  93812. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93813. /**
  93814. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93815. * This will be passed three parameters.
  93816. * This does nothing and may be overwritten by the user.
  93817. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93818. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93819. * @param update the boolean update value actually passed to setParticles()
  93820. */
  93821. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93822. }
  93823. }
  93824. declare module BABYLON {
  93825. /**
  93826. * Represents one particle of a solid particle system.
  93827. */
  93828. export class SolidParticle {
  93829. /**
  93830. * particle global index
  93831. */
  93832. idx: number;
  93833. /**
  93834. * particle identifier
  93835. */
  93836. id: number;
  93837. /**
  93838. * The color of the particle
  93839. */
  93840. color: Nullable<Color4>;
  93841. /**
  93842. * The world space position of the particle.
  93843. */
  93844. position: Vector3;
  93845. /**
  93846. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93847. */
  93848. rotation: Vector3;
  93849. /**
  93850. * The world space rotation quaternion of the particle.
  93851. */
  93852. rotationQuaternion: Nullable<Quaternion>;
  93853. /**
  93854. * The scaling of the particle.
  93855. */
  93856. scaling: Vector3;
  93857. /**
  93858. * The uvs of the particle.
  93859. */
  93860. uvs: Vector4;
  93861. /**
  93862. * The current speed of the particle.
  93863. */
  93864. velocity: Vector3;
  93865. /**
  93866. * The pivot point in the particle local space.
  93867. */
  93868. pivot: Vector3;
  93869. /**
  93870. * Must the particle be translated from its pivot point in its local space ?
  93871. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93872. * Default : false
  93873. */
  93874. translateFromPivot: boolean;
  93875. /**
  93876. * Is the particle active or not ?
  93877. */
  93878. alive: boolean;
  93879. /**
  93880. * Is the particle visible or not ?
  93881. */
  93882. isVisible: boolean;
  93883. /**
  93884. * Index of this particle in the global "positions" array (Internal use)
  93885. * @hidden
  93886. */
  93887. _pos: number;
  93888. /**
  93889. * @hidden Index of this particle in the global "indices" array (Internal use)
  93890. */
  93891. _ind: number;
  93892. /**
  93893. * @hidden ModelShape of this particle (Internal use)
  93894. */
  93895. _model: ModelShape;
  93896. /**
  93897. * ModelShape id of this particle
  93898. */
  93899. shapeId: number;
  93900. /**
  93901. * Index of the particle in its shape id
  93902. */
  93903. idxInShape: number;
  93904. /**
  93905. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93906. */
  93907. _modelBoundingInfo: BoundingInfo;
  93908. /**
  93909. * @hidden Particle BoundingInfo object (Internal use)
  93910. */
  93911. _boundingInfo: BoundingInfo;
  93912. /**
  93913. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93914. */
  93915. _sps: SolidParticleSystem;
  93916. /**
  93917. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93918. */
  93919. _stillInvisible: boolean;
  93920. /**
  93921. * @hidden Last computed particle rotation matrix
  93922. */
  93923. _rotationMatrix: number[];
  93924. /**
  93925. * Parent particle Id, if any.
  93926. * Default null.
  93927. */
  93928. parentId: Nullable<number>;
  93929. /**
  93930. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93931. * The possible values are :
  93932. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93933. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93934. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93935. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93936. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93937. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93938. * */
  93939. cullingStrategy: number;
  93940. /**
  93941. * @hidden Internal global position in the SPS.
  93942. */
  93943. _globalPosition: Vector3;
  93944. /**
  93945. * Creates a Solid Particle object.
  93946. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93947. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  93948. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  93949. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93950. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93951. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93952. * @param shapeId (integer) is the model shape identifier in the SPS.
  93953. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93954. * @param sps defines the sps it is associated to
  93955. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93956. */
  93957. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93958. /**
  93959. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  93960. * @param target the particle target
  93961. * @returns the current particle
  93962. */
  93963. copyToRef(target: SolidParticle): SolidParticle;
  93964. /**
  93965. * Legacy support, changed scale to scaling
  93966. */
  93967. /**
  93968. * Legacy support, changed scale to scaling
  93969. */
  93970. scale: Vector3;
  93971. /**
  93972. * Legacy support, changed quaternion to rotationQuaternion
  93973. */
  93974. /**
  93975. * Legacy support, changed quaternion to rotationQuaternion
  93976. */
  93977. quaternion: Nullable<Quaternion>;
  93978. /**
  93979. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93980. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93981. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93982. * @returns true if it intersects
  93983. */
  93984. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93985. /**
  93986. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93987. * A particle is in the frustum if its bounding box intersects the frustum
  93988. * @param frustumPlanes defines the frustum to test
  93989. * @returns true if the particle is in the frustum planes
  93990. */
  93991. isInFrustum(frustumPlanes: Plane[]): boolean;
  93992. /**
  93993. * get the rotation matrix of the particle
  93994. * @hidden
  93995. */
  93996. getRotationMatrix(m: Matrix): void;
  93997. }
  93998. /**
  93999. * Represents the shape of the model used by one particle of a solid particle system.
  94000. * SPS internal tool, don't use it manually.
  94001. */
  94002. export class ModelShape {
  94003. /**
  94004. * The shape id
  94005. * @hidden
  94006. */
  94007. shapeID: number;
  94008. /**
  94009. * flat array of model positions (internal use)
  94010. * @hidden
  94011. */
  94012. _shape: Vector3[];
  94013. /**
  94014. * flat array of model UVs (internal use)
  94015. * @hidden
  94016. */
  94017. _shapeUV: number[];
  94018. /**
  94019. * color array of the model
  94020. * @hidden
  94021. */
  94022. _shapeColors: number[];
  94023. /**
  94024. * indices array of the model
  94025. * @hidden
  94026. */
  94027. _indices: number[];
  94028. /**
  94029. * normals array of the model
  94030. * @hidden
  94031. */
  94032. _normals: number[];
  94033. /**
  94034. * length of the shape in the model indices array (internal use)
  94035. * @hidden
  94036. */
  94037. _indicesLength: number;
  94038. /**
  94039. * Custom position function (internal use)
  94040. * @hidden
  94041. */
  94042. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94043. /**
  94044. * Custom vertex function (internal use)
  94045. * @hidden
  94046. */
  94047. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94048. /**
  94049. * 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.
  94050. * SPS internal tool, don't use it manually.
  94051. * @hidden
  94052. */
  94053. 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>);
  94054. }
  94055. /**
  94056. * Represents a Depth Sorted Particle in the solid particle system.
  94057. */
  94058. export class DepthSortedParticle {
  94059. /**
  94060. * Index of the particle in the "indices" array
  94061. */
  94062. ind: number;
  94063. /**
  94064. * Length of the particle shape in the "indices" array
  94065. */
  94066. indicesLength: number;
  94067. /**
  94068. * Squared distance from the particle to the camera
  94069. */
  94070. sqDistance: number;
  94071. }
  94072. }
  94073. declare module BABYLON {
  94074. /**
  94075. * @hidden
  94076. */
  94077. export class _MeshCollisionData {
  94078. _checkCollisions: boolean;
  94079. _collisionMask: number;
  94080. _collisionGroup: number;
  94081. _collider: Nullable<Collider>;
  94082. _oldPositionForCollisions: Vector3;
  94083. _diffPositionForCollisions: Vector3;
  94084. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94085. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94086. }
  94087. }
  94088. declare module BABYLON {
  94089. /** @hidden */
  94090. class _FacetDataStorage {
  94091. facetPositions: Vector3[];
  94092. facetNormals: Vector3[];
  94093. facetPartitioning: number[][];
  94094. facetNb: number;
  94095. partitioningSubdivisions: number;
  94096. partitioningBBoxRatio: number;
  94097. facetDataEnabled: boolean;
  94098. facetParameters: any;
  94099. bbSize: Vector3;
  94100. subDiv: {
  94101. max: number;
  94102. X: number;
  94103. Y: number;
  94104. Z: number;
  94105. };
  94106. facetDepthSort: boolean;
  94107. facetDepthSortEnabled: boolean;
  94108. depthSortedIndices: IndicesArray;
  94109. depthSortedFacets: {
  94110. ind: number;
  94111. sqDistance: number;
  94112. }[];
  94113. facetDepthSortFunction: (f1: {
  94114. ind: number;
  94115. sqDistance: number;
  94116. }, f2: {
  94117. ind: number;
  94118. sqDistance: number;
  94119. }) => number;
  94120. facetDepthSortFrom: Vector3;
  94121. facetDepthSortOrigin: Vector3;
  94122. invertedMatrix: Matrix;
  94123. }
  94124. /**
  94125. * @hidden
  94126. **/
  94127. class _InternalAbstractMeshDataInfo {
  94128. _hasVertexAlpha: boolean;
  94129. _useVertexColors: boolean;
  94130. _numBoneInfluencers: number;
  94131. _applyFog: boolean;
  94132. _receiveShadows: boolean;
  94133. _facetData: _FacetDataStorage;
  94134. _visibility: number;
  94135. _skeleton: Nullable<Skeleton>;
  94136. _layerMask: number;
  94137. _computeBonesUsingShaders: boolean;
  94138. _isActive: boolean;
  94139. _onlyForInstances: boolean;
  94140. _isActiveIntermediate: boolean;
  94141. _onlyForInstancesIntermediate: boolean;
  94142. _actAsRegularMesh: boolean;
  94143. }
  94144. /**
  94145. * Class used to store all common mesh properties
  94146. */
  94147. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94148. /** No occlusion */
  94149. static OCCLUSION_TYPE_NONE: number;
  94150. /** Occlusion set to optimisitic */
  94151. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94152. /** Occlusion set to strict */
  94153. static OCCLUSION_TYPE_STRICT: number;
  94154. /** Use an accurante occlusion algorithm */
  94155. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94156. /** Use a conservative occlusion algorithm */
  94157. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94158. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94159. * Test order :
  94160. * Is the bounding sphere outside the frustum ?
  94161. * If not, are the bounding box vertices outside the frustum ?
  94162. * It not, then the cullable object is in the frustum.
  94163. */
  94164. static readonly CULLINGSTRATEGY_STANDARD: number;
  94165. /** Culling strategy : Bounding Sphere Only.
  94166. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94167. * It's also less accurate than the standard because some not visible objects can still be selected.
  94168. * Test : is the bounding sphere outside the frustum ?
  94169. * If not, then the cullable object is in the frustum.
  94170. */
  94171. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94172. /** Culling strategy : Optimistic Inclusion.
  94173. * This in an inclusion test first, then the standard exclusion test.
  94174. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94175. * 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.
  94176. * Anyway, it's as accurate as the standard strategy.
  94177. * Test :
  94178. * Is the cullable object bounding sphere center in the frustum ?
  94179. * If not, apply the default culling strategy.
  94180. */
  94181. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94182. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94183. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94184. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94185. * 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.
  94186. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94187. * Test :
  94188. * Is the cullable object bounding sphere center in the frustum ?
  94189. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94190. */
  94191. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94192. /**
  94193. * No billboard
  94194. */
  94195. static readonly BILLBOARDMODE_NONE: number;
  94196. /** Billboard on X axis */
  94197. static readonly BILLBOARDMODE_X: number;
  94198. /** Billboard on Y axis */
  94199. static readonly BILLBOARDMODE_Y: number;
  94200. /** Billboard on Z axis */
  94201. static readonly BILLBOARDMODE_Z: number;
  94202. /** Billboard on all axes */
  94203. static readonly BILLBOARDMODE_ALL: number;
  94204. /** Billboard on using position instead of orientation */
  94205. static readonly BILLBOARDMODE_USE_POSITION: number;
  94206. /** @hidden */
  94207. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94208. /**
  94209. * The culling strategy to use to check whether the mesh must be rendered or not.
  94210. * This value can be changed at any time and will be used on the next render mesh selection.
  94211. * The possible values are :
  94212. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94213. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94214. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94215. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94216. * Please read each static variable documentation to get details about the culling process.
  94217. * */
  94218. cullingStrategy: number;
  94219. /**
  94220. * Gets the number of facets in the mesh
  94221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94222. */
  94223. readonly facetNb: number;
  94224. /**
  94225. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94227. */
  94228. partitioningSubdivisions: number;
  94229. /**
  94230. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94231. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94233. */
  94234. partitioningBBoxRatio: number;
  94235. /**
  94236. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94237. * Works only for updatable meshes.
  94238. * Doesn't work with multi-materials
  94239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94240. */
  94241. mustDepthSortFacets: boolean;
  94242. /**
  94243. * The location (Vector3) where the facet depth sort must be computed from.
  94244. * By default, the active camera position.
  94245. * Used only when facet depth sort is enabled
  94246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94247. */
  94248. facetDepthSortFrom: Vector3;
  94249. /**
  94250. * gets a boolean indicating if facetData is enabled
  94251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94252. */
  94253. readonly isFacetDataEnabled: boolean;
  94254. /** @hidden */
  94255. _updateNonUniformScalingState(value: boolean): boolean;
  94256. /**
  94257. * An event triggered when this mesh collides with another one
  94258. */
  94259. onCollideObservable: Observable<AbstractMesh>;
  94260. /** Set a function to call when this mesh collides with another one */
  94261. onCollide: () => void;
  94262. /**
  94263. * An event triggered when the collision's position changes
  94264. */
  94265. onCollisionPositionChangeObservable: Observable<Vector3>;
  94266. /** Set a function to call when the collision's position changes */
  94267. onCollisionPositionChange: () => void;
  94268. /**
  94269. * An event triggered when material is changed
  94270. */
  94271. onMaterialChangedObservable: Observable<AbstractMesh>;
  94272. /**
  94273. * Gets or sets the orientation for POV movement & rotation
  94274. */
  94275. definedFacingForward: boolean;
  94276. /** @hidden */
  94277. _occlusionQuery: Nullable<WebGLQuery>;
  94278. /** @hidden */
  94279. _renderingGroup: Nullable<RenderingGroup>;
  94280. /**
  94281. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94282. */
  94283. /**
  94284. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94285. */
  94286. visibility: number;
  94287. /** Gets or sets the alpha index used to sort transparent meshes
  94288. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94289. */
  94290. alphaIndex: number;
  94291. /**
  94292. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94293. */
  94294. isVisible: boolean;
  94295. /**
  94296. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94297. */
  94298. isPickable: boolean;
  94299. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94300. showSubMeshesBoundingBox: boolean;
  94301. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94302. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94303. */
  94304. isBlocker: boolean;
  94305. /**
  94306. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94307. */
  94308. enablePointerMoveEvents: boolean;
  94309. /**
  94310. * Specifies the rendering group id for this mesh (0 by default)
  94311. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94312. */
  94313. renderingGroupId: number;
  94314. private _material;
  94315. /** Gets or sets current material */
  94316. material: Nullable<Material>;
  94317. /**
  94318. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94319. * @see http://doc.babylonjs.com/babylon101/shadows
  94320. */
  94321. receiveShadows: boolean;
  94322. /** Defines color to use when rendering outline */
  94323. outlineColor: Color3;
  94324. /** Define width to use when rendering outline */
  94325. outlineWidth: number;
  94326. /** Defines color to use when rendering overlay */
  94327. overlayColor: Color3;
  94328. /** Defines alpha to use when rendering overlay */
  94329. overlayAlpha: number;
  94330. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94331. hasVertexAlpha: boolean;
  94332. /** 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) */
  94333. useVertexColors: boolean;
  94334. /**
  94335. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94336. */
  94337. computeBonesUsingShaders: boolean;
  94338. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94339. numBoneInfluencers: number;
  94340. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94341. applyFog: boolean;
  94342. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94343. useOctreeForRenderingSelection: boolean;
  94344. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94345. useOctreeForPicking: boolean;
  94346. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94347. useOctreeForCollisions: boolean;
  94348. /**
  94349. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94350. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94351. */
  94352. layerMask: number;
  94353. /**
  94354. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94355. */
  94356. alwaysSelectAsActiveMesh: boolean;
  94357. /**
  94358. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94359. */
  94360. doNotSyncBoundingInfo: boolean;
  94361. /**
  94362. * Gets or sets the current action manager
  94363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94364. */
  94365. actionManager: Nullable<AbstractActionManager>;
  94366. private _meshCollisionData;
  94367. /**
  94368. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94370. */
  94371. ellipsoid: Vector3;
  94372. /**
  94373. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94375. */
  94376. ellipsoidOffset: Vector3;
  94377. /**
  94378. * Gets or sets a collision mask used to mask collisions (default is -1).
  94379. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94380. */
  94381. collisionMask: number;
  94382. /**
  94383. * Gets or sets the current collision group mask (-1 by default).
  94384. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94385. */
  94386. collisionGroup: number;
  94387. /**
  94388. * Defines edge width used when edgesRenderer is enabled
  94389. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94390. */
  94391. edgesWidth: number;
  94392. /**
  94393. * Defines edge color used when edgesRenderer is enabled
  94394. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94395. */
  94396. edgesColor: Color4;
  94397. /** @hidden */
  94398. _edgesRenderer: Nullable<IEdgesRenderer>;
  94399. /** @hidden */
  94400. _masterMesh: Nullable<AbstractMesh>;
  94401. /** @hidden */
  94402. _boundingInfo: Nullable<BoundingInfo>;
  94403. /** @hidden */
  94404. _renderId: number;
  94405. /**
  94406. * Gets or sets the list of subMeshes
  94407. * @see http://doc.babylonjs.com/how_to/multi_materials
  94408. */
  94409. subMeshes: SubMesh[];
  94410. /** @hidden */
  94411. _intersectionsInProgress: AbstractMesh[];
  94412. /** @hidden */
  94413. _unIndexed: boolean;
  94414. /** @hidden */
  94415. _lightSources: Light[];
  94416. /** Gets the list of lights affecting that mesh */
  94417. readonly lightSources: Light[];
  94418. /** @hidden */
  94419. readonly _positions: Nullable<Vector3[]>;
  94420. /** @hidden */
  94421. _waitingData: {
  94422. lods: Nullable<any>;
  94423. actions: Nullable<any>;
  94424. freezeWorldMatrix: Nullable<boolean>;
  94425. };
  94426. /** @hidden */
  94427. _bonesTransformMatrices: Nullable<Float32Array>;
  94428. /** @hidden */
  94429. _transformMatrixTexture: Nullable<RawTexture>;
  94430. /**
  94431. * Gets or sets a skeleton to apply skining transformations
  94432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94433. */
  94434. skeleton: Nullable<Skeleton>;
  94435. /**
  94436. * An event triggered when the mesh is rebuilt.
  94437. */
  94438. onRebuildObservable: Observable<AbstractMesh>;
  94439. /**
  94440. * Creates a new AbstractMesh
  94441. * @param name defines the name of the mesh
  94442. * @param scene defines the hosting scene
  94443. */
  94444. constructor(name: string, scene?: Nullable<Scene>);
  94445. /**
  94446. * Returns the string "AbstractMesh"
  94447. * @returns "AbstractMesh"
  94448. */
  94449. getClassName(): string;
  94450. /**
  94451. * Gets a string representation of the current mesh
  94452. * @param fullDetails defines a boolean indicating if full details must be included
  94453. * @returns a string representation of the current mesh
  94454. */
  94455. toString(fullDetails?: boolean): string;
  94456. /**
  94457. * @hidden
  94458. */
  94459. protected _getEffectiveParent(): Nullable<Node>;
  94460. /** @hidden */
  94461. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94462. /** @hidden */
  94463. _rebuild(): void;
  94464. /** @hidden */
  94465. _resyncLightSources(): void;
  94466. /** @hidden */
  94467. _resyncLighSource(light: Light): void;
  94468. /** @hidden */
  94469. _unBindEffect(): void;
  94470. /** @hidden */
  94471. _removeLightSource(light: Light, dispose: boolean): void;
  94472. private _markSubMeshesAsDirty;
  94473. /** @hidden */
  94474. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94475. /** @hidden */
  94476. _markSubMeshesAsAttributesDirty(): void;
  94477. /** @hidden */
  94478. _markSubMeshesAsMiscDirty(): void;
  94479. /**
  94480. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94481. */
  94482. scaling: Vector3;
  94483. /**
  94484. * Returns true if the mesh is blocked. Implemented by child classes
  94485. */
  94486. readonly isBlocked: boolean;
  94487. /**
  94488. * Returns the mesh itself by default. Implemented by child classes
  94489. * @param camera defines the camera to use to pick the right LOD level
  94490. * @returns the currentAbstractMesh
  94491. */
  94492. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94493. /**
  94494. * Returns 0 by default. Implemented by child classes
  94495. * @returns an integer
  94496. */
  94497. getTotalVertices(): number;
  94498. /**
  94499. * Returns a positive integer : the total number of indices in this mesh geometry.
  94500. * @returns the numner of indices or zero if the mesh has no geometry.
  94501. */
  94502. getTotalIndices(): number;
  94503. /**
  94504. * Returns null by default. Implemented by child classes
  94505. * @returns null
  94506. */
  94507. getIndices(): Nullable<IndicesArray>;
  94508. /**
  94509. * Returns the array of the requested vertex data kind. Implemented by child classes
  94510. * @param kind defines the vertex data kind to use
  94511. * @returns null
  94512. */
  94513. getVerticesData(kind: string): Nullable<FloatArray>;
  94514. /**
  94515. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94516. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94517. * Note that a new underlying VertexBuffer object is created each call.
  94518. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94519. * @param kind defines vertex data kind:
  94520. * * VertexBuffer.PositionKind
  94521. * * VertexBuffer.UVKind
  94522. * * VertexBuffer.UV2Kind
  94523. * * VertexBuffer.UV3Kind
  94524. * * VertexBuffer.UV4Kind
  94525. * * VertexBuffer.UV5Kind
  94526. * * VertexBuffer.UV6Kind
  94527. * * VertexBuffer.ColorKind
  94528. * * VertexBuffer.MatricesIndicesKind
  94529. * * VertexBuffer.MatricesIndicesExtraKind
  94530. * * VertexBuffer.MatricesWeightsKind
  94531. * * VertexBuffer.MatricesWeightsExtraKind
  94532. * @param data defines the data source
  94533. * @param updatable defines if the data must be flagged as updatable (or static)
  94534. * @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
  94535. * @returns the current mesh
  94536. */
  94537. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94538. /**
  94539. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94540. * If the mesh has no geometry, it is simply returned as it is.
  94541. * @param kind defines vertex data kind:
  94542. * * VertexBuffer.PositionKind
  94543. * * VertexBuffer.UVKind
  94544. * * VertexBuffer.UV2Kind
  94545. * * VertexBuffer.UV3Kind
  94546. * * VertexBuffer.UV4Kind
  94547. * * VertexBuffer.UV5Kind
  94548. * * VertexBuffer.UV6Kind
  94549. * * VertexBuffer.ColorKind
  94550. * * VertexBuffer.MatricesIndicesKind
  94551. * * VertexBuffer.MatricesIndicesExtraKind
  94552. * * VertexBuffer.MatricesWeightsKind
  94553. * * VertexBuffer.MatricesWeightsExtraKind
  94554. * @param data defines the data source
  94555. * @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
  94556. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94557. * @returns the current mesh
  94558. */
  94559. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94560. /**
  94561. * Sets the mesh indices,
  94562. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94563. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94564. * @param totalVertices Defines the total number of vertices
  94565. * @returns the current mesh
  94566. */
  94567. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94568. /**
  94569. * Gets a boolean indicating if specific vertex data is present
  94570. * @param kind defines the vertex data kind to use
  94571. * @returns true is data kind is present
  94572. */
  94573. isVerticesDataPresent(kind: string): boolean;
  94574. /**
  94575. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94576. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94577. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94578. * @returns a BoundingInfo
  94579. */
  94580. getBoundingInfo(): BoundingInfo;
  94581. /**
  94582. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94583. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94584. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94585. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94586. * @returns the current mesh
  94587. */
  94588. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94589. /**
  94590. * Overwrite the current bounding info
  94591. * @param boundingInfo defines the new bounding info
  94592. * @returns the current mesh
  94593. */
  94594. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94595. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94596. readonly useBones: boolean;
  94597. /** @hidden */
  94598. _preActivate(): void;
  94599. /** @hidden */
  94600. _preActivateForIntermediateRendering(renderId: number): void;
  94601. /** @hidden */
  94602. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94603. /** @hidden */
  94604. _postActivate(): void;
  94605. /** @hidden */
  94606. _freeze(): void;
  94607. /** @hidden */
  94608. _unFreeze(): void;
  94609. /**
  94610. * Gets the current world matrix
  94611. * @returns a Matrix
  94612. */
  94613. getWorldMatrix(): Matrix;
  94614. /** @hidden */
  94615. _getWorldMatrixDeterminant(): number;
  94616. /**
  94617. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94618. */
  94619. readonly isAnInstance: boolean;
  94620. /**
  94621. * Gets a boolean indicating if this mesh has instances
  94622. */
  94623. readonly hasInstances: boolean;
  94624. /**
  94625. * Perform relative position change from the point of view of behind the front of the mesh.
  94626. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94627. * Supports definition of mesh facing forward or backward
  94628. * @param amountRight defines the distance on the right axis
  94629. * @param amountUp defines the distance on the up axis
  94630. * @param amountForward defines the distance on the forward axis
  94631. * @returns the current mesh
  94632. */
  94633. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94634. /**
  94635. * Calculate relative position change from the point of view of behind the front of the mesh.
  94636. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94637. * Supports definition of mesh facing forward or backward
  94638. * @param amountRight defines the distance on the right axis
  94639. * @param amountUp defines the distance on the up axis
  94640. * @param amountForward defines the distance on the forward axis
  94641. * @returns the new displacement vector
  94642. */
  94643. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94644. /**
  94645. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94646. * Supports definition of mesh facing forward or backward
  94647. * @param flipBack defines the flip
  94648. * @param twirlClockwise defines the twirl
  94649. * @param tiltRight defines the tilt
  94650. * @returns the current mesh
  94651. */
  94652. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94653. /**
  94654. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94655. * Supports definition of mesh facing forward or backward.
  94656. * @param flipBack defines the flip
  94657. * @param twirlClockwise defines the twirl
  94658. * @param tiltRight defines the tilt
  94659. * @returns the new rotation vector
  94660. */
  94661. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94662. /**
  94663. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94664. * This means the mesh underlying bounding box and sphere are recomputed.
  94665. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94666. * @returns the current mesh
  94667. */
  94668. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94669. /** @hidden */
  94670. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94671. /** @hidden */
  94672. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94673. /** @hidden */
  94674. _updateBoundingInfo(): AbstractMesh;
  94675. /** @hidden */
  94676. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94677. /** @hidden */
  94678. protected _afterComputeWorldMatrix(): void;
  94679. /** @hidden */
  94680. readonly _effectiveMesh: AbstractMesh;
  94681. /**
  94682. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94683. * A mesh is in the frustum if its bounding box intersects the frustum
  94684. * @param frustumPlanes defines the frustum to test
  94685. * @returns true if the mesh is in the frustum planes
  94686. */
  94687. isInFrustum(frustumPlanes: Plane[]): boolean;
  94688. /**
  94689. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94690. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94691. * @param frustumPlanes defines the frustum to test
  94692. * @returns true if the mesh is completely in the frustum planes
  94693. */
  94694. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94695. /**
  94696. * True if the mesh intersects another mesh or a SolidParticle object
  94697. * @param mesh defines a target mesh or SolidParticle to test
  94698. * @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)
  94699. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94700. * @returns true if there is an intersection
  94701. */
  94702. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94703. /**
  94704. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94705. * @param point defines the point to test
  94706. * @returns true if there is an intersection
  94707. */
  94708. intersectsPoint(point: Vector3): boolean;
  94709. /**
  94710. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94712. */
  94713. checkCollisions: boolean;
  94714. /**
  94715. * Gets Collider object used to compute collisions (not physics)
  94716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94717. */
  94718. readonly collider: Nullable<Collider>;
  94719. /**
  94720. * Move the mesh using collision engine
  94721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94722. * @param displacement defines the requested displacement vector
  94723. * @returns the current mesh
  94724. */
  94725. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94726. private _onCollisionPositionChange;
  94727. /** @hidden */
  94728. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94729. /** @hidden */
  94730. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94731. /** @hidden */
  94732. _checkCollision(collider: Collider): AbstractMesh;
  94733. /** @hidden */
  94734. _generatePointsArray(): boolean;
  94735. /**
  94736. * Checks if the passed Ray intersects with the mesh
  94737. * @param ray defines the ray to use
  94738. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94739. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94740. * @returns the picking info
  94741. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94742. */
  94743. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94744. /**
  94745. * Clones the current mesh
  94746. * @param name defines the mesh name
  94747. * @param newParent defines the new mesh parent
  94748. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94749. * @returns the new mesh
  94750. */
  94751. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94752. /**
  94753. * Disposes all the submeshes of the current meshnp
  94754. * @returns the current mesh
  94755. */
  94756. releaseSubMeshes(): AbstractMesh;
  94757. /**
  94758. * Releases resources associated with this abstract mesh.
  94759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94761. */
  94762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94763. /**
  94764. * Adds the passed mesh as a child to the current mesh
  94765. * @param mesh defines the child mesh
  94766. * @returns the current mesh
  94767. */
  94768. addChild(mesh: AbstractMesh): AbstractMesh;
  94769. /**
  94770. * Removes the passed mesh from the current mesh children list
  94771. * @param mesh defines the child mesh
  94772. * @returns the current mesh
  94773. */
  94774. removeChild(mesh: AbstractMesh): AbstractMesh;
  94775. /** @hidden */
  94776. private _initFacetData;
  94777. /**
  94778. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94779. * This method can be called within the render loop.
  94780. * 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
  94781. * @returns the current mesh
  94782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94783. */
  94784. updateFacetData(): AbstractMesh;
  94785. /**
  94786. * Returns the facetLocalNormals array.
  94787. * The normals are expressed in the mesh local spac
  94788. * @returns an array of Vector3
  94789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94790. */
  94791. getFacetLocalNormals(): Vector3[];
  94792. /**
  94793. * Returns the facetLocalPositions array.
  94794. * The facet positions are expressed in the mesh local space
  94795. * @returns an array of Vector3
  94796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94797. */
  94798. getFacetLocalPositions(): Vector3[];
  94799. /**
  94800. * Returns the facetLocalPartioning array
  94801. * @returns an array of array of numbers
  94802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94803. */
  94804. getFacetLocalPartitioning(): number[][];
  94805. /**
  94806. * Returns the i-th facet position in the world system.
  94807. * This method allocates a new Vector3 per call
  94808. * @param i defines the facet index
  94809. * @returns a new Vector3
  94810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94811. */
  94812. getFacetPosition(i: number): Vector3;
  94813. /**
  94814. * Sets the reference Vector3 with the i-th facet position in the world system
  94815. * @param i defines the facet index
  94816. * @param ref defines the target vector
  94817. * @returns the current mesh
  94818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94819. */
  94820. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94821. /**
  94822. * Returns the i-th facet normal in the world system.
  94823. * This method allocates a new Vector3 per call
  94824. * @param i defines the facet index
  94825. * @returns a new Vector3
  94826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94827. */
  94828. getFacetNormal(i: number): Vector3;
  94829. /**
  94830. * Sets the reference Vector3 with the i-th facet normal in the world system
  94831. * @param i defines the facet index
  94832. * @param ref defines the target vector
  94833. * @returns the current mesh
  94834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94835. */
  94836. getFacetNormalToRef(i: number, ref: Vector3): this;
  94837. /**
  94838. * 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)
  94839. * @param x defines x coordinate
  94840. * @param y defines y coordinate
  94841. * @param z defines z coordinate
  94842. * @returns the array of facet indexes
  94843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94844. */
  94845. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94846. /**
  94847. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94848. * @param projected sets as the (x,y,z) world projection on the facet
  94849. * @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
  94850. * @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
  94851. * @param x defines x coordinate
  94852. * @param y defines y coordinate
  94853. * @param z defines z coordinate
  94854. * @returns the face index if found (or null instead)
  94855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94856. */
  94857. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94858. /**
  94859. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94860. * @param projected sets as the (x,y,z) local projection on the facet
  94861. * @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
  94862. * @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
  94863. * @param x defines x coordinate
  94864. * @param y defines y coordinate
  94865. * @param z defines z coordinate
  94866. * @returns the face index if found (or null instead)
  94867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94868. */
  94869. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94870. /**
  94871. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94872. * @returns the parameters
  94873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94874. */
  94875. getFacetDataParameters(): any;
  94876. /**
  94877. * Disables the feature FacetData and frees the related memory
  94878. * @returns the current mesh
  94879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94880. */
  94881. disableFacetData(): AbstractMesh;
  94882. /**
  94883. * Updates the AbstractMesh indices array
  94884. * @param indices defines the data source
  94885. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94886. * @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)
  94887. * @returns the current mesh
  94888. */
  94889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94890. /**
  94891. * Creates new normals data for the mesh
  94892. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94893. * @returns the current mesh
  94894. */
  94895. createNormals(updatable: boolean): AbstractMesh;
  94896. /**
  94897. * Align the mesh with a normal
  94898. * @param normal defines the normal to use
  94899. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94900. * @returns the current mesh
  94901. */
  94902. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94903. /** @hidden */
  94904. _checkOcclusionQuery(): boolean;
  94905. /**
  94906. * Disables the mesh edge rendering mode
  94907. * @returns the currentAbstractMesh
  94908. */
  94909. disableEdgesRendering(): AbstractMesh;
  94910. /**
  94911. * Enables the edge rendering mode on the mesh.
  94912. * This mode makes the mesh edges visible
  94913. * @param epsilon defines the maximal distance between two angles to detect a face
  94914. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94915. * @returns the currentAbstractMesh
  94916. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94917. */
  94918. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94919. }
  94920. }
  94921. declare module BABYLON {
  94922. /**
  94923. * Interface used to define ActionEvent
  94924. */
  94925. export interface IActionEvent {
  94926. /** The mesh or sprite that triggered the action */
  94927. source: any;
  94928. /** The X mouse cursor position at the time of the event */
  94929. pointerX: number;
  94930. /** The Y mouse cursor position at the time of the event */
  94931. pointerY: number;
  94932. /** The mesh that is currently pointed at (can be null) */
  94933. meshUnderPointer: Nullable<AbstractMesh>;
  94934. /** the original (browser) event that triggered the ActionEvent */
  94935. sourceEvent?: any;
  94936. /** additional data for the event */
  94937. additionalData?: any;
  94938. }
  94939. /**
  94940. * ActionEvent is the event being sent when an action is triggered.
  94941. */
  94942. export class ActionEvent implements IActionEvent {
  94943. /** The mesh or sprite that triggered the action */
  94944. source: any;
  94945. /** The X mouse cursor position at the time of the event */
  94946. pointerX: number;
  94947. /** The Y mouse cursor position at the time of the event */
  94948. pointerY: number;
  94949. /** The mesh that is currently pointed at (can be null) */
  94950. meshUnderPointer: Nullable<AbstractMesh>;
  94951. /** the original (browser) event that triggered the ActionEvent */
  94952. sourceEvent?: any;
  94953. /** additional data for the event */
  94954. additionalData?: any;
  94955. /**
  94956. * Creates a new ActionEvent
  94957. * @param source The mesh or sprite that triggered the action
  94958. * @param pointerX The X mouse cursor position at the time of the event
  94959. * @param pointerY The Y mouse cursor position at the time of the event
  94960. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94961. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94962. * @param additionalData additional data for the event
  94963. */
  94964. constructor(
  94965. /** The mesh or sprite that triggered the action */
  94966. source: any,
  94967. /** The X mouse cursor position at the time of the event */
  94968. pointerX: number,
  94969. /** The Y mouse cursor position at the time of the event */
  94970. pointerY: number,
  94971. /** The mesh that is currently pointed at (can be null) */
  94972. meshUnderPointer: Nullable<AbstractMesh>,
  94973. /** the original (browser) event that triggered the ActionEvent */
  94974. sourceEvent?: any,
  94975. /** additional data for the event */
  94976. additionalData?: any);
  94977. /**
  94978. * Helper function to auto-create an ActionEvent from a source mesh.
  94979. * @param source The source mesh that triggered the event
  94980. * @param evt The original (browser) event
  94981. * @param additionalData additional data for the event
  94982. * @returns the new ActionEvent
  94983. */
  94984. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94985. /**
  94986. * Helper function to auto-create an ActionEvent from a source sprite
  94987. * @param source The source sprite that triggered the event
  94988. * @param scene Scene associated with the sprite
  94989. * @param evt The original (browser) event
  94990. * @param additionalData additional data for the event
  94991. * @returns the new ActionEvent
  94992. */
  94993. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94994. /**
  94995. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94996. * @param scene the scene where the event occurred
  94997. * @param evt The original (browser) event
  94998. * @returns the new ActionEvent
  94999. */
  95000. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95001. /**
  95002. * Helper function to auto-create an ActionEvent from a primitive
  95003. * @param prim defines the target primitive
  95004. * @param pointerPos defines the pointer position
  95005. * @param evt The original (browser) event
  95006. * @param additionalData additional data for the event
  95007. * @returns the new ActionEvent
  95008. */
  95009. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95010. }
  95011. }
  95012. declare module BABYLON {
  95013. /**
  95014. * Abstract class used to decouple action Manager from scene and meshes.
  95015. * Do not instantiate.
  95016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95017. */
  95018. export abstract class AbstractActionManager implements IDisposable {
  95019. /** Gets the list of active triggers */
  95020. static Triggers: {
  95021. [key: string]: number;
  95022. };
  95023. /** Gets the cursor to use when hovering items */
  95024. hoverCursor: string;
  95025. /** Gets the list of actions */
  95026. actions: IAction[];
  95027. /**
  95028. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95029. */
  95030. isRecursive: boolean;
  95031. /**
  95032. * Releases all associated resources
  95033. */
  95034. abstract dispose(): void;
  95035. /**
  95036. * Does this action manager has pointer triggers
  95037. */
  95038. abstract readonly hasPointerTriggers: boolean;
  95039. /**
  95040. * Does this action manager has pick triggers
  95041. */
  95042. abstract readonly hasPickTriggers: boolean;
  95043. /**
  95044. * Process a specific trigger
  95045. * @param trigger defines the trigger to process
  95046. * @param evt defines the event details to be processed
  95047. */
  95048. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95049. /**
  95050. * Does this action manager handles actions of any of the given triggers
  95051. * @param triggers defines the triggers to be tested
  95052. * @return a boolean indicating whether one (or more) of the triggers is handled
  95053. */
  95054. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95055. /**
  95056. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95057. * speed.
  95058. * @param triggerA defines the trigger to be tested
  95059. * @param triggerB defines the trigger to be tested
  95060. * @return a boolean indicating whether one (or more) of the triggers is handled
  95061. */
  95062. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95063. /**
  95064. * Does this action manager handles actions of a given trigger
  95065. * @param trigger defines the trigger to be tested
  95066. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95067. * @return whether the trigger is handled
  95068. */
  95069. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95070. /**
  95071. * Serialize this manager to a JSON object
  95072. * @param name defines the property name to store this manager
  95073. * @returns a JSON representation of this manager
  95074. */
  95075. abstract serialize(name: string): any;
  95076. /**
  95077. * Registers an action to this action manager
  95078. * @param action defines the action to be registered
  95079. * @return the action amended (prepared) after registration
  95080. */
  95081. abstract registerAction(action: IAction): Nullable<IAction>;
  95082. /**
  95083. * Unregisters an action to this action manager
  95084. * @param action defines the action to be unregistered
  95085. * @return a boolean indicating whether the action has been unregistered
  95086. */
  95087. abstract unregisterAction(action: IAction): Boolean;
  95088. /**
  95089. * Does exist one action manager with at least one trigger
  95090. **/
  95091. static readonly HasTriggers: boolean;
  95092. /**
  95093. * Does exist one action manager with at least one pick trigger
  95094. **/
  95095. static readonly HasPickTriggers: boolean;
  95096. /**
  95097. * Does exist one action manager that handles actions of a given trigger
  95098. * @param trigger defines the trigger to be tested
  95099. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95100. **/
  95101. static HasSpecificTrigger(trigger: number): boolean;
  95102. }
  95103. }
  95104. declare module BABYLON {
  95105. /**
  95106. * Defines how a node can be built from a string name.
  95107. */
  95108. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95109. /**
  95110. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95111. */
  95112. export class Node implements IBehaviorAware<Node> {
  95113. /** @hidden */
  95114. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95115. private static _NodeConstructors;
  95116. /**
  95117. * Add a new node constructor
  95118. * @param type defines the type name of the node to construct
  95119. * @param constructorFunc defines the constructor function
  95120. */
  95121. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95122. /**
  95123. * Returns a node constructor based on type name
  95124. * @param type defines the type name
  95125. * @param name defines the new node name
  95126. * @param scene defines the hosting scene
  95127. * @param options defines optional options to transmit to constructors
  95128. * @returns the new constructor or null
  95129. */
  95130. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95131. /**
  95132. * Gets or sets the name of the node
  95133. */
  95134. name: string;
  95135. /**
  95136. * Gets or sets the id of the node
  95137. */
  95138. id: string;
  95139. /**
  95140. * Gets or sets the unique id of the node
  95141. */
  95142. uniqueId: number;
  95143. /**
  95144. * Gets or sets a string used to store user defined state for the node
  95145. */
  95146. state: string;
  95147. /**
  95148. * Gets or sets an object used to store user defined information for the node
  95149. */
  95150. metadata: any;
  95151. /**
  95152. * For internal use only. Please do not use.
  95153. */
  95154. reservedDataStore: any;
  95155. /**
  95156. * List of inspectable custom properties (used by the Inspector)
  95157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95158. */
  95159. inspectableCustomProperties: IInspectable[];
  95160. private _doNotSerialize;
  95161. /**
  95162. * Gets or sets a boolean used to define if the node must be serialized
  95163. */
  95164. doNotSerialize: boolean;
  95165. /** @hidden */
  95166. _isDisposed: boolean;
  95167. /**
  95168. * Gets a list of Animations associated with the node
  95169. */
  95170. animations: Animation[];
  95171. protected _ranges: {
  95172. [name: string]: Nullable<AnimationRange>;
  95173. };
  95174. /**
  95175. * Callback raised when the node is ready to be used
  95176. */
  95177. onReady: Nullable<(node: Node) => void>;
  95178. private _isEnabled;
  95179. private _isParentEnabled;
  95180. private _isReady;
  95181. /** @hidden */
  95182. _currentRenderId: number;
  95183. private _parentUpdateId;
  95184. /** @hidden */
  95185. _childUpdateId: number;
  95186. /** @hidden */
  95187. _waitingParentId: Nullable<string>;
  95188. /** @hidden */
  95189. _scene: Scene;
  95190. /** @hidden */
  95191. _cache: any;
  95192. private _parentNode;
  95193. private _children;
  95194. /** @hidden */
  95195. _worldMatrix: Matrix;
  95196. /** @hidden */
  95197. _worldMatrixDeterminant: number;
  95198. /** @hidden */
  95199. _worldMatrixDeterminantIsDirty: boolean;
  95200. /** @hidden */
  95201. private _sceneRootNodesIndex;
  95202. /**
  95203. * Gets a boolean indicating if the node has been disposed
  95204. * @returns true if the node was disposed
  95205. */
  95206. isDisposed(): boolean;
  95207. /**
  95208. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95209. * @see https://doc.babylonjs.com/how_to/parenting
  95210. */
  95211. parent: Nullable<Node>;
  95212. /** @hidden */
  95213. _addToSceneRootNodes(): void;
  95214. /** @hidden */
  95215. _removeFromSceneRootNodes(): void;
  95216. private _animationPropertiesOverride;
  95217. /**
  95218. * Gets or sets the animation properties override
  95219. */
  95220. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95221. /**
  95222. * Gets a string idenfifying the name of the class
  95223. * @returns "Node" string
  95224. */
  95225. getClassName(): string;
  95226. /** @hidden */
  95227. readonly _isNode: boolean;
  95228. /**
  95229. * An event triggered when the mesh is disposed
  95230. */
  95231. onDisposeObservable: Observable<Node>;
  95232. private _onDisposeObserver;
  95233. /**
  95234. * Sets a callback that will be raised when the node will be disposed
  95235. */
  95236. onDispose: () => void;
  95237. /**
  95238. * Creates a new Node
  95239. * @param name the name and id to be given to this node
  95240. * @param scene the scene this node will be added to
  95241. */
  95242. constructor(name: string, scene?: Nullable<Scene>);
  95243. /**
  95244. * Gets the scene of the node
  95245. * @returns a scene
  95246. */
  95247. getScene(): Scene;
  95248. /**
  95249. * Gets the engine of the node
  95250. * @returns a Engine
  95251. */
  95252. getEngine(): Engine;
  95253. private _behaviors;
  95254. /**
  95255. * Attach a behavior to the node
  95256. * @see http://doc.babylonjs.com/features/behaviour
  95257. * @param behavior defines the behavior to attach
  95258. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95259. * @returns the current Node
  95260. */
  95261. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95262. /**
  95263. * Remove an attached behavior
  95264. * @see http://doc.babylonjs.com/features/behaviour
  95265. * @param behavior defines the behavior to attach
  95266. * @returns the current Node
  95267. */
  95268. removeBehavior(behavior: Behavior<Node>): Node;
  95269. /**
  95270. * Gets the list of attached behaviors
  95271. * @see http://doc.babylonjs.com/features/behaviour
  95272. */
  95273. readonly behaviors: Behavior<Node>[];
  95274. /**
  95275. * Gets an attached behavior by name
  95276. * @param name defines the name of the behavior to look for
  95277. * @see http://doc.babylonjs.com/features/behaviour
  95278. * @returns null if behavior was not found else the requested behavior
  95279. */
  95280. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95281. /**
  95282. * Returns the latest update of the World matrix
  95283. * @returns a Matrix
  95284. */
  95285. getWorldMatrix(): Matrix;
  95286. /** @hidden */
  95287. _getWorldMatrixDeterminant(): number;
  95288. /**
  95289. * Returns directly the latest state of the mesh World matrix.
  95290. * A Matrix is returned.
  95291. */
  95292. readonly worldMatrixFromCache: Matrix;
  95293. /** @hidden */
  95294. _initCache(): void;
  95295. /** @hidden */
  95296. updateCache(force?: boolean): void;
  95297. /** @hidden */
  95298. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95299. /** @hidden */
  95300. _updateCache(ignoreParentClass?: boolean): void;
  95301. /** @hidden */
  95302. _isSynchronized(): boolean;
  95303. /** @hidden */
  95304. _markSyncedWithParent(): void;
  95305. /** @hidden */
  95306. isSynchronizedWithParent(): boolean;
  95307. /** @hidden */
  95308. isSynchronized(): boolean;
  95309. /**
  95310. * Is this node ready to be used/rendered
  95311. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95312. * @return true if the node is ready
  95313. */
  95314. isReady(completeCheck?: boolean): boolean;
  95315. /**
  95316. * Is this node enabled?
  95317. * 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
  95318. * @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
  95319. * @return whether this node (and its parent) is enabled
  95320. */
  95321. isEnabled(checkAncestors?: boolean): boolean;
  95322. /** @hidden */
  95323. protected _syncParentEnabledState(): void;
  95324. /**
  95325. * Set the enabled state of this node
  95326. * @param value defines the new enabled state
  95327. */
  95328. setEnabled(value: boolean): void;
  95329. /**
  95330. * Is this node a descendant of the given node?
  95331. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95332. * @param ancestor defines the parent node to inspect
  95333. * @returns a boolean indicating if this node is a descendant of the given node
  95334. */
  95335. isDescendantOf(ancestor: Node): boolean;
  95336. /** @hidden */
  95337. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95338. /**
  95339. * Will return all nodes that have this node as ascendant
  95340. * @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
  95341. * @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
  95342. * @return all children nodes of all types
  95343. */
  95344. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95345. /**
  95346. * Get all child-meshes of this node
  95347. * @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)
  95348. * @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
  95349. * @returns an array of AbstractMesh
  95350. */
  95351. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95352. /**
  95353. * Get all direct children of this node
  95354. * @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
  95355. * @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)
  95356. * @returns an array of Node
  95357. */
  95358. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95359. /** @hidden */
  95360. _setReady(state: boolean): void;
  95361. /**
  95362. * Get an animation by name
  95363. * @param name defines the name of the animation to look for
  95364. * @returns null if not found else the requested animation
  95365. */
  95366. getAnimationByName(name: string): Nullable<Animation>;
  95367. /**
  95368. * Creates an animation range for this node
  95369. * @param name defines the name of the range
  95370. * @param from defines the starting key
  95371. * @param to defines the end key
  95372. */
  95373. createAnimationRange(name: string, from: number, to: number): void;
  95374. /**
  95375. * Delete a specific animation range
  95376. * @param name defines the name of the range to delete
  95377. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95378. */
  95379. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95380. /**
  95381. * Get an animation range by name
  95382. * @param name defines the name of the animation range to look for
  95383. * @returns null if not found else the requested animation range
  95384. */
  95385. getAnimationRange(name: string): Nullable<AnimationRange>;
  95386. /**
  95387. * Gets the list of all animation ranges defined on this node
  95388. * @returns an array
  95389. */
  95390. getAnimationRanges(): Nullable<AnimationRange>[];
  95391. /**
  95392. * Will start the animation sequence
  95393. * @param name defines the range frames for animation sequence
  95394. * @param loop defines if the animation should loop (false by default)
  95395. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95396. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95397. * @returns the object created for this animation. If range does not exist, it will return null
  95398. */
  95399. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95400. /**
  95401. * Serialize animation ranges into a JSON compatible object
  95402. * @returns serialization object
  95403. */
  95404. serializeAnimationRanges(): any;
  95405. /**
  95406. * Computes the world matrix of the node
  95407. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95408. * @returns the world matrix
  95409. */
  95410. computeWorldMatrix(force?: boolean): Matrix;
  95411. /**
  95412. * Releases resources associated with this node.
  95413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95415. */
  95416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95417. /**
  95418. * Parse animation range data from a serialization object and store them into a given node
  95419. * @param node defines where to store the animation ranges
  95420. * @param parsedNode defines the serialization object to read data from
  95421. * @param scene defines the hosting scene
  95422. */
  95423. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95424. /**
  95425. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95426. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95427. * @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
  95428. * @returns the new bounding vectors
  95429. */
  95430. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95431. min: Vector3;
  95432. max: Vector3;
  95433. };
  95434. }
  95435. }
  95436. declare module BABYLON {
  95437. /**
  95438. * @hidden
  95439. */
  95440. export class _IAnimationState {
  95441. key: number;
  95442. repeatCount: number;
  95443. workValue?: any;
  95444. loopMode?: number;
  95445. offsetValue?: any;
  95446. highLimitValue?: any;
  95447. }
  95448. /**
  95449. * Class used to store any kind of animation
  95450. */
  95451. export class Animation {
  95452. /**Name of the animation */
  95453. name: string;
  95454. /**Property to animate */
  95455. targetProperty: string;
  95456. /**The frames per second of the animation */
  95457. framePerSecond: number;
  95458. /**The data type of the animation */
  95459. dataType: number;
  95460. /**The loop mode of the animation */
  95461. loopMode?: number | undefined;
  95462. /**Specifies if blending should be enabled */
  95463. enableBlending?: boolean | undefined;
  95464. /**
  95465. * Use matrix interpolation instead of using direct key value when animating matrices
  95466. */
  95467. static AllowMatricesInterpolation: boolean;
  95468. /**
  95469. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95470. */
  95471. static AllowMatrixDecomposeForInterpolation: boolean;
  95472. /**
  95473. * Stores the key frames of the animation
  95474. */
  95475. private _keys;
  95476. /**
  95477. * Stores the easing function of the animation
  95478. */
  95479. private _easingFunction;
  95480. /**
  95481. * @hidden Internal use only
  95482. */
  95483. _runtimeAnimations: RuntimeAnimation[];
  95484. /**
  95485. * The set of event that will be linked to this animation
  95486. */
  95487. private _events;
  95488. /**
  95489. * Stores an array of target property paths
  95490. */
  95491. targetPropertyPath: string[];
  95492. /**
  95493. * Stores the blending speed of the animation
  95494. */
  95495. blendingSpeed: number;
  95496. /**
  95497. * Stores the animation ranges for the animation
  95498. */
  95499. private _ranges;
  95500. /**
  95501. * @hidden Internal use
  95502. */
  95503. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95504. /**
  95505. * Sets up an animation
  95506. * @param property The property to animate
  95507. * @param animationType The animation type to apply
  95508. * @param framePerSecond The frames per second of the animation
  95509. * @param easingFunction The easing function used in the animation
  95510. * @returns The created animation
  95511. */
  95512. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95513. /**
  95514. * Create and start an animation on a node
  95515. * @param name defines the name of the global animation that will be run on all nodes
  95516. * @param node defines the root node where the animation will take place
  95517. * @param targetProperty defines property to animate
  95518. * @param framePerSecond defines the number of frame per second yo use
  95519. * @param totalFrame defines the number of frames in total
  95520. * @param from defines the initial value
  95521. * @param to defines the final value
  95522. * @param loopMode defines which loop mode you want to use (off by default)
  95523. * @param easingFunction defines the easing function to use (linear by default)
  95524. * @param onAnimationEnd defines the callback to call when animation end
  95525. * @returns the animatable created for this animation
  95526. */
  95527. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95528. /**
  95529. * Create and start an animation on a node and its descendants
  95530. * @param name defines the name of the global animation that will be run on all nodes
  95531. * @param node defines the root node where the animation will take place
  95532. * @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
  95533. * @param targetProperty defines property to animate
  95534. * @param framePerSecond defines the number of frame per second to use
  95535. * @param totalFrame defines the number of frames in total
  95536. * @param from defines the initial value
  95537. * @param to defines the final value
  95538. * @param loopMode defines which loop mode you want to use (off by default)
  95539. * @param easingFunction defines the easing function to use (linear by default)
  95540. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95541. * @returns the list of animatables created for all nodes
  95542. * @example https://www.babylonjs-playground.com/#MH0VLI
  95543. */
  95544. 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[]>;
  95545. /**
  95546. * Creates a new animation, merges it with the existing animations and starts it
  95547. * @param name Name of the animation
  95548. * @param node Node which contains the scene that begins the animations
  95549. * @param targetProperty Specifies which property to animate
  95550. * @param framePerSecond The frames per second of the animation
  95551. * @param totalFrame The total number of frames
  95552. * @param from The frame at the beginning of the animation
  95553. * @param to The frame at the end of the animation
  95554. * @param loopMode Specifies the loop mode of the animation
  95555. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95556. * @param onAnimationEnd Callback to run once the animation is complete
  95557. * @returns Nullable animation
  95558. */
  95559. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95560. /**
  95561. * Transition property of an host to the target Value
  95562. * @param property The property to transition
  95563. * @param targetValue The target Value of the property
  95564. * @param host The object where the property to animate belongs
  95565. * @param scene Scene used to run the animation
  95566. * @param frameRate Framerate (in frame/s) to use
  95567. * @param transition The transition type we want to use
  95568. * @param duration The duration of the animation, in milliseconds
  95569. * @param onAnimationEnd Callback trigger at the end of the animation
  95570. * @returns Nullable animation
  95571. */
  95572. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95573. /**
  95574. * Return the array of runtime animations currently using this animation
  95575. */
  95576. readonly runtimeAnimations: RuntimeAnimation[];
  95577. /**
  95578. * Specifies if any of the runtime animations are currently running
  95579. */
  95580. readonly hasRunningRuntimeAnimations: boolean;
  95581. /**
  95582. * Initializes the animation
  95583. * @param name Name of the animation
  95584. * @param targetProperty Property to animate
  95585. * @param framePerSecond The frames per second of the animation
  95586. * @param dataType The data type of the animation
  95587. * @param loopMode The loop mode of the animation
  95588. * @param enableBlending Specifies if blending should be enabled
  95589. */
  95590. constructor(
  95591. /**Name of the animation */
  95592. name: string,
  95593. /**Property to animate */
  95594. targetProperty: string,
  95595. /**The frames per second of the animation */
  95596. framePerSecond: number,
  95597. /**The data type of the animation */
  95598. dataType: number,
  95599. /**The loop mode of the animation */
  95600. loopMode?: number | undefined,
  95601. /**Specifies if blending should be enabled */
  95602. enableBlending?: boolean | undefined);
  95603. /**
  95604. * Converts the animation to a string
  95605. * @param fullDetails support for multiple levels of logging within scene loading
  95606. * @returns String form of the animation
  95607. */
  95608. toString(fullDetails?: boolean): string;
  95609. /**
  95610. * Add an event to this animation
  95611. * @param event Event to add
  95612. */
  95613. addEvent(event: AnimationEvent): void;
  95614. /**
  95615. * Remove all events found at the given frame
  95616. * @param frame The frame to remove events from
  95617. */
  95618. removeEvents(frame: number): void;
  95619. /**
  95620. * Retrieves all the events from the animation
  95621. * @returns Events from the animation
  95622. */
  95623. getEvents(): AnimationEvent[];
  95624. /**
  95625. * Creates an animation range
  95626. * @param name Name of the animation range
  95627. * @param from Starting frame of the animation range
  95628. * @param to Ending frame of the animation
  95629. */
  95630. createRange(name: string, from: number, to: number): void;
  95631. /**
  95632. * Deletes an animation range by name
  95633. * @param name Name of the animation range to delete
  95634. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95635. */
  95636. deleteRange(name: string, deleteFrames?: boolean): void;
  95637. /**
  95638. * Gets the animation range by name, or null if not defined
  95639. * @param name Name of the animation range
  95640. * @returns Nullable animation range
  95641. */
  95642. getRange(name: string): Nullable<AnimationRange>;
  95643. /**
  95644. * Gets the key frames from the animation
  95645. * @returns The key frames of the animation
  95646. */
  95647. getKeys(): Array<IAnimationKey>;
  95648. /**
  95649. * Gets the highest frame rate of the animation
  95650. * @returns Highest frame rate of the animation
  95651. */
  95652. getHighestFrame(): number;
  95653. /**
  95654. * Gets the easing function of the animation
  95655. * @returns Easing function of the animation
  95656. */
  95657. getEasingFunction(): IEasingFunction;
  95658. /**
  95659. * Sets the easing function of the animation
  95660. * @param easingFunction A custom mathematical formula for animation
  95661. */
  95662. setEasingFunction(easingFunction: EasingFunction): void;
  95663. /**
  95664. * Interpolates a scalar linearly
  95665. * @param startValue Start value of the animation curve
  95666. * @param endValue End value of the animation curve
  95667. * @param gradient Scalar amount to interpolate
  95668. * @returns Interpolated scalar value
  95669. */
  95670. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95671. /**
  95672. * Interpolates a scalar cubically
  95673. * @param startValue Start value of the animation curve
  95674. * @param outTangent End tangent of the animation
  95675. * @param endValue End value of the animation curve
  95676. * @param inTangent Start tangent of the animation curve
  95677. * @param gradient Scalar amount to interpolate
  95678. * @returns Interpolated scalar value
  95679. */
  95680. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95681. /**
  95682. * Interpolates a quaternion using a spherical linear interpolation
  95683. * @param startValue Start value of the animation curve
  95684. * @param endValue End value of the animation curve
  95685. * @param gradient Scalar amount to interpolate
  95686. * @returns Interpolated quaternion value
  95687. */
  95688. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95689. /**
  95690. * Interpolates a quaternion cubically
  95691. * @param startValue Start value of the animation curve
  95692. * @param outTangent End tangent of the animation curve
  95693. * @param endValue End value of the animation curve
  95694. * @param inTangent Start tangent of the animation curve
  95695. * @param gradient Scalar amount to interpolate
  95696. * @returns Interpolated quaternion value
  95697. */
  95698. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95699. /**
  95700. * Interpolates a Vector3 linearl
  95701. * @param startValue Start value of the animation curve
  95702. * @param endValue End value of the animation curve
  95703. * @param gradient Scalar amount to interpolate
  95704. * @returns Interpolated scalar value
  95705. */
  95706. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95707. /**
  95708. * Interpolates a Vector3 cubically
  95709. * @param startValue Start value of the animation curve
  95710. * @param outTangent End tangent of the animation
  95711. * @param endValue End value of the animation curve
  95712. * @param inTangent Start tangent of the animation curve
  95713. * @param gradient Scalar amount to interpolate
  95714. * @returns InterpolatedVector3 value
  95715. */
  95716. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95717. /**
  95718. * Interpolates a Vector2 linearly
  95719. * @param startValue Start value of the animation curve
  95720. * @param endValue End value of the animation curve
  95721. * @param gradient Scalar amount to interpolate
  95722. * @returns Interpolated Vector2 value
  95723. */
  95724. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95725. /**
  95726. * Interpolates a Vector2 cubically
  95727. * @param startValue Start value of the animation curve
  95728. * @param outTangent End tangent of the animation
  95729. * @param endValue End value of the animation curve
  95730. * @param inTangent Start tangent of the animation curve
  95731. * @param gradient Scalar amount to interpolate
  95732. * @returns Interpolated Vector2 value
  95733. */
  95734. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95735. /**
  95736. * Interpolates a size linearly
  95737. * @param startValue Start value of the animation curve
  95738. * @param endValue End value of the animation curve
  95739. * @param gradient Scalar amount to interpolate
  95740. * @returns Interpolated Size value
  95741. */
  95742. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95743. /**
  95744. * Interpolates a Color3 linearly
  95745. * @param startValue Start value of the animation curve
  95746. * @param endValue End value of the animation curve
  95747. * @param gradient Scalar amount to interpolate
  95748. * @returns Interpolated Color3 value
  95749. */
  95750. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95751. /**
  95752. * Interpolates a Color4 linearly
  95753. * @param startValue Start value of the animation curve
  95754. * @param endValue End value of the animation curve
  95755. * @param gradient Scalar amount to interpolate
  95756. * @returns Interpolated Color3 value
  95757. */
  95758. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95759. /**
  95760. * @hidden Internal use only
  95761. */
  95762. _getKeyValue(value: any): any;
  95763. /**
  95764. * @hidden Internal use only
  95765. */
  95766. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95767. /**
  95768. * Defines the function to use to interpolate matrices
  95769. * @param startValue defines the start matrix
  95770. * @param endValue defines the end matrix
  95771. * @param gradient defines the gradient between both matrices
  95772. * @param result defines an optional target matrix where to store the interpolation
  95773. * @returns the interpolated matrix
  95774. */
  95775. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95776. /**
  95777. * Makes a copy of the animation
  95778. * @returns Cloned animation
  95779. */
  95780. clone(): Animation;
  95781. /**
  95782. * Sets the key frames of the animation
  95783. * @param values The animation key frames to set
  95784. */
  95785. setKeys(values: Array<IAnimationKey>): void;
  95786. /**
  95787. * Serializes the animation to an object
  95788. * @returns Serialized object
  95789. */
  95790. serialize(): any;
  95791. /**
  95792. * Float animation type
  95793. */
  95794. static readonly ANIMATIONTYPE_FLOAT: number;
  95795. /**
  95796. * Vector3 animation type
  95797. */
  95798. static readonly ANIMATIONTYPE_VECTOR3: number;
  95799. /**
  95800. * Quaternion animation type
  95801. */
  95802. static readonly ANIMATIONTYPE_QUATERNION: number;
  95803. /**
  95804. * Matrix animation type
  95805. */
  95806. static readonly ANIMATIONTYPE_MATRIX: number;
  95807. /**
  95808. * Color3 animation type
  95809. */
  95810. static readonly ANIMATIONTYPE_COLOR3: number;
  95811. /**
  95812. * Color3 animation type
  95813. */
  95814. static readonly ANIMATIONTYPE_COLOR4: number;
  95815. /**
  95816. * Vector2 animation type
  95817. */
  95818. static readonly ANIMATIONTYPE_VECTOR2: number;
  95819. /**
  95820. * Size animation type
  95821. */
  95822. static readonly ANIMATIONTYPE_SIZE: number;
  95823. /**
  95824. * Relative Loop Mode
  95825. */
  95826. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95827. /**
  95828. * Cycle Loop Mode
  95829. */
  95830. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95831. /**
  95832. * Constant Loop Mode
  95833. */
  95834. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95835. /** @hidden */
  95836. static _UniversalLerp(left: any, right: any, amount: number): any;
  95837. /**
  95838. * Parses an animation object and creates an animation
  95839. * @param parsedAnimation Parsed animation object
  95840. * @returns Animation object
  95841. */
  95842. static Parse(parsedAnimation: any): Animation;
  95843. /**
  95844. * Appends the serialized animations from the source animations
  95845. * @param source Source containing the animations
  95846. * @param destination Target to store the animations
  95847. */
  95848. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95849. }
  95850. }
  95851. declare module BABYLON {
  95852. /**
  95853. * Interface containing an array of animations
  95854. */
  95855. export interface IAnimatable {
  95856. /**
  95857. * Array of animations
  95858. */
  95859. animations: Nullable<Array<Animation>>;
  95860. }
  95861. }
  95862. declare module BABYLON {
  95863. /**
  95864. * This represents all the required information to add a fresnel effect on a material:
  95865. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95866. */
  95867. export class FresnelParameters {
  95868. private _isEnabled;
  95869. /**
  95870. * Define if the fresnel effect is enable or not.
  95871. */
  95872. isEnabled: boolean;
  95873. /**
  95874. * Define the color used on edges (grazing angle)
  95875. */
  95876. leftColor: Color3;
  95877. /**
  95878. * Define the color used on center
  95879. */
  95880. rightColor: Color3;
  95881. /**
  95882. * Define bias applied to computed fresnel term
  95883. */
  95884. bias: number;
  95885. /**
  95886. * Defined the power exponent applied to fresnel term
  95887. */
  95888. power: number;
  95889. /**
  95890. * Clones the current fresnel and its valuues
  95891. * @returns a clone fresnel configuration
  95892. */
  95893. clone(): FresnelParameters;
  95894. /**
  95895. * Serializes the current fresnel parameters to a JSON representation.
  95896. * @return the JSON serialization
  95897. */
  95898. serialize(): any;
  95899. /**
  95900. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95901. * @param parsedFresnelParameters Define the JSON representation
  95902. * @returns the parsed parameters
  95903. */
  95904. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95905. }
  95906. }
  95907. declare module BABYLON {
  95908. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95909. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95910. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95911. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95912. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95913. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95914. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95915. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95916. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95917. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95918. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95919. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95920. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95921. /**
  95922. * Decorator used to define property that can be serialized as reference to a camera
  95923. * @param sourceName defines the name of the property to decorate
  95924. */
  95925. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95926. /**
  95927. * Class used to help serialization objects
  95928. */
  95929. export class SerializationHelper {
  95930. /** @hidden */
  95931. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95932. /** @hidden */
  95933. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95934. /** @hidden */
  95935. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95936. /** @hidden */
  95937. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95938. /**
  95939. * Appends the serialized animations from the source animations
  95940. * @param source Source containing the animations
  95941. * @param destination Target to store the animations
  95942. */
  95943. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95944. /**
  95945. * Static function used to serialized a specific entity
  95946. * @param entity defines the entity to serialize
  95947. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95948. * @returns a JSON compatible object representing the serialization of the entity
  95949. */
  95950. static Serialize<T>(entity: T, serializationObject?: any): any;
  95951. /**
  95952. * Creates a new entity from a serialization data object
  95953. * @param creationFunction defines a function used to instanciated the new entity
  95954. * @param source defines the source serialization data
  95955. * @param scene defines the hosting scene
  95956. * @param rootUrl defines the root url for resources
  95957. * @returns a new entity
  95958. */
  95959. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95960. /**
  95961. * Clones an object
  95962. * @param creationFunction defines the function used to instanciate the new object
  95963. * @param source defines the source object
  95964. * @returns the cloned object
  95965. */
  95966. static Clone<T>(creationFunction: () => T, source: T): T;
  95967. /**
  95968. * Instanciates a new object based on a source one (some data will be shared between both object)
  95969. * @param creationFunction defines the function used to instanciate the new object
  95970. * @param source defines the source object
  95971. * @returns the new object
  95972. */
  95973. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95974. }
  95975. }
  95976. declare module BABYLON {
  95977. /**
  95978. * Class used to manipulate GUIDs
  95979. */
  95980. export class GUID {
  95981. /**
  95982. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95983. * Be aware Math.random() could cause collisions, but:
  95984. * "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"
  95985. * @returns a pseudo random id
  95986. */
  95987. static RandomId(): string;
  95988. }
  95989. }
  95990. declare module BABYLON {
  95991. /**
  95992. * Base class of all the textures in babylon.
  95993. * It groups all the common properties the materials, post process, lights... might need
  95994. * in order to make a correct use of the texture.
  95995. */
  95996. export class BaseTexture implements IAnimatable {
  95997. /**
  95998. * Default anisotropic filtering level for the application.
  95999. * It is set to 4 as a good tradeoff between perf and quality.
  96000. */
  96001. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96002. /**
  96003. * Gets or sets the unique id of the texture
  96004. */
  96005. uniqueId: number;
  96006. /**
  96007. * Define the name of the texture.
  96008. */
  96009. name: string;
  96010. /**
  96011. * Gets or sets an object used to store user defined information.
  96012. */
  96013. metadata: any;
  96014. /**
  96015. * For internal use only. Please do not use.
  96016. */
  96017. reservedDataStore: any;
  96018. private _hasAlpha;
  96019. /**
  96020. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96021. */
  96022. hasAlpha: boolean;
  96023. /**
  96024. * Defines if the alpha value should be determined via the rgb values.
  96025. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96026. */
  96027. getAlphaFromRGB: boolean;
  96028. /**
  96029. * Intensity or strength of the texture.
  96030. * It is commonly used by materials to fine tune the intensity of the texture
  96031. */
  96032. level: number;
  96033. /**
  96034. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96035. * This is part of the texture as textures usually maps to one uv set.
  96036. */
  96037. coordinatesIndex: number;
  96038. private _coordinatesMode;
  96039. /**
  96040. * How a texture is mapped.
  96041. *
  96042. * | Value | Type | Description |
  96043. * | ----- | ----------------------------------- | ----------- |
  96044. * | 0 | EXPLICIT_MODE | |
  96045. * | 1 | SPHERICAL_MODE | |
  96046. * | 2 | PLANAR_MODE | |
  96047. * | 3 | CUBIC_MODE | |
  96048. * | 4 | PROJECTION_MODE | |
  96049. * | 5 | SKYBOX_MODE | |
  96050. * | 6 | INVCUBIC_MODE | |
  96051. * | 7 | EQUIRECTANGULAR_MODE | |
  96052. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96053. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96054. */
  96055. coordinatesMode: number;
  96056. /**
  96057. * | Value | Type | Description |
  96058. * | ----- | ------------------ | ----------- |
  96059. * | 0 | CLAMP_ADDRESSMODE | |
  96060. * | 1 | WRAP_ADDRESSMODE | |
  96061. * | 2 | MIRROR_ADDRESSMODE | |
  96062. */
  96063. wrapU: number;
  96064. /**
  96065. * | Value | Type | Description |
  96066. * | ----- | ------------------ | ----------- |
  96067. * | 0 | CLAMP_ADDRESSMODE | |
  96068. * | 1 | WRAP_ADDRESSMODE | |
  96069. * | 2 | MIRROR_ADDRESSMODE | |
  96070. */
  96071. wrapV: number;
  96072. /**
  96073. * | Value | Type | Description |
  96074. * | ----- | ------------------ | ----------- |
  96075. * | 0 | CLAMP_ADDRESSMODE | |
  96076. * | 1 | WRAP_ADDRESSMODE | |
  96077. * | 2 | MIRROR_ADDRESSMODE | |
  96078. */
  96079. wrapR: number;
  96080. /**
  96081. * With compliant hardware and browser (supporting anisotropic filtering)
  96082. * this defines the level of anisotropic filtering in the texture.
  96083. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96084. */
  96085. anisotropicFilteringLevel: number;
  96086. /**
  96087. * Define if the texture is a cube texture or if false a 2d texture.
  96088. */
  96089. isCube: boolean;
  96090. /**
  96091. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96092. */
  96093. is3D: boolean;
  96094. /**
  96095. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96096. */
  96097. is2DArray: boolean;
  96098. /**
  96099. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96100. * HDR texture are usually stored in linear space.
  96101. * This only impacts the PBR and Background materials
  96102. */
  96103. gammaSpace: boolean;
  96104. /**
  96105. * Gets or sets whether or not the texture contains RGBD data.
  96106. */
  96107. isRGBD: boolean;
  96108. /**
  96109. * Is Z inverted in the texture (useful in a cube texture).
  96110. */
  96111. invertZ: boolean;
  96112. /**
  96113. * Are mip maps generated for this texture or not.
  96114. */
  96115. readonly noMipmap: boolean;
  96116. /**
  96117. * @hidden
  96118. */
  96119. lodLevelInAlpha: boolean;
  96120. /**
  96121. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96122. */
  96123. lodGenerationOffset: number;
  96124. /**
  96125. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96126. */
  96127. lodGenerationScale: number;
  96128. /**
  96129. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96130. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96131. * average roughness values.
  96132. */
  96133. linearSpecularLOD: boolean;
  96134. /**
  96135. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96136. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96137. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96138. */
  96139. irradianceTexture: Nullable<BaseTexture>;
  96140. /**
  96141. * Define if the texture is a render target.
  96142. */
  96143. isRenderTarget: boolean;
  96144. /**
  96145. * Define the unique id of the texture in the scene.
  96146. */
  96147. readonly uid: string;
  96148. /**
  96149. * Return a string representation of the texture.
  96150. * @returns the texture as a string
  96151. */
  96152. toString(): string;
  96153. /**
  96154. * Get the class name of the texture.
  96155. * @returns "BaseTexture"
  96156. */
  96157. getClassName(): string;
  96158. /**
  96159. * Define the list of animation attached to the texture.
  96160. */
  96161. animations: Animation[];
  96162. /**
  96163. * An event triggered when the texture is disposed.
  96164. */
  96165. onDisposeObservable: Observable<BaseTexture>;
  96166. private _onDisposeObserver;
  96167. /**
  96168. * Callback triggered when the texture has been disposed.
  96169. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96170. */
  96171. onDispose: () => void;
  96172. /**
  96173. * Define the current state of the loading sequence when in delayed load mode.
  96174. */
  96175. delayLoadState: number;
  96176. private _scene;
  96177. /** @hidden */
  96178. _texture: Nullable<InternalTexture>;
  96179. private _uid;
  96180. /**
  96181. * Define if the texture is preventinga material to render or not.
  96182. * If not and the texture is not ready, the engine will use a default black texture instead.
  96183. */
  96184. readonly isBlocking: boolean;
  96185. /**
  96186. * Instantiates a new BaseTexture.
  96187. * Base class of all the textures in babylon.
  96188. * It groups all the common properties the materials, post process, lights... might need
  96189. * in order to make a correct use of the texture.
  96190. * @param scene Define the scene the texture blongs to
  96191. */
  96192. constructor(scene: Nullable<Scene>);
  96193. /**
  96194. * Get the scene the texture belongs to.
  96195. * @returns the scene or null if undefined
  96196. */
  96197. getScene(): Nullable<Scene>;
  96198. /**
  96199. * Get the texture transform matrix used to offset tile the texture for istance.
  96200. * @returns the transformation matrix
  96201. */
  96202. getTextureMatrix(): Matrix;
  96203. /**
  96204. * Get the texture reflection matrix used to rotate/transform the reflection.
  96205. * @returns the reflection matrix
  96206. */
  96207. getReflectionTextureMatrix(): Matrix;
  96208. /**
  96209. * Get the underlying lower level texture from Babylon.
  96210. * @returns the insternal texture
  96211. */
  96212. getInternalTexture(): Nullable<InternalTexture>;
  96213. /**
  96214. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96215. * @returns true if ready or not blocking
  96216. */
  96217. isReadyOrNotBlocking(): boolean;
  96218. /**
  96219. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96220. * @returns true if fully ready
  96221. */
  96222. isReady(): boolean;
  96223. private _cachedSize;
  96224. /**
  96225. * Get the size of the texture.
  96226. * @returns the texture size.
  96227. */
  96228. getSize(): ISize;
  96229. /**
  96230. * Get the base size of the texture.
  96231. * It can be different from the size if the texture has been resized for POT for instance
  96232. * @returns the base size
  96233. */
  96234. getBaseSize(): ISize;
  96235. /**
  96236. * Update the sampling mode of the texture.
  96237. * Default is Trilinear mode.
  96238. *
  96239. * | Value | Type | Description |
  96240. * | ----- | ------------------ | ----------- |
  96241. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96242. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96243. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96244. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96245. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96246. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96247. * | 7 | NEAREST_LINEAR | |
  96248. * | 8 | NEAREST_NEAREST | |
  96249. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96250. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96251. * | 11 | LINEAR_LINEAR | |
  96252. * | 12 | LINEAR_NEAREST | |
  96253. *
  96254. * > _mag_: magnification filter (close to the viewer)
  96255. * > _min_: minification filter (far from the viewer)
  96256. * > _mip_: filter used between mip map levels
  96257. *@param samplingMode Define the new sampling mode of the texture
  96258. */
  96259. updateSamplingMode(samplingMode: number): void;
  96260. /**
  96261. * Scales the texture if is `canRescale()`
  96262. * @param ratio the resize factor we want to use to rescale
  96263. */
  96264. scale(ratio: number): void;
  96265. /**
  96266. * Get if the texture can rescale.
  96267. */
  96268. readonly canRescale: boolean;
  96269. /** @hidden */
  96270. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96271. /** @hidden */
  96272. _rebuild(): void;
  96273. /**
  96274. * Triggers the load sequence in delayed load mode.
  96275. */
  96276. delayLoad(): void;
  96277. /**
  96278. * Clones the texture.
  96279. * @returns the cloned texture
  96280. */
  96281. clone(): Nullable<BaseTexture>;
  96282. /**
  96283. * Get the texture underlying type (INT, FLOAT...)
  96284. */
  96285. readonly textureType: number;
  96286. /**
  96287. * Get the texture underlying format (RGB, RGBA...)
  96288. */
  96289. readonly textureFormat: number;
  96290. /**
  96291. * Indicates that textures need to be re-calculated for all materials
  96292. */
  96293. protected _markAllSubMeshesAsTexturesDirty(): void;
  96294. /**
  96295. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96296. * This will returns an RGBA array buffer containing either in values (0-255) or
  96297. * float values (0-1) depending of the underlying buffer type.
  96298. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96299. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96300. * @param buffer defines a user defined buffer to fill with data (can be null)
  96301. * @returns The Array buffer containing the pixels data.
  96302. */
  96303. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96304. /**
  96305. * Release and destroy the underlying lower level texture aka internalTexture.
  96306. */
  96307. releaseInternalTexture(): void;
  96308. /** @hidden */
  96309. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96310. /** @hidden */
  96311. readonly _lodTextureMid: Nullable<BaseTexture>;
  96312. /** @hidden */
  96313. readonly _lodTextureLow: Nullable<BaseTexture>;
  96314. /**
  96315. * Dispose the texture and release its associated resources.
  96316. */
  96317. dispose(): void;
  96318. /**
  96319. * Serialize the texture into a JSON representation that can be parsed later on.
  96320. * @returns the JSON representation of the texture
  96321. */
  96322. serialize(): any;
  96323. /**
  96324. * Helper function to be called back once a list of texture contains only ready textures.
  96325. * @param textures Define the list of textures to wait for
  96326. * @param callback Define the callback triggered once the entire list will be ready
  96327. */
  96328. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96329. }
  96330. }
  96331. declare module BABYLON {
  96332. /**
  96333. * Options to be used when creating an effect.
  96334. */
  96335. export interface IEffectCreationOptions {
  96336. /**
  96337. * Atrributes that will be used in the shader.
  96338. */
  96339. attributes: string[];
  96340. /**
  96341. * Uniform varible names that will be set in the shader.
  96342. */
  96343. uniformsNames: string[];
  96344. /**
  96345. * Uniform buffer varible names that will be set in the shader.
  96346. */
  96347. uniformBuffersNames: string[];
  96348. /**
  96349. * Sampler texture variable names that will be set in the shader.
  96350. */
  96351. samplers: string[];
  96352. /**
  96353. * Define statements that will be set in the shader.
  96354. */
  96355. defines: any;
  96356. /**
  96357. * Possible fallbacks for this effect to improve performance when needed.
  96358. */
  96359. fallbacks: Nullable<IEffectFallbacks>;
  96360. /**
  96361. * Callback that will be called when the shader is compiled.
  96362. */
  96363. onCompiled: Nullable<(effect: Effect) => void>;
  96364. /**
  96365. * Callback that will be called if an error occurs during shader compilation.
  96366. */
  96367. onError: Nullable<(effect: Effect, errors: string) => void>;
  96368. /**
  96369. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96370. */
  96371. indexParameters?: any;
  96372. /**
  96373. * Max number of lights that can be used in the shader.
  96374. */
  96375. maxSimultaneousLights?: number;
  96376. /**
  96377. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96378. */
  96379. transformFeedbackVaryings?: Nullable<string[]>;
  96380. }
  96381. /**
  96382. * Effect containing vertex and fragment shader that can be executed on an object.
  96383. */
  96384. export class Effect implements IDisposable {
  96385. /**
  96386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96387. */
  96388. static ShadersRepository: string;
  96389. /**
  96390. * Name of the effect.
  96391. */
  96392. name: any;
  96393. /**
  96394. * String container all the define statements that should be set on the shader.
  96395. */
  96396. defines: string;
  96397. /**
  96398. * Callback that will be called when the shader is compiled.
  96399. */
  96400. onCompiled: Nullable<(effect: Effect) => void>;
  96401. /**
  96402. * Callback that will be called if an error occurs during shader compilation.
  96403. */
  96404. onError: Nullable<(effect: Effect, errors: string) => void>;
  96405. /**
  96406. * Callback that will be called when effect is bound.
  96407. */
  96408. onBind: Nullable<(effect: Effect) => void>;
  96409. /**
  96410. * Unique ID of the effect.
  96411. */
  96412. uniqueId: number;
  96413. /**
  96414. * Observable that will be called when the shader is compiled.
  96415. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96416. */
  96417. onCompileObservable: Observable<Effect>;
  96418. /**
  96419. * Observable that will be called if an error occurs during shader compilation.
  96420. */
  96421. onErrorObservable: Observable<Effect>;
  96422. /** @hidden */
  96423. _onBindObservable: Nullable<Observable<Effect>>;
  96424. /**
  96425. * Observable that will be called when effect is bound.
  96426. */
  96427. readonly onBindObservable: Observable<Effect>;
  96428. /** @hidden */
  96429. _bonesComputationForcedToCPU: boolean;
  96430. private static _uniqueIdSeed;
  96431. private _engine;
  96432. private _uniformBuffersNames;
  96433. private _uniformsNames;
  96434. private _samplerList;
  96435. private _samplers;
  96436. private _isReady;
  96437. private _compilationError;
  96438. private _allFallbacksProcessed;
  96439. private _attributesNames;
  96440. private _attributes;
  96441. private _uniforms;
  96442. /**
  96443. * Key for the effect.
  96444. * @hidden
  96445. */
  96446. _key: string;
  96447. private _indexParameters;
  96448. private _fallbacks;
  96449. private _vertexSourceCode;
  96450. private _fragmentSourceCode;
  96451. private _vertexSourceCodeOverride;
  96452. private _fragmentSourceCodeOverride;
  96453. private _transformFeedbackVaryings;
  96454. /**
  96455. * Compiled shader to webGL program.
  96456. * @hidden
  96457. */
  96458. _pipelineContext: Nullable<IPipelineContext>;
  96459. private _valueCache;
  96460. private static _baseCache;
  96461. /**
  96462. * Instantiates an effect.
  96463. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96464. * @param baseName Name of the effect.
  96465. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96466. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96467. * @param samplers List of sampler variables that will be passed to the shader.
  96468. * @param engine Engine to be used to render the effect
  96469. * @param defines Define statements to be added to the shader.
  96470. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96471. * @param onCompiled Callback that will be called when the shader is compiled.
  96472. * @param onError Callback that will be called if an error occurs during shader compilation.
  96473. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96474. */
  96475. 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);
  96476. private _useFinalCode;
  96477. /**
  96478. * Unique key for this effect
  96479. */
  96480. readonly key: string;
  96481. /**
  96482. * If the effect has been compiled and prepared.
  96483. * @returns if the effect is compiled and prepared.
  96484. */
  96485. isReady(): boolean;
  96486. private _isReadyInternal;
  96487. /**
  96488. * The engine the effect was initialized with.
  96489. * @returns the engine.
  96490. */
  96491. getEngine(): Engine;
  96492. /**
  96493. * The pipeline context for this effect
  96494. * @returns the associated pipeline context
  96495. */
  96496. getPipelineContext(): Nullable<IPipelineContext>;
  96497. /**
  96498. * The set of names of attribute variables for the shader.
  96499. * @returns An array of attribute names.
  96500. */
  96501. getAttributesNames(): string[];
  96502. /**
  96503. * Returns the attribute at the given index.
  96504. * @param index The index of the attribute.
  96505. * @returns The location of the attribute.
  96506. */
  96507. getAttributeLocation(index: number): number;
  96508. /**
  96509. * Returns the attribute based on the name of the variable.
  96510. * @param name of the attribute to look up.
  96511. * @returns the attribute location.
  96512. */
  96513. getAttributeLocationByName(name: string): number;
  96514. /**
  96515. * The number of attributes.
  96516. * @returns the numnber of attributes.
  96517. */
  96518. getAttributesCount(): number;
  96519. /**
  96520. * Gets the index of a uniform variable.
  96521. * @param uniformName of the uniform to look up.
  96522. * @returns the index.
  96523. */
  96524. getUniformIndex(uniformName: string): number;
  96525. /**
  96526. * Returns the attribute based on the name of the variable.
  96527. * @param uniformName of the uniform to look up.
  96528. * @returns the location of the uniform.
  96529. */
  96530. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96531. /**
  96532. * Returns an array of sampler variable names
  96533. * @returns The array of sampler variable neames.
  96534. */
  96535. getSamplers(): string[];
  96536. /**
  96537. * The error from the last compilation.
  96538. * @returns the error string.
  96539. */
  96540. getCompilationError(): string;
  96541. /**
  96542. * Gets a boolean indicating that all fallbacks were used during compilation
  96543. * @returns true if all fallbacks were used
  96544. */
  96545. allFallbacksProcessed(): boolean;
  96546. /**
  96547. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96548. * @param func The callback to be used.
  96549. */
  96550. executeWhenCompiled(func: (effect: Effect) => void): void;
  96551. private _checkIsReady;
  96552. private _loadShader;
  96553. /**
  96554. * Recompiles the webGL program
  96555. * @param vertexSourceCode The source code for the vertex shader.
  96556. * @param fragmentSourceCode The source code for the fragment shader.
  96557. * @param onCompiled Callback called when completed.
  96558. * @param onError Callback called on error.
  96559. * @hidden
  96560. */
  96561. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96562. /**
  96563. * Prepares the effect
  96564. * @hidden
  96565. */
  96566. _prepareEffect(): void;
  96567. private _processCompilationErrors;
  96568. /**
  96569. * Checks if the effect is supported. (Must be called after compilation)
  96570. */
  96571. readonly isSupported: boolean;
  96572. /**
  96573. * Binds a texture to the engine to be used as output of the shader.
  96574. * @param channel Name of the output variable.
  96575. * @param texture Texture to bind.
  96576. * @hidden
  96577. */
  96578. _bindTexture(channel: string, texture: InternalTexture): void;
  96579. /**
  96580. * Sets a texture on the engine to be used in the shader.
  96581. * @param channel Name of the sampler variable.
  96582. * @param texture Texture to set.
  96583. */
  96584. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96585. /**
  96586. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96587. * @param channel Name of the sampler variable.
  96588. * @param texture Texture to set.
  96589. */
  96590. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96591. /**
  96592. * Sets an array of textures on the engine to be used in the shader.
  96593. * @param channel Name of the variable.
  96594. * @param textures Textures to set.
  96595. */
  96596. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96597. /**
  96598. * 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)
  96599. * @param channel Name of the sampler variable.
  96600. * @param postProcess Post process to get the input texture from.
  96601. */
  96602. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96603. /**
  96604. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96605. * 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)
  96606. * @param channel Name of the sampler variable.
  96607. * @param postProcess Post process to get the output texture from.
  96608. */
  96609. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96610. /** @hidden */
  96611. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96612. /** @hidden */
  96613. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96614. /** @hidden */
  96615. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96616. /** @hidden */
  96617. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96618. /**
  96619. * Binds a buffer to a uniform.
  96620. * @param buffer Buffer to bind.
  96621. * @param name Name of the uniform variable to bind to.
  96622. */
  96623. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96624. /**
  96625. * Binds block to a uniform.
  96626. * @param blockName Name of the block to bind.
  96627. * @param index Index to bind.
  96628. */
  96629. bindUniformBlock(blockName: string, index: number): void;
  96630. /**
  96631. * Sets an interger value on a uniform variable.
  96632. * @param uniformName Name of the variable.
  96633. * @param value Value to be set.
  96634. * @returns this effect.
  96635. */
  96636. setInt(uniformName: string, value: number): Effect;
  96637. /**
  96638. * Sets an int array on a uniform variable.
  96639. * @param uniformName Name of the variable.
  96640. * @param array array to be set.
  96641. * @returns this effect.
  96642. */
  96643. setIntArray(uniformName: string, array: Int32Array): Effect;
  96644. /**
  96645. * 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)
  96646. * @param uniformName Name of the variable.
  96647. * @param array array to be set.
  96648. * @returns this effect.
  96649. */
  96650. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96651. /**
  96652. * 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)
  96653. * @param uniformName Name of the variable.
  96654. * @param array array to be set.
  96655. * @returns this effect.
  96656. */
  96657. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96658. /**
  96659. * 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)
  96660. * @param uniformName Name of the variable.
  96661. * @param array array to be set.
  96662. * @returns this effect.
  96663. */
  96664. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96665. /**
  96666. * Sets an float array on a uniform variable.
  96667. * @param uniformName Name of the variable.
  96668. * @param array array to be set.
  96669. * @returns this effect.
  96670. */
  96671. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96672. /**
  96673. * 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)
  96674. * @param uniformName Name of the variable.
  96675. * @param array array to be set.
  96676. * @returns this effect.
  96677. */
  96678. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96679. /**
  96680. * 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)
  96681. * @param uniformName Name of the variable.
  96682. * @param array array to be set.
  96683. * @returns this effect.
  96684. */
  96685. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96686. /**
  96687. * 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)
  96688. * @param uniformName Name of the variable.
  96689. * @param array array to be set.
  96690. * @returns this effect.
  96691. */
  96692. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96693. /**
  96694. * Sets an array on a uniform variable.
  96695. * @param uniformName Name of the variable.
  96696. * @param array array to be set.
  96697. * @returns this effect.
  96698. */
  96699. setArray(uniformName: string, array: number[]): Effect;
  96700. /**
  96701. * 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)
  96702. * @param uniformName Name of the variable.
  96703. * @param array array to be set.
  96704. * @returns this effect.
  96705. */
  96706. setArray2(uniformName: string, array: number[]): Effect;
  96707. /**
  96708. * 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)
  96709. * @param uniformName Name of the variable.
  96710. * @param array array to be set.
  96711. * @returns this effect.
  96712. */
  96713. setArray3(uniformName: string, array: number[]): Effect;
  96714. /**
  96715. * 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)
  96716. * @param uniformName Name of the variable.
  96717. * @param array array to be set.
  96718. * @returns this effect.
  96719. */
  96720. setArray4(uniformName: string, array: number[]): Effect;
  96721. /**
  96722. * Sets matrices on a uniform variable.
  96723. * @param uniformName Name of the variable.
  96724. * @param matrices matrices to be set.
  96725. * @returns this effect.
  96726. */
  96727. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96728. /**
  96729. * Sets matrix on a uniform variable.
  96730. * @param uniformName Name of the variable.
  96731. * @param matrix matrix to be set.
  96732. * @returns this effect.
  96733. */
  96734. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96735. /**
  96736. * 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)
  96737. * @param uniformName Name of the variable.
  96738. * @param matrix matrix to be set.
  96739. * @returns this effect.
  96740. */
  96741. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96742. /**
  96743. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96744. * @param uniformName Name of the variable.
  96745. * @param matrix matrix to be set.
  96746. * @returns this effect.
  96747. */
  96748. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96749. /**
  96750. * Sets a float on a uniform variable.
  96751. * @param uniformName Name of the variable.
  96752. * @param value value to be set.
  96753. * @returns this effect.
  96754. */
  96755. setFloat(uniformName: string, value: number): Effect;
  96756. /**
  96757. * Sets a boolean on a uniform variable.
  96758. * @param uniformName Name of the variable.
  96759. * @param bool value to be set.
  96760. * @returns this effect.
  96761. */
  96762. setBool(uniformName: string, bool: boolean): Effect;
  96763. /**
  96764. * Sets a Vector2 on a uniform variable.
  96765. * @param uniformName Name of the variable.
  96766. * @param vector2 vector2 to be set.
  96767. * @returns this effect.
  96768. */
  96769. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96770. /**
  96771. * Sets a float2 on a uniform variable.
  96772. * @param uniformName Name of the variable.
  96773. * @param x First float in float2.
  96774. * @param y Second float in float2.
  96775. * @returns this effect.
  96776. */
  96777. setFloat2(uniformName: string, x: number, y: number): Effect;
  96778. /**
  96779. * Sets a Vector3 on a uniform variable.
  96780. * @param uniformName Name of the variable.
  96781. * @param vector3 Value to be set.
  96782. * @returns this effect.
  96783. */
  96784. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96785. /**
  96786. * Sets a float3 on a uniform variable.
  96787. * @param uniformName Name of the variable.
  96788. * @param x First float in float3.
  96789. * @param y Second float in float3.
  96790. * @param z Third float in float3.
  96791. * @returns this effect.
  96792. */
  96793. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96794. /**
  96795. * Sets a Vector4 on a uniform variable.
  96796. * @param uniformName Name of the variable.
  96797. * @param vector4 Value to be set.
  96798. * @returns this effect.
  96799. */
  96800. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96801. /**
  96802. * Sets a float4 on a uniform variable.
  96803. * @param uniformName Name of the variable.
  96804. * @param x First float in float4.
  96805. * @param y Second float in float4.
  96806. * @param z Third float in float4.
  96807. * @param w Fourth float in float4.
  96808. * @returns this effect.
  96809. */
  96810. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96811. /**
  96812. * Sets a Color3 on a uniform variable.
  96813. * @param uniformName Name of the variable.
  96814. * @param color3 Value to be set.
  96815. * @returns this effect.
  96816. */
  96817. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96818. /**
  96819. * Sets a Color4 on a uniform variable.
  96820. * @param uniformName Name of the variable.
  96821. * @param color3 Value to be set.
  96822. * @param alpha Alpha value to be set.
  96823. * @returns this effect.
  96824. */
  96825. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96826. /**
  96827. * Sets a Color4 on a uniform variable
  96828. * @param uniformName defines the name of the variable
  96829. * @param color4 defines the value to be set
  96830. * @returns this effect.
  96831. */
  96832. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96833. /** Release all associated resources */
  96834. dispose(): void;
  96835. /**
  96836. * This function will add a new shader to the shader store
  96837. * @param name the name of the shader
  96838. * @param pixelShader optional pixel shader content
  96839. * @param vertexShader optional vertex shader content
  96840. */
  96841. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96842. /**
  96843. * Store of each shader (The can be looked up using effect.key)
  96844. */
  96845. static ShadersStore: {
  96846. [key: string]: string;
  96847. };
  96848. /**
  96849. * Store of each included file for a shader (The can be looked up using effect.key)
  96850. */
  96851. static IncludesShadersStore: {
  96852. [key: string]: string;
  96853. };
  96854. /**
  96855. * Resets the cache of effects.
  96856. */
  96857. static ResetCache(): void;
  96858. }
  96859. }
  96860. declare module BABYLON {
  96861. /**
  96862. * Interface used to describe the capabilities of the engine relatively to the current browser
  96863. */
  96864. export interface EngineCapabilities {
  96865. /** Maximum textures units per fragment shader */
  96866. maxTexturesImageUnits: number;
  96867. /** Maximum texture units per vertex shader */
  96868. maxVertexTextureImageUnits: number;
  96869. /** Maximum textures units in the entire pipeline */
  96870. maxCombinedTexturesImageUnits: number;
  96871. /** Maximum texture size */
  96872. maxTextureSize: number;
  96873. /** Maximum cube texture size */
  96874. maxCubemapTextureSize: number;
  96875. /** Maximum render texture size */
  96876. maxRenderTextureSize: number;
  96877. /** Maximum number of vertex attributes */
  96878. maxVertexAttribs: number;
  96879. /** Maximum number of varyings */
  96880. maxVaryingVectors: number;
  96881. /** Maximum number of uniforms per vertex shader */
  96882. maxVertexUniformVectors: number;
  96883. /** Maximum number of uniforms per fragment shader */
  96884. maxFragmentUniformVectors: number;
  96885. /** Defines if standard derivates (dx/dy) are supported */
  96886. standardDerivatives: boolean;
  96887. /** Defines if s3tc texture compression is supported */
  96888. s3tc?: WEBGL_compressed_texture_s3tc;
  96889. /** Defines if pvrtc texture compression is supported */
  96890. pvrtc: any;
  96891. /** Defines if etc1 texture compression is supported */
  96892. etc1: any;
  96893. /** Defines if etc2 texture compression is supported */
  96894. etc2: any;
  96895. /** Defines if astc texture compression is supported */
  96896. astc: any;
  96897. /** Defines if float textures are supported */
  96898. textureFloat: boolean;
  96899. /** Defines if vertex array objects are supported */
  96900. vertexArrayObject: boolean;
  96901. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96902. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96903. /** Gets the maximum level of anisotropy supported */
  96904. maxAnisotropy: number;
  96905. /** Defines if instancing is supported */
  96906. instancedArrays: boolean;
  96907. /** Defines if 32 bits indices are supported */
  96908. uintIndices: boolean;
  96909. /** Defines if high precision shaders are supported */
  96910. highPrecisionShaderSupported: boolean;
  96911. /** Defines if depth reading in the fragment shader is supported */
  96912. fragmentDepthSupported: boolean;
  96913. /** Defines if float texture linear filtering is supported*/
  96914. textureFloatLinearFiltering: boolean;
  96915. /** Defines if rendering to float textures is supported */
  96916. textureFloatRender: boolean;
  96917. /** Defines if half float textures are supported*/
  96918. textureHalfFloat: boolean;
  96919. /** Defines if half float texture linear filtering is supported*/
  96920. textureHalfFloatLinearFiltering: boolean;
  96921. /** Defines if rendering to half float textures is supported */
  96922. textureHalfFloatRender: boolean;
  96923. /** Defines if textureLOD shader command is supported */
  96924. textureLOD: boolean;
  96925. /** Defines if draw buffers extension is supported */
  96926. drawBuffersExtension: boolean;
  96927. /** Defines if depth textures are supported */
  96928. depthTextureExtension: boolean;
  96929. /** Defines if float color buffer are supported */
  96930. colorBufferFloat: boolean;
  96931. /** Gets disjoint timer query extension (null if not supported) */
  96932. timerQuery?: EXT_disjoint_timer_query;
  96933. /** Defines if timestamp can be used with timer query */
  96934. canUseTimestampForTimerQuery: boolean;
  96935. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96936. multiview?: any;
  96937. /** Function used to let the system compiles shaders in background */
  96938. parallelShaderCompile?: {
  96939. COMPLETION_STATUS_KHR: number;
  96940. };
  96941. /** Max number of texture samples for MSAA */
  96942. maxMSAASamples: number;
  96943. /** Defines if the blend min max extension is supported */
  96944. blendMinMax: boolean;
  96945. }
  96946. }
  96947. declare module BABYLON {
  96948. /**
  96949. * @hidden
  96950. **/
  96951. export class DepthCullingState {
  96952. private _isDepthTestDirty;
  96953. private _isDepthMaskDirty;
  96954. private _isDepthFuncDirty;
  96955. private _isCullFaceDirty;
  96956. private _isCullDirty;
  96957. private _isZOffsetDirty;
  96958. private _isFrontFaceDirty;
  96959. private _depthTest;
  96960. private _depthMask;
  96961. private _depthFunc;
  96962. private _cull;
  96963. private _cullFace;
  96964. private _zOffset;
  96965. private _frontFace;
  96966. /**
  96967. * Initializes the state.
  96968. */
  96969. constructor();
  96970. readonly isDirty: boolean;
  96971. zOffset: number;
  96972. cullFace: Nullable<number>;
  96973. cull: Nullable<boolean>;
  96974. depthFunc: Nullable<number>;
  96975. depthMask: boolean;
  96976. depthTest: boolean;
  96977. frontFace: Nullable<number>;
  96978. reset(): void;
  96979. apply(gl: WebGLRenderingContext): void;
  96980. }
  96981. }
  96982. declare module BABYLON {
  96983. /**
  96984. * @hidden
  96985. **/
  96986. export class StencilState {
  96987. /** 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 */
  96988. static readonly ALWAYS: number;
  96989. /** Passed to stencilOperation to specify that stencil value must be kept */
  96990. static readonly KEEP: number;
  96991. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96992. static readonly REPLACE: number;
  96993. private _isStencilTestDirty;
  96994. private _isStencilMaskDirty;
  96995. private _isStencilFuncDirty;
  96996. private _isStencilOpDirty;
  96997. private _stencilTest;
  96998. private _stencilMask;
  96999. private _stencilFunc;
  97000. private _stencilFuncRef;
  97001. private _stencilFuncMask;
  97002. private _stencilOpStencilFail;
  97003. private _stencilOpDepthFail;
  97004. private _stencilOpStencilDepthPass;
  97005. readonly isDirty: boolean;
  97006. stencilFunc: number;
  97007. stencilFuncRef: number;
  97008. stencilFuncMask: number;
  97009. stencilOpStencilFail: number;
  97010. stencilOpDepthFail: number;
  97011. stencilOpStencilDepthPass: number;
  97012. stencilMask: number;
  97013. stencilTest: boolean;
  97014. constructor();
  97015. reset(): void;
  97016. apply(gl: WebGLRenderingContext): void;
  97017. }
  97018. }
  97019. declare module BABYLON {
  97020. /**
  97021. * @hidden
  97022. **/
  97023. export class AlphaState {
  97024. private _isAlphaBlendDirty;
  97025. private _isBlendFunctionParametersDirty;
  97026. private _isBlendEquationParametersDirty;
  97027. private _isBlendConstantsDirty;
  97028. private _alphaBlend;
  97029. private _blendFunctionParameters;
  97030. private _blendEquationParameters;
  97031. private _blendConstants;
  97032. /**
  97033. * Initializes the state.
  97034. */
  97035. constructor();
  97036. readonly isDirty: boolean;
  97037. alphaBlend: boolean;
  97038. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97039. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97040. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97041. reset(): void;
  97042. apply(gl: WebGLRenderingContext): void;
  97043. }
  97044. }
  97045. declare module BABYLON {
  97046. /** @hidden */
  97047. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97048. attributeProcessor(attribute: string): string;
  97049. varyingProcessor(varying: string, isFragment: boolean): string;
  97050. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97051. }
  97052. }
  97053. declare module BABYLON {
  97054. /**
  97055. * Interface for attribute information associated with buffer instanciation
  97056. */
  97057. export interface InstancingAttributeInfo {
  97058. /**
  97059. * Index/offset of the attribute in the vertex shader
  97060. */
  97061. index: number;
  97062. /**
  97063. * size of the attribute, 1, 2, 3 or 4
  97064. */
  97065. attributeSize: number;
  97066. /**
  97067. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97068. * default is FLOAT
  97069. */
  97070. attributeType: number;
  97071. /**
  97072. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97073. */
  97074. normalized: boolean;
  97075. /**
  97076. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97077. */
  97078. offset: number;
  97079. /**
  97080. * Name of the GLSL attribute, for debugging purpose only
  97081. */
  97082. attributeName: string;
  97083. }
  97084. }
  97085. declare module BABYLON {
  97086. interface ThinEngine {
  97087. /**
  97088. * Update a video texture
  97089. * @param texture defines the texture to update
  97090. * @param video defines the video element to use
  97091. * @param invertY defines if data must be stored with Y axis inverted
  97092. */
  97093. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97094. }
  97095. }
  97096. declare module BABYLON {
  97097. /**
  97098. * Settings for finer control over video usage
  97099. */
  97100. export interface VideoTextureSettings {
  97101. /**
  97102. * Applies `autoplay` to video, if specified
  97103. */
  97104. autoPlay?: boolean;
  97105. /**
  97106. * Applies `loop` to video, if specified
  97107. */
  97108. loop?: boolean;
  97109. /**
  97110. * Automatically updates internal texture from video at every frame in the render loop
  97111. */
  97112. autoUpdateTexture: boolean;
  97113. /**
  97114. * Image src displayed during the video loading or until the user interacts with the video.
  97115. */
  97116. poster?: string;
  97117. }
  97118. /**
  97119. * If you want to display a video in your scene, this is the special texture for that.
  97120. * This special texture works similar to other textures, with the exception of a few parameters.
  97121. * @see https://doc.babylonjs.com/how_to/video_texture
  97122. */
  97123. export class VideoTexture extends Texture {
  97124. /**
  97125. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97126. */
  97127. readonly autoUpdateTexture: boolean;
  97128. /**
  97129. * The video instance used by the texture internally
  97130. */
  97131. readonly video: HTMLVideoElement;
  97132. private _onUserActionRequestedObservable;
  97133. /**
  97134. * Event triggerd when a dom action is required by the user to play the video.
  97135. * This happens due to recent changes in browser policies preventing video to auto start.
  97136. */
  97137. readonly onUserActionRequestedObservable: Observable<Texture>;
  97138. private _generateMipMaps;
  97139. private _engine;
  97140. private _stillImageCaptured;
  97141. private _displayingPosterTexture;
  97142. private _settings;
  97143. private _createInternalTextureOnEvent;
  97144. private _frameId;
  97145. /**
  97146. * Creates a video texture.
  97147. * If you want to display a video in your scene, this is the special texture for that.
  97148. * This special texture works similar to other textures, with the exception of a few parameters.
  97149. * @see https://doc.babylonjs.com/how_to/video_texture
  97150. * @param name optional name, will detect from video source, if not defined
  97151. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97152. * @param scene is obviously the current scene.
  97153. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97154. * @param invertY is false by default but can be used to invert video on Y axis
  97155. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97156. * @param settings allows finer control over video usage
  97157. */
  97158. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97159. private _getName;
  97160. private _getVideo;
  97161. private _createInternalTexture;
  97162. private reset;
  97163. /**
  97164. * @hidden Internal method to initiate `update`.
  97165. */
  97166. _rebuild(): void;
  97167. /**
  97168. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97169. */
  97170. update(): void;
  97171. /**
  97172. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97173. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97174. */
  97175. updateTexture(isVisible: boolean): void;
  97176. protected _updateInternalTexture: () => void;
  97177. /**
  97178. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97179. * @param url New url.
  97180. */
  97181. updateURL(url: string): void;
  97182. /**
  97183. * Dispose the texture and release its associated resources.
  97184. */
  97185. dispose(): void;
  97186. /**
  97187. * Creates a video texture straight from a stream.
  97188. * @param scene Define the scene the texture should be created in
  97189. * @param stream Define the stream the texture should be created from
  97190. * @returns The created video texture as a promise
  97191. */
  97192. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97193. /**
  97194. * Creates a video texture straight from your WebCam video feed.
  97195. * @param scene Define the scene the texture should be created in
  97196. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97197. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97198. * @returns The created video texture as a promise
  97199. */
  97200. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97201. minWidth: number;
  97202. maxWidth: number;
  97203. minHeight: number;
  97204. maxHeight: number;
  97205. deviceId: string;
  97206. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97207. /**
  97208. * Creates a video texture straight from your WebCam video feed.
  97209. * @param scene Define the scene the texture should be created in
  97210. * @param onReady Define a callback to triggered once the texture will be ready
  97211. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97212. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97213. */
  97214. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97215. minWidth: number;
  97216. maxWidth: number;
  97217. minHeight: number;
  97218. maxHeight: number;
  97219. deviceId: string;
  97220. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97221. }
  97222. }
  97223. declare module BABYLON {
  97224. /**
  97225. * Defines the interface used by objects working like Scene
  97226. * @hidden
  97227. */
  97228. interface ISceneLike {
  97229. _addPendingData(data: any): void;
  97230. _removePendingData(data: any): void;
  97231. offlineProvider: IOfflineProvider;
  97232. }
  97233. /** Interface defining initialization parameters for Engine class */
  97234. export interface EngineOptions extends WebGLContextAttributes {
  97235. /**
  97236. * Defines if the engine should no exceed a specified device ratio
  97237. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97238. */
  97239. limitDeviceRatio?: number;
  97240. /**
  97241. * Defines if webvr should be enabled automatically
  97242. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97243. */
  97244. autoEnableWebVR?: boolean;
  97245. /**
  97246. * Defines if webgl2 should be turned off even if supported
  97247. * @see http://doc.babylonjs.com/features/webgl2
  97248. */
  97249. disableWebGL2Support?: boolean;
  97250. /**
  97251. * Defines if webaudio should be initialized as well
  97252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97253. */
  97254. audioEngine?: boolean;
  97255. /**
  97256. * Defines if animations should run using a deterministic lock step
  97257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97258. */
  97259. deterministicLockstep?: boolean;
  97260. /** Defines the maximum steps to use with deterministic lock step mode */
  97261. lockstepMaxSteps?: number;
  97262. /**
  97263. * Defines that engine should ignore context lost events
  97264. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97265. */
  97266. doNotHandleContextLost?: boolean;
  97267. /**
  97268. * Defines that engine should ignore modifying touch action attribute and style
  97269. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97270. */
  97271. doNotHandleTouchAction?: boolean;
  97272. /**
  97273. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97274. */
  97275. useHighPrecisionFloats?: boolean;
  97276. }
  97277. /**
  97278. * The base engine class (root of all engines)
  97279. */
  97280. export class ThinEngine {
  97281. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97282. static ExceptionList: ({
  97283. key: string;
  97284. capture: string;
  97285. captureConstraint: number;
  97286. targets: string[];
  97287. } | {
  97288. key: string;
  97289. capture: null;
  97290. captureConstraint: null;
  97291. targets: string[];
  97292. })[];
  97293. /** @hidden */
  97294. static _TextureLoaders: IInternalTextureLoader[];
  97295. /**
  97296. * Returns the current npm package of the sdk
  97297. */
  97298. static readonly NpmPackage: string;
  97299. /**
  97300. * Returns the current version of the framework
  97301. */
  97302. static readonly Version: string;
  97303. /**
  97304. * Returns a string describing the current engine
  97305. */
  97306. readonly description: string;
  97307. /**
  97308. * Gets or sets the epsilon value used by collision engine
  97309. */
  97310. static CollisionsEpsilon: number;
  97311. /**
  97312. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97313. */
  97314. static ShadersRepository: string;
  97315. /** @hidden */
  97316. _shaderProcessor: IShaderProcessor;
  97317. /**
  97318. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97319. */
  97320. forcePOTTextures: boolean;
  97321. /**
  97322. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97323. */
  97324. isFullscreen: boolean;
  97325. /**
  97326. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97327. */
  97328. cullBackFaces: boolean;
  97329. /**
  97330. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97331. */
  97332. renderEvenInBackground: boolean;
  97333. /**
  97334. * Gets or sets a boolean indicating that cache can be kept between frames
  97335. */
  97336. preventCacheWipeBetweenFrames: boolean;
  97337. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97338. validateShaderPrograms: boolean;
  97339. /**
  97340. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97341. */
  97342. disableUniformBuffers: boolean;
  97343. /** @hidden */
  97344. _uniformBuffers: UniformBuffer[];
  97345. /**
  97346. * Gets a boolean indicating that the engine supports uniform buffers
  97347. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97348. */
  97349. readonly supportsUniformBuffers: boolean;
  97350. /** @hidden */
  97351. _gl: WebGLRenderingContext;
  97352. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97353. protected _windowIsBackground: boolean;
  97354. protected _webGLVersion: number;
  97355. protected _creationOptions: EngineOptions;
  97356. protected _highPrecisionShadersAllowed: boolean;
  97357. /** @hidden */
  97358. readonly _shouldUseHighPrecisionShader: boolean;
  97359. /**
  97360. * Gets a boolean indicating that only power of 2 textures are supported
  97361. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97362. */
  97363. readonly needPOTTextures: boolean;
  97364. /** @hidden */
  97365. _badOS: boolean;
  97366. /** @hidden */
  97367. _badDesktopOS: boolean;
  97368. private _hardwareScalingLevel;
  97369. /** @hidden */
  97370. _caps: EngineCapabilities;
  97371. private _isStencilEnable;
  97372. protected _colorWrite: boolean;
  97373. private _glVersion;
  97374. private _glRenderer;
  97375. private _glVendor;
  97376. /** @hidden */
  97377. _videoTextureSupported: boolean;
  97378. protected _renderingQueueLaunched: boolean;
  97379. protected _activeRenderLoops: (() => void)[];
  97380. /**
  97381. * Observable signaled when a context lost event is raised
  97382. */
  97383. onContextLostObservable: Observable<ThinEngine>;
  97384. /**
  97385. * Observable signaled when a context restored event is raised
  97386. */
  97387. onContextRestoredObservable: Observable<ThinEngine>;
  97388. private _onContextLost;
  97389. private _onContextRestored;
  97390. protected _contextWasLost: boolean;
  97391. /** @hidden */
  97392. _doNotHandleContextLost: boolean;
  97393. /**
  97394. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97396. */
  97397. doNotHandleContextLost: boolean;
  97398. /**
  97399. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97400. */
  97401. disableVertexArrayObjects: boolean;
  97402. /** @hidden */
  97403. protected _depthCullingState: DepthCullingState;
  97404. /** @hidden */
  97405. protected _stencilState: StencilState;
  97406. /** @hidden */
  97407. protected _alphaState: AlphaState;
  97408. /** @hidden */
  97409. _internalTexturesCache: InternalTexture[];
  97410. /** @hidden */
  97411. protected _activeChannel: number;
  97412. private _currentTextureChannel;
  97413. /** @hidden */
  97414. protected _boundTexturesCache: {
  97415. [key: string]: Nullable<InternalTexture>;
  97416. };
  97417. /** @hidden */
  97418. protected _currentEffect: Nullable<Effect>;
  97419. /** @hidden */
  97420. protected _currentProgram: Nullable<WebGLProgram>;
  97421. private _compiledEffects;
  97422. private _vertexAttribArraysEnabled;
  97423. /** @hidden */
  97424. protected _cachedViewport: Nullable<IViewportLike>;
  97425. private _cachedVertexArrayObject;
  97426. /** @hidden */
  97427. protected _cachedVertexBuffers: any;
  97428. /** @hidden */
  97429. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97430. /** @hidden */
  97431. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97432. /** @hidden */
  97433. _currentRenderTarget: Nullable<InternalTexture>;
  97434. private _uintIndicesCurrentlySet;
  97435. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97436. /** @hidden */
  97437. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97438. private _currentBufferPointers;
  97439. private _currentInstanceLocations;
  97440. private _currentInstanceBuffers;
  97441. private _textureUnits;
  97442. /** @hidden */
  97443. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97444. /** @hidden */
  97445. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97446. /** @hidden */
  97447. _boundRenderFunction: any;
  97448. private _vaoRecordInProgress;
  97449. private _mustWipeVertexAttributes;
  97450. private _emptyTexture;
  97451. private _emptyCubeTexture;
  97452. private _emptyTexture3D;
  97453. private _emptyTexture2DArray;
  97454. /** @hidden */
  97455. _frameHandler: number;
  97456. private _nextFreeTextureSlots;
  97457. private _maxSimultaneousTextures;
  97458. private _activeRequests;
  97459. protected _texturesSupported: string[];
  97460. /** @hidden */
  97461. _textureFormatInUse: Nullable<string>;
  97462. protected readonly _supportsHardwareTextureRescaling: boolean;
  97463. /**
  97464. * Gets the list of texture formats supported
  97465. */
  97466. readonly texturesSupported: Array<string>;
  97467. /**
  97468. * Gets the list of texture formats in use
  97469. */
  97470. readonly textureFormatInUse: Nullable<string>;
  97471. /**
  97472. * Gets the current viewport
  97473. */
  97474. readonly currentViewport: Nullable<IViewportLike>;
  97475. /**
  97476. * Gets the default empty texture
  97477. */
  97478. readonly emptyTexture: InternalTexture;
  97479. /**
  97480. * Gets the default empty 3D texture
  97481. */
  97482. readonly emptyTexture3D: InternalTexture;
  97483. /**
  97484. * Gets the default empty 2D array texture
  97485. */
  97486. readonly emptyTexture2DArray: InternalTexture;
  97487. /**
  97488. * Gets the default empty cube texture
  97489. */
  97490. readonly emptyCubeTexture: InternalTexture;
  97491. /**
  97492. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97493. */
  97494. readonly premultipliedAlpha: boolean;
  97495. /**
  97496. * Observable event triggered before each texture is initialized
  97497. */
  97498. onBeforeTextureInitObservable: Observable<Texture>;
  97499. /**
  97500. * Creates a new engine
  97501. * @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
  97502. * @param antialias defines enable antialiasing (default: false)
  97503. * @param options defines further options to be sent to the getContext() function
  97504. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97505. */
  97506. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97507. private _rebuildInternalTextures;
  97508. private _rebuildEffects;
  97509. /**
  97510. * Gets a boolean indicating if all created effects are ready
  97511. * @returns true if all effects are ready
  97512. */
  97513. areAllEffectsReady(): boolean;
  97514. protected _rebuildBuffers(): void;
  97515. private _initGLContext;
  97516. /**
  97517. * Gets version of the current webGL context
  97518. */
  97519. readonly webGLVersion: number;
  97520. /**
  97521. * Gets a string idenfifying the name of the class
  97522. * @returns "Engine" string
  97523. */
  97524. getClassName(): string;
  97525. /**
  97526. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97527. */
  97528. readonly isStencilEnable: boolean;
  97529. /** @hidden */
  97530. _prepareWorkingCanvas(): void;
  97531. /**
  97532. * Reset the texture cache to empty state
  97533. */
  97534. resetTextureCache(): void;
  97535. /**
  97536. * Gets an object containing information about the current webGL context
  97537. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97538. */
  97539. getGlInfo(): {
  97540. vendor: string;
  97541. renderer: string;
  97542. version: string;
  97543. };
  97544. /**
  97545. * Defines the hardware scaling level.
  97546. * By default the hardware scaling level is computed from the window device ratio.
  97547. * 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.
  97548. * @param level defines the level to use
  97549. */
  97550. setHardwareScalingLevel(level: number): void;
  97551. /**
  97552. * Gets the current hardware scaling level.
  97553. * By default the hardware scaling level is computed from the window device ratio.
  97554. * 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.
  97555. * @returns a number indicating the current hardware scaling level
  97556. */
  97557. getHardwareScalingLevel(): number;
  97558. /**
  97559. * Gets the list of loaded textures
  97560. * @returns an array containing all loaded textures
  97561. */
  97562. getLoadedTexturesCache(): InternalTexture[];
  97563. /**
  97564. * Gets the object containing all engine capabilities
  97565. * @returns the EngineCapabilities object
  97566. */
  97567. getCaps(): EngineCapabilities;
  97568. /**
  97569. * stop executing a render loop function and remove it from the execution array
  97570. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97571. */
  97572. stopRenderLoop(renderFunction?: () => void): void;
  97573. /** @hidden */
  97574. _renderLoop(): void;
  97575. /**
  97576. * Gets the HTML canvas attached with the current webGL context
  97577. * @returns a HTML canvas
  97578. */
  97579. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97580. /**
  97581. * Gets host window
  97582. * @returns the host window object
  97583. */
  97584. getHostWindow(): Nullable<Window>;
  97585. /**
  97586. * Gets the current render width
  97587. * @param useScreen defines if screen size must be used (or the current render target if any)
  97588. * @returns a number defining the current render width
  97589. */
  97590. getRenderWidth(useScreen?: boolean): number;
  97591. /**
  97592. * Gets the current render height
  97593. * @param useScreen defines if screen size must be used (or the current render target if any)
  97594. * @returns a number defining the current render height
  97595. */
  97596. getRenderHeight(useScreen?: boolean): number;
  97597. /**
  97598. * Can be used to override the current requestAnimationFrame requester.
  97599. * @hidden
  97600. */
  97601. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97602. /**
  97603. * Register and execute a render loop. The engine can have more than one render function
  97604. * @param renderFunction defines the function to continuously execute
  97605. */
  97606. runRenderLoop(renderFunction: () => void): void;
  97607. /**
  97608. * Clear the current render buffer or the current render target (if any is set up)
  97609. * @param color defines the color to use
  97610. * @param backBuffer defines if the back buffer must be cleared
  97611. * @param depth defines if the depth buffer must be cleared
  97612. * @param stencil defines if the stencil buffer must be cleared
  97613. */
  97614. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97615. private _viewportCached;
  97616. /** @hidden */
  97617. _viewport(x: number, y: number, width: number, height: number): void;
  97618. /**
  97619. * Set the WebGL's viewport
  97620. * @param viewport defines the viewport element to be used
  97621. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97622. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97623. */
  97624. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97625. /**
  97626. * Begin a new frame
  97627. */
  97628. beginFrame(): void;
  97629. /**
  97630. * Enf the current frame
  97631. */
  97632. endFrame(): void;
  97633. /**
  97634. * Resize the view according to the canvas' size
  97635. */
  97636. resize(): void;
  97637. /**
  97638. * Force a specific size of the canvas
  97639. * @param width defines the new canvas' width
  97640. * @param height defines the new canvas' height
  97641. */
  97642. setSize(width: number, height: number): void;
  97643. /**
  97644. * Binds the frame buffer to the specified texture.
  97645. * @param texture The texture to render to or null for the default canvas
  97646. * @param faceIndex The face of the texture to render to in case of cube texture
  97647. * @param requiredWidth The width of the target to render to
  97648. * @param requiredHeight The height of the target to render to
  97649. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97650. * @param depthStencilTexture The depth stencil texture to use to render
  97651. * @param lodLevel defines le lod level to bind to the frame buffer
  97652. */
  97653. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97654. /** @hidden */
  97655. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97656. /**
  97657. * Unbind the current render target texture from the webGL context
  97658. * @param texture defines the render target texture to unbind
  97659. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97660. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97661. */
  97662. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97663. /**
  97664. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97665. */
  97666. flushFramebuffer(): void;
  97667. /**
  97668. * Unbind the current render target and bind the default framebuffer
  97669. */
  97670. restoreDefaultFramebuffer(): void;
  97671. /** @hidden */
  97672. protected _resetVertexBufferBinding(): void;
  97673. /**
  97674. * Creates a vertex buffer
  97675. * @param data the data for the vertex buffer
  97676. * @returns the new WebGL static buffer
  97677. */
  97678. createVertexBuffer(data: DataArray): DataBuffer;
  97679. private _createVertexBuffer;
  97680. /**
  97681. * Creates a dynamic vertex buffer
  97682. * @param data the data for the dynamic vertex buffer
  97683. * @returns the new WebGL dynamic buffer
  97684. */
  97685. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97686. protected _resetIndexBufferBinding(): void;
  97687. /**
  97688. * Creates a new index buffer
  97689. * @param indices defines the content of the index buffer
  97690. * @param updatable defines if the index buffer must be updatable
  97691. * @returns a new webGL buffer
  97692. */
  97693. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97694. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97695. /**
  97696. * Bind a webGL buffer to the webGL context
  97697. * @param buffer defines the buffer to bind
  97698. */
  97699. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97700. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97701. private bindBuffer;
  97702. /**
  97703. * update the bound buffer with the given data
  97704. * @param data defines the data to update
  97705. */
  97706. updateArrayBuffer(data: Float32Array): void;
  97707. private _vertexAttribPointer;
  97708. private _bindIndexBufferWithCache;
  97709. private _bindVertexBuffersAttributes;
  97710. /**
  97711. * Records a vertex array object
  97712. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97713. * @param vertexBuffers defines the list of vertex buffers to store
  97714. * @param indexBuffer defines the index buffer to store
  97715. * @param effect defines the effect to store
  97716. * @returns the new vertex array object
  97717. */
  97718. recordVertexArrayObject(vertexBuffers: {
  97719. [key: string]: VertexBuffer;
  97720. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97721. /**
  97722. * Bind a specific vertex array object
  97723. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97724. * @param vertexArrayObject defines the vertex array object to bind
  97725. * @param indexBuffer defines the index buffer to bind
  97726. */
  97727. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97728. /**
  97729. * Bind webGl buffers directly to the webGL context
  97730. * @param vertexBuffer defines the vertex buffer to bind
  97731. * @param indexBuffer defines the index buffer to bind
  97732. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97733. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97734. * @param effect defines the effect associated with the vertex buffer
  97735. */
  97736. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97737. private _unbindVertexArrayObject;
  97738. /**
  97739. * Bind a list of vertex buffers to the webGL context
  97740. * @param vertexBuffers defines the list of vertex buffers to bind
  97741. * @param indexBuffer defines the index buffer to bind
  97742. * @param effect defines the effect associated with the vertex buffers
  97743. */
  97744. bindBuffers(vertexBuffers: {
  97745. [key: string]: Nullable<VertexBuffer>;
  97746. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97747. /**
  97748. * Unbind all instance attributes
  97749. */
  97750. unbindInstanceAttributes(): void;
  97751. /**
  97752. * Release and free the memory of a vertex array object
  97753. * @param vao defines the vertex array object to delete
  97754. */
  97755. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97756. /** @hidden */
  97757. _releaseBuffer(buffer: DataBuffer): boolean;
  97758. protected _deleteBuffer(buffer: DataBuffer): void;
  97759. /**
  97760. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97761. * @param instancesBuffer defines the webGL buffer to update and bind
  97762. * @param data defines the data to store in the buffer
  97763. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97764. */
  97765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97766. /**
  97767. * Apply all cached states (depth, culling, stencil and alpha)
  97768. */
  97769. applyStates(): void;
  97770. /**
  97771. * Send a draw order
  97772. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97773. * @param indexStart defines the starting index
  97774. * @param indexCount defines the number of index to draw
  97775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97776. */
  97777. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97778. /**
  97779. * Draw a list of points
  97780. * @param verticesStart defines the index of first vertex to draw
  97781. * @param verticesCount defines the count of vertices to draw
  97782. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97783. */
  97784. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97785. /**
  97786. * Draw a list of unindexed primitives
  97787. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97788. * @param verticesStart defines the index of first vertex to draw
  97789. * @param verticesCount defines the count of vertices to draw
  97790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97791. */
  97792. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97793. /**
  97794. * Draw a list of indexed primitives
  97795. * @param fillMode defines the primitive to use
  97796. * @param indexStart defines the starting index
  97797. * @param indexCount defines the number of index to draw
  97798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97799. */
  97800. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97801. /**
  97802. * Draw a list of unindexed primitives
  97803. * @param fillMode defines the primitive to use
  97804. * @param verticesStart defines the index of first vertex to draw
  97805. * @param verticesCount defines the count of vertices to draw
  97806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97807. */
  97808. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97809. private _drawMode;
  97810. /** @hidden */
  97811. protected _reportDrawCall(): void;
  97812. /** @hidden */
  97813. _releaseEffect(effect: Effect): void;
  97814. /** @hidden */
  97815. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97816. /**
  97817. * Create a new effect (used to store vertex/fragment shaders)
  97818. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97819. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97820. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97821. * @param samplers defines an array of string used to represent textures
  97822. * @param defines defines the string containing the defines to use to compile the shaders
  97823. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97824. * @param onCompiled defines a function to call when the effect creation is successful
  97825. * @param onError defines a function to call when the effect creation has failed
  97826. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97827. * @returns the new Effect
  97828. */
  97829. 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;
  97830. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97831. private _compileShader;
  97832. private _compileRawShader;
  97833. /**
  97834. * Directly creates a webGL program
  97835. * @param pipelineContext defines the pipeline context to attach to
  97836. * @param vertexCode defines the vertex shader code to use
  97837. * @param fragmentCode defines the fragment shader code to use
  97838. * @param context defines the webGL context to use (if not set, the current one will be used)
  97839. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97840. * @returns the new webGL program
  97841. */
  97842. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97843. /**
  97844. * Creates a webGL program
  97845. * @param pipelineContext defines the pipeline context to attach to
  97846. * @param vertexCode defines the vertex shader code to use
  97847. * @param fragmentCode defines the fragment shader code to use
  97848. * @param defines defines the string containing the defines to use to compile the shaders
  97849. * @param context defines the webGL context to use (if not set, the current one will be used)
  97850. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97851. * @returns the new webGL program
  97852. */
  97853. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97854. /**
  97855. * Creates a new pipeline context
  97856. * @returns the new pipeline
  97857. */
  97858. createPipelineContext(): IPipelineContext;
  97859. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97860. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97861. /** @hidden */
  97862. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97863. /** @hidden */
  97864. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97865. /** @hidden */
  97866. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97867. /**
  97868. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97869. * @param pipelineContext defines the pipeline context to use
  97870. * @param uniformsNames defines the list of uniform names
  97871. * @returns an array of webGL uniform locations
  97872. */
  97873. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97874. /**
  97875. * Gets the lsit of active attributes for a given webGL program
  97876. * @param pipelineContext defines the pipeline context to use
  97877. * @param attributesNames defines the list of attribute names to get
  97878. * @returns an array of indices indicating the offset of each attribute
  97879. */
  97880. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97881. /**
  97882. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97883. * @param effect defines the effect to activate
  97884. */
  97885. enableEffect(effect: Nullable<Effect>): void;
  97886. /**
  97887. * Set the value of an uniform to a number (int)
  97888. * @param uniform defines the webGL uniform location where to store the value
  97889. * @param value defines the int number to store
  97890. */
  97891. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97892. /**
  97893. * Set the value of an uniform to an array of int32
  97894. * @param uniform defines the webGL uniform location where to store the value
  97895. * @param array defines the array of int32 to store
  97896. */
  97897. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97898. /**
  97899. * Set the value of an uniform to an array of int32 (stored as vec2)
  97900. * @param uniform defines the webGL uniform location where to store the value
  97901. * @param array defines the array of int32 to store
  97902. */
  97903. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97904. /**
  97905. * Set the value of an uniform to an array of int32 (stored as vec3)
  97906. * @param uniform defines the webGL uniform location where to store the value
  97907. * @param array defines the array of int32 to store
  97908. */
  97909. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97910. /**
  97911. * Set the value of an uniform to an array of int32 (stored as vec4)
  97912. * @param uniform defines the webGL uniform location where to store the value
  97913. * @param array defines the array of int32 to store
  97914. */
  97915. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97916. /**
  97917. * Set the value of an uniform to an array of number
  97918. * @param uniform defines the webGL uniform location where to store the value
  97919. * @param array defines the array of number to store
  97920. */
  97921. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97922. /**
  97923. * Set the value of an uniform to an array of number (stored as vec2)
  97924. * @param uniform defines the webGL uniform location where to store the value
  97925. * @param array defines the array of number to store
  97926. */
  97927. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97928. /**
  97929. * Set the value of an uniform to an array of number (stored as vec3)
  97930. * @param uniform defines the webGL uniform location where to store the value
  97931. * @param array defines the array of number to store
  97932. */
  97933. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97934. /**
  97935. * Set the value of an uniform to an array of number (stored as vec4)
  97936. * @param uniform defines the webGL uniform location where to store the value
  97937. * @param array defines the array of number to store
  97938. */
  97939. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97940. /**
  97941. * Set the value of an uniform to an array of float32 (stored as matrices)
  97942. * @param uniform defines the webGL uniform location where to store the value
  97943. * @param matrices defines the array of float32 to store
  97944. */
  97945. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97946. /**
  97947. * Set the value of an uniform to a matrix (3x3)
  97948. * @param uniform defines the webGL uniform location where to store the value
  97949. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97950. */
  97951. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97952. /**
  97953. * Set the value of an uniform to a matrix (2x2)
  97954. * @param uniform defines the webGL uniform location where to store the value
  97955. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97956. */
  97957. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97958. /**
  97959. * Set the value of an uniform to a number (float)
  97960. * @param uniform defines the webGL uniform location where to store the value
  97961. * @param value defines the float number to store
  97962. */
  97963. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97964. /**
  97965. * Set the value of an uniform to a vec2
  97966. * @param uniform defines the webGL uniform location where to store the value
  97967. * @param x defines the 1st component of the value
  97968. * @param y defines the 2nd component of the value
  97969. */
  97970. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97971. /**
  97972. * Set the value of an uniform to a vec3
  97973. * @param uniform defines the webGL uniform location where to store the value
  97974. * @param x defines the 1st component of the value
  97975. * @param y defines the 2nd component of the value
  97976. * @param z defines the 3rd component of the value
  97977. */
  97978. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97979. /**
  97980. * Set the value of an uniform to a vec4
  97981. * @param uniform defines the webGL uniform location where to store the value
  97982. * @param x defines the 1st component of the value
  97983. * @param y defines the 2nd component of the value
  97984. * @param z defines the 3rd component of the value
  97985. * @param w defines the 4th component of the value
  97986. */
  97987. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97988. /**
  97989. * Gets the depth culling state manager
  97990. */
  97991. readonly depthCullingState: DepthCullingState;
  97992. /**
  97993. * Gets the alpha state manager
  97994. */
  97995. readonly alphaState: AlphaState;
  97996. /**
  97997. * Gets the stencil state manager
  97998. */
  97999. readonly stencilState: StencilState;
  98000. /**
  98001. * Clears the list of texture accessible through engine.
  98002. * This can help preventing texture load conflict due to name collision.
  98003. */
  98004. clearInternalTexturesCache(): void;
  98005. /**
  98006. * Force the entire cache to be cleared
  98007. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98008. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98009. */
  98010. wipeCaches(bruteForce?: boolean): void;
  98011. /** @hidden */
  98012. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98013. min: number;
  98014. mag: number;
  98015. };
  98016. /** @hidden */
  98017. _createTexture(): WebGLTexture;
  98018. /**
  98019. * Usually called from Texture.ts.
  98020. * Passed information to create a WebGLTexture
  98021. * @param urlArg defines a value which contains one of the following:
  98022. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98023. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98024. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98025. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98026. * @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)
  98027. * @param scene needed for loading to the correct scene
  98028. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98029. * @param onLoad optional callback to be called upon successful completion
  98030. * @param onError optional callback to be called upon failure
  98031. * @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
  98032. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98033. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98034. * @param forcedExtension defines the extension to use to pick the right loader
  98035. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98036. * @param mimeType defines an optional mime type
  98037. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98038. */
  98039. 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;
  98040. /**
  98041. * @hidden
  98042. */
  98043. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98044. /**
  98045. * Creates a raw texture
  98046. * @param data defines the data to store in the texture
  98047. * @param width defines the width of the texture
  98048. * @param height defines the height of the texture
  98049. * @param format defines the format of the data
  98050. * @param generateMipMaps defines if the engine should generate the mip levels
  98051. * @param invertY defines if data must be stored with Y axis inverted
  98052. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98053. * @param compression defines the compression used (null by default)
  98054. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98055. * @returns the raw texture inside an InternalTexture
  98056. */
  98057. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98058. /**
  98059. * Creates a new raw cube texture
  98060. * @param data defines the array of data to use to create each face
  98061. * @param size defines the size of the textures
  98062. * @param format defines the format of the data
  98063. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98064. * @param generateMipMaps defines if the engine should generate the mip levels
  98065. * @param invertY defines if data must be stored with Y axis inverted
  98066. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98067. * @param compression defines the compression used (null by default)
  98068. * @returns the cube texture as an InternalTexture
  98069. */
  98070. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98071. /**
  98072. * Creates a new raw 3D texture
  98073. * @param data defines the data used to create the texture
  98074. * @param width defines the width of the texture
  98075. * @param height defines the height of the texture
  98076. * @param depth defines the depth of the texture
  98077. * @param format defines the format of the texture
  98078. * @param generateMipMaps defines if the engine must generate mip levels
  98079. * @param invertY defines if data must be stored with Y axis inverted
  98080. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98081. * @param compression defines the compressed used (can be null)
  98082. * @param textureType defines the compressed used (can be null)
  98083. * @returns a new raw 3D texture (stored in an InternalTexture)
  98084. */
  98085. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98086. /**
  98087. * Creates a new raw 2D array texture
  98088. * @param data defines the data used to create the texture
  98089. * @param width defines the width of the texture
  98090. * @param height defines the height of the texture
  98091. * @param depth defines the number of layers of the texture
  98092. * @param format defines the format of the texture
  98093. * @param generateMipMaps defines if the engine must generate mip levels
  98094. * @param invertY defines if data must be stored with Y axis inverted
  98095. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98096. * @param compression defines the compressed used (can be null)
  98097. * @param textureType defines the compressed used (can be null)
  98098. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98099. */
  98100. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98101. private _unpackFlipYCached;
  98102. /**
  98103. * In case you are sharing the context with other applications, it might
  98104. * be interested to not cache the unpack flip y state to ensure a consistent
  98105. * value would be set.
  98106. */
  98107. enableUnpackFlipYCached: boolean;
  98108. /** @hidden */
  98109. _unpackFlipY(value: boolean): void;
  98110. /** @hidden */
  98111. _getUnpackAlignement(): number;
  98112. /**
  98113. * Update the sampling mode of a given texture
  98114. * @param samplingMode defines the required sampling mode
  98115. * @param texture defines the texture to update
  98116. */
  98117. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98118. /** @hidden */
  98119. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98120. width: number;
  98121. height: number;
  98122. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98123. /** @hidden */
  98124. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98125. /** @hidden */
  98126. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98127. /** @hidden */
  98128. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98129. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98130. private _prepareWebGLTexture;
  98131. /** @hidden */
  98132. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98133. /** @hidden */
  98134. _releaseFramebufferObjects(texture: InternalTexture): void;
  98135. /** @hidden */
  98136. _releaseTexture(texture: InternalTexture): void;
  98137. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98138. protected _setProgram(program: WebGLProgram): void;
  98139. protected _boundUniforms: {
  98140. [key: number]: WebGLUniformLocation;
  98141. };
  98142. /**
  98143. * Binds an effect to the webGL context
  98144. * @param effect defines the effect to bind
  98145. */
  98146. bindSamplers(effect: Effect): void;
  98147. private _activateCurrentTexture;
  98148. /** @hidden */
  98149. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98150. /** @hidden */
  98151. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98152. /**
  98153. * Unbind all textures from the webGL context
  98154. */
  98155. unbindAllTextures(): void;
  98156. /**
  98157. * Sets a texture to the according uniform.
  98158. * @param channel The texture channel
  98159. * @param uniform The uniform to set
  98160. * @param texture The texture to apply
  98161. */
  98162. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98163. private _bindSamplerUniformToChannel;
  98164. private _getTextureWrapMode;
  98165. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98166. /**
  98167. * Sets an array of texture to the webGL context
  98168. * @param channel defines the channel where the texture array must be set
  98169. * @param uniform defines the associated uniform location
  98170. * @param textures defines the array of textures to bind
  98171. */
  98172. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98173. /** @hidden */
  98174. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98175. private _setTextureParameterFloat;
  98176. private _setTextureParameterInteger;
  98177. /**
  98178. * Unbind all vertex attributes from the webGL context
  98179. */
  98180. unbindAllAttributes(): void;
  98181. /**
  98182. * 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
  98183. */
  98184. releaseEffects(): void;
  98185. /**
  98186. * Dispose and release all associated resources
  98187. */
  98188. dispose(): void;
  98189. /**
  98190. * Attach a new callback raised when context lost event is fired
  98191. * @param callback defines the callback to call
  98192. */
  98193. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98194. /**
  98195. * Attach a new callback raised when context restored event is fired
  98196. * @param callback defines the callback to call
  98197. */
  98198. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98199. /**
  98200. * Get the current error code of the webGL context
  98201. * @returns the error code
  98202. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98203. */
  98204. getError(): number;
  98205. private _canRenderToFloatFramebuffer;
  98206. private _canRenderToHalfFloatFramebuffer;
  98207. private _canRenderToFramebuffer;
  98208. /** @hidden */
  98209. _getWebGLTextureType(type: number): number;
  98210. /** @hidden */
  98211. _getInternalFormat(format: number): number;
  98212. /** @hidden */
  98213. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98214. /** @hidden */
  98215. _getRGBAMultiSampleBufferFormat(type: number): number;
  98216. /** @hidden */
  98217. _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;
  98218. /**
  98219. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98220. * @returns true if the engine can be created
  98221. * @ignorenaming
  98222. */
  98223. static isSupported(): boolean;
  98224. /**
  98225. * Find the next highest power of two.
  98226. * @param x Number to start search from.
  98227. * @return Next highest power of two.
  98228. */
  98229. static CeilingPOT(x: number): number;
  98230. /**
  98231. * Find the next lowest power of two.
  98232. * @param x Number to start search from.
  98233. * @return Next lowest power of two.
  98234. */
  98235. static FloorPOT(x: number): number;
  98236. /**
  98237. * Find the nearest power of two.
  98238. * @param x Number to start search from.
  98239. * @return Next nearest power of two.
  98240. */
  98241. static NearestPOT(x: number): number;
  98242. /**
  98243. * Get the closest exponent of two
  98244. * @param value defines the value to approximate
  98245. * @param max defines the maximum value to return
  98246. * @param mode defines how to define the closest value
  98247. * @returns closest exponent of two of the given value
  98248. */
  98249. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98250. /**
  98251. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98252. * @param func - the function to be called
  98253. * @param requester - the object that will request the next frame. Falls back to window.
  98254. * @returns frame number
  98255. */
  98256. static QueueNewFrame(func: () => void, requester?: any): number;
  98257. }
  98258. }
  98259. declare module BABYLON {
  98260. /**
  98261. * Class representing spherical harmonics coefficients to the 3rd degree
  98262. */
  98263. export class SphericalHarmonics {
  98264. /**
  98265. * Defines whether or not the harmonics have been prescaled for rendering.
  98266. */
  98267. preScaled: boolean;
  98268. /**
  98269. * The l0,0 coefficients of the spherical harmonics
  98270. */
  98271. l00: Vector3;
  98272. /**
  98273. * The l1,-1 coefficients of the spherical harmonics
  98274. */
  98275. l1_1: Vector3;
  98276. /**
  98277. * The l1,0 coefficients of the spherical harmonics
  98278. */
  98279. l10: Vector3;
  98280. /**
  98281. * The l1,1 coefficients of the spherical harmonics
  98282. */
  98283. l11: Vector3;
  98284. /**
  98285. * The l2,-2 coefficients of the spherical harmonics
  98286. */
  98287. l2_2: Vector3;
  98288. /**
  98289. * The l2,-1 coefficients of the spherical harmonics
  98290. */
  98291. l2_1: Vector3;
  98292. /**
  98293. * The l2,0 coefficients of the spherical harmonics
  98294. */
  98295. l20: Vector3;
  98296. /**
  98297. * The l2,1 coefficients of the spherical harmonics
  98298. */
  98299. l21: Vector3;
  98300. /**
  98301. * The l2,2 coefficients of the spherical harmonics
  98302. */
  98303. l22: Vector3;
  98304. /**
  98305. * Adds a light to the spherical harmonics
  98306. * @param direction the direction of the light
  98307. * @param color the color of the light
  98308. * @param deltaSolidAngle the delta solid angle of the light
  98309. */
  98310. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98311. /**
  98312. * Scales the spherical harmonics by the given amount
  98313. * @param scale the amount to scale
  98314. */
  98315. scaleInPlace(scale: number): void;
  98316. /**
  98317. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98318. *
  98319. * ```
  98320. * E_lm = A_l * L_lm
  98321. * ```
  98322. *
  98323. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98324. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98325. * the scaling factors are given in equation 9.
  98326. */
  98327. convertIncidentRadianceToIrradiance(): void;
  98328. /**
  98329. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98330. *
  98331. * ```
  98332. * L = (1/pi) * E * rho
  98333. * ```
  98334. *
  98335. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98336. */
  98337. convertIrradianceToLambertianRadiance(): void;
  98338. /**
  98339. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98340. * required operations at run time.
  98341. *
  98342. * This is simply done by scaling back the SH with Ylm constants parameter.
  98343. * The trigonometric part being applied by the shader at run time.
  98344. */
  98345. preScaleForRendering(): void;
  98346. /**
  98347. * Constructs a spherical harmonics from an array.
  98348. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98349. * @returns the spherical harmonics
  98350. */
  98351. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98352. /**
  98353. * Gets the spherical harmonics from polynomial
  98354. * @param polynomial the spherical polynomial
  98355. * @returns the spherical harmonics
  98356. */
  98357. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98358. }
  98359. /**
  98360. * Class representing spherical polynomial coefficients to the 3rd degree
  98361. */
  98362. export class SphericalPolynomial {
  98363. private _harmonics;
  98364. /**
  98365. * The spherical harmonics used to create the polynomials.
  98366. */
  98367. readonly preScaledHarmonics: SphericalHarmonics;
  98368. /**
  98369. * The x coefficients of the spherical polynomial
  98370. */
  98371. x: Vector3;
  98372. /**
  98373. * The y coefficients of the spherical polynomial
  98374. */
  98375. y: Vector3;
  98376. /**
  98377. * The z coefficients of the spherical polynomial
  98378. */
  98379. z: Vector3;
  98380. /**
  98381. * The xx coefficients of the spherical polynomial
  98382. */
  98383. xx: Vector3;
  98384. /**
  98385. * The yy coefficients of the spherical polynomial
  98386. */
  98387. yy: Vector3;
  98388. /**
  98389. * The zz coefficients of the spherical polynomial
  98390. */
  98391. zz: Vector3;
  98392. /**
  98393. * The xy coefficients of the spherical polynomial
  98394. */
  98395. xy: Vector3;
  98396. /**
  98397. * The yz coefficients of the spherical polynomial
  98398. */
  98399. yz: Vector3;
  98400. /**
  98401. * The zx coefficients of the spherical polynomial
  98402. */
  98403. zx: Vector3;
  98404. /**
  98405. * Adds an ambient color to the spherical polynomial
  98406. * @param color the color to add
  98407. */
  98408. addAmbient(color: Color3): void;
  98409. /**
  98410. * Scales the spherical polynomial by the given amount
  98411. * @param scale the amount to scale
  98412. */
  98413. scaleInPlace(scale: number): void;
  98414. /**
  98415. * Gets the spherical polynomial from harmonics
  98416. * @param harmonics the spherical harmonics
  98417. * @returns the spherical polynomial
  98418. */
  98419. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98420. /**
  98421. * Constructs a spherical polynomial from an array.
  98422. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98423. * @returns the spherical polynomial
  98424. */
  98425. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98426. }
  98427. }
  98428. declare module BABYLON {
  98429. /**
  98430. * Defines the source of the internal texture
  98431. */
  98432. export enum InternalTextureSource {
  98433. /**
  98434. * The source of the texture data is unknown
  98435. */
  98436. Unknown = 0,
  98437. /**
  98438. * Texture data comes from an URL
  98439. */
  98440. Url = 1,
  98441. /**
  98442. * Texture data is only used for temporary storage
  98443. */
  98444. Temp = 2,
  98445. /**
  98446. * Texture data comes from raw data (ArrayBuffer)
  98447. */
  98448. Raw = 3,
  98449. /**
  98450. * Texture content is dynamic (video or dynamic texture)
  98451. */
  98452. Dynamic = 4,
  98453. /**
  98454. * Texture content is generated by rendering to it
  98455. */
  98456. RenderTarget = 5,
  98457. /**
  98458. * Texture content is part of a multi render target process
  98459. */
  98460. MultiRenderTarget = 6,
  98461. /**
  98462. * Texture data comes from a cube data file
  98463. */
  98464. Cube = 7,
  98465. /**
  98466. * Texture data comes from a raw cube data
  98467. */
  98468. CubeRaw = 8,
  98469. /**
  98470. * Texture data come from a prefiltered cube data file
  98471. */
  98472. CubePrefiltered = 9,
  98473. /**
  98474. * Texture content is raw 3D data
  98475. */
  98476. Raw3D = 10,
  98477. /**
  98478. * Texture content is raw 2D array data
  98479. */
  98480. Raw2DArray = 11,
  98481. /**
  98482. * Texture content is a depth texture
  98483. */
  98484. Depth = 12,
  98485. /**
  98486. * Texture data comes from a raw cube data encoded with RGBD
  98487. */
  98488. CubeRawRGBD = 13
  98489. }
  98490. /**
  98491. * Class used to store data associated with WebGL texture data for the engine
  98492. * This class should not be used directly
  98493. */
  98494. export class InternalTexture {
  98495. /** @hidden */
  98496. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98497. /**
  98498. * Defines if the texture is ready
  98499. */
  98500. isReady: boolean;
  98501. /**
  98502. * Defines if the texture is a cube texture
  98503. */
  98504. isCube: boolean;
  98505. /**
  98506. * Defines if the texture contains 3D data
  98507. */
  98508. is3D: boolean;
  98509. /**
  98510. * Defines if the texture contains 2D array data
  98511. */
  98512. is2DArray: boolean;
  98513. /**
  98514. * Defines if the texture contains multiview data
  98515. */
  98516. isMultiview: boolean;
  98517. /**
  98518. * Gets the URL used to load this texture
  98519. */
  98520. url: string;
  98521. /**
  98522. * Gets the sampling mode of the texture
  98523. */
  98524. samplingMode: number;
  98525. /**
  98526. * Gets a boolean indicating if the texture needs mipmaps generation
  98527. */
  98528. generateMipMaps: boolean;
  98529. /**
  98530. * Gets the number of samples used by the texture (WebGL2+ only)
  98531. */
  98532. samples: number;
  98533. /**
  98534. * Gets the type of the texture (int, float...)
  98535. */
  98536. type: number;
  98537. /**
  98538. * Gets the format of the texture (RGB, RGBA...)
  98539. */
  98540. format: number;
  98541. /**
  98542. * Observable called when the texture is loaded
  98543. */
  98544. onLoadedObservable: Observable<InternalTexture>;
  98545. /**
  98546. * Gets the width of the texture
  98547. */
  98548. width: number;
  98549. /**
  98550. * Gets the height of the texture
  98551. */
  98552. height: number;
  98553. /**
  98554. * Gets the depth of the texture
  98555. */
  98556. depth: number;
  98557. /**
  98558. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98559. */
  98560. baseWidth: number;
  98561. /**
  98562. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98563. */
  98564. baseHeight: number;
  98565. /**
  98566. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98567. */
  98568. baseDepth: number;
  98569. /**
  98570. * Gets a boolean indicating if the texture is inverted on Y axis
  98571. */
  98572. invertY: boolean;
  98573. /** @hidden */
  98574. _invertVScale: boolean;
  98575. /** @hidden */
  98576. _associatedChannel: number;
  98577. /** @hidden */
  98578. _source: InternalTextureSource;
  98579. /** @hidden */
  98580. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98581. /** @hidden */
  98582. _bufferView: Nullable<ArrayBufferView>;
  98583. /** @hidden */
  98584. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98585. /** @hidden */
  98586. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98587. /** @hidden */
  98588. _size: number;
  98589. /** @hidden */
  98590. _extension: string;
  98591. /** @hidden */
  98592. _files: Nullable<string[]>;
  98593. /** @hidden */
  98594. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98595. /** @hidden */
  98596. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98597. /** @hidden */
  98598. _framebuffer: Nullable<WebGLFramebuffer>;
  98599. /** @hidden */
  98600. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98601. /** @hidden */
  98602. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98603. /** @hidden */
  98604. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98605. /** @hidden */
  98606. _attachments: Nullable<number[]>;
  98607. /** @hidden */
  98608. _cachedCoordinatesMode: Nullable<number>;
  98609. /** @hidden */
  98610. _cachedWrapU: Nullable<number>;
  98611. /** @hidden */
  98612. _cachedWrapV: Nullable<number>;
  98613. /** @hidden */
  98614. _cachedWrapR: Nullable<number>;
  98615. /** @hidden */
  98616. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98617. /** @hidden */
  98618. _isDisabled: boolean;
  98619. /** @hidden */
  98620. _compression: Nullable<string>;
  98621. /** @hidden */
  98622. _generateStencilBuffer: boolean;
  98623. /** @hidden */
  98624. _generateDepthBuffer: boolean;
  98625. /** @hidden */
  98626. _comparisonFunction: number;
  98627. /** @hidden */
  98628. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98629. /** @hidden */
  98630. _lodGenerationScale: number;
  98631. /** @hidden */
  98632. _lodGenerationOffset: number;
  98633. /** @hidden */
  98634. _colorTextureArray: Nullable<WebGLTexture>;
  98635. /** @hidden */
  98636. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98637. /** @hidden */
  98638. _lodTextureHigh: Nullable<BaseTexture>;
  98639. /** @hidden */
  98640. _lodTextureMid: Nullable<BaseTexture>;
  98641. /** @hidden */
  98642. _lodTextureLow: Nullable<BaseTexture>;
  98643. /** @hidden */
  98644. _isRGBD: boolean;
  98645. /** @hidden */
  98646. _linearSpecularLOD: boolean;
  98647. /** @hidden */
  98648. _irradianceTexture: Nullable<BaseTexture>;
  98649. /** @hidden */
  98650. _webGLTexture: Nullable<WebGLTexture>;
  98651. /** @hidden */
  98652. _references: number;
  98653. private _engine;
  98654. /**
  98655. * Gets the Engine the texture belongs to.
  98656. * @returns The babylon engine
  98657. */
  98658. getEngine(): ThinEngine;
  98659. /**
  98660. * Gets the data source type of the texture
  98661. */
  98662. readonly source: InternalTextureSource;
  98663. /**
  98664. * Creates a new InternalTexture
  98665. * @param engine defines the engine to use
  98666. * @param source defines the type of data that will be used
  98667. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98668. */
  98669. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98670. /**
  98671. * Increments the number of references (ie. the number of Texture that point to it)
  98672. */
  98673. incrementReferences(): void;
  98674. /**
  98675. * Change the size of the texture (not the size of the content)
  98676. * @param width defines the new width
  98677. * @param height defines the new height
  98678. * @param depth defines the new depth (1 by default)
  98679. */
  98680. updateSize(width: int, height: int, depth?: int): void;
  98681. /** @hidden */
  98682. _rebuild(): void;
  98683. /** @hidden */
  98684. _swapAndDie(target: InternalTexture): void;
  98685. /**
  98686. * Dispose the current allocated resources
  98687. */
  98688. dispose(): void;
  98689. }
  98690. }
  98691. declare module BABYLON {
  98692. /**
  98693. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98695. */
  98696. export class Analyser {
  98697. /**
  98698. * Gets or sets the smoothing
  98699. * @ignorenaming
  98700. */
  98701. SMOOTHING: number;
  98702. /**
  98703. * Gets or sets the FFT table size
  98704. * @ignorenaming
  98705. */
  98706. FFT_SIZE: number;
  98707. /**
  98708. * Gets or sets the bar graph amplitude
  98709. * @ignorenaming
  98710. */
  98711. BARGRAPHAMPLITUDE: number;
  98712. /**
  98713. * Gets or sets the position of the debug canvas
  98714. * @ignorenaming
  98715. */
  98716. DEBUGCANVASPOS: {
  98717. x: number;
  98718. y: number;
  98719. };
  98720. /**
  98721. * Gets or sets the debug canvas size
  98722. * @ignorenaming
  98723. */
  98724. DEBUGCANVASSIZE: {
  98725. width: number;
  98726. height: number;
  98727. };
  98728. private _byteFreqs;
  98729. private _byteTime;
  98730. private _floatFreqs;
  98731. private _webAudioAnalyser;
  98732. private _debugCanvas;
  98733. private _debugCanvasContext;
  98734. private _scene;
  98735. private _registerFunc;
  98736. private _audioEngine;
  98737. /**
  98738. * Creates a new analyser
  98739. * @param scene defines hosting scene
  98740. */
  98741. constructor(scene: Scene);
  98742. /**
  98743. * Get the number of data values you will have to play with for the visualization
  98744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98745. * @returns a number
  98746. */
  98747. getFrequencyBinCount(): number;
  98748. /**
  98749. * Gets the current frequency data as a byte array
  98750. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98751. * @returns a Uint8Array
  98752. */
  98753. getByteFrequencyData(): Uint8Array;
  98754. /**
  98755. * Gets the current waveform as a byte array
  98756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98757. * @returns a Uint8Array
  98758. */
  98759. getByteTimeDomainData(): Uint8Array;
  98760. /**
  98761. * Gets the current frequency data as a float array
  98762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98763. * @returns a Float32Array
  98764. */
  98765. getFloatFrequencyData(): Float32Array;
  98766. /**
  98767. * Renders the debug canvas
  98768. */
  98769. drawDebugCanvas(): void;
  98770. /**
  98771. * Stops rendering the debug canvas and removes it
  98772. */
  98773. stopDebugCanvas(): void;
  98774. /**
  98775. * Connects two audio nodes
  98776. * @param inputAudioNode defines first node to connect
  98777. * @param outputAudioNode defines second node to connect
  98778. */
  98779. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98780. /**
  98781. * Releases all associated resources
  98782. */
  98783. dispose(): void;
  98784. }
  98785. }
  98786. declare module BABYLON {
  98787. /**
  98788. * This represents an audio engine and it is responsible
  98789. * to play, synchronize and analyse sounds throughout the application.
  98790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98791. */
  98792. export interface IAudioEngine extends IDisposable {
  98793. /**
  98794. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98795. */
  98796. readonly canUseWebAudio: boolean;
  98797. /**
  98798. * Gets the current AudioContext if available.
  98799. */
  98800. readonly audioContext: Nullable<AudioContext>;
  98801. /**
  98802. * The master gain node defines the global audio volume of your audio engine.
  98803. */
  98804. readonly masterGain: GainNode;
  98805. /**
  98806. * Gets whether or not mp3 are supported by your browser.
  98807. */
  98808. readonly isMP3supported: boolean;
  98809. /**
  98810. * Gets whether or not ogg are supported by your browser.
  98811. */
  98812. readonly isOGGsupported: boolean;
  98813. /**
  98814. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98815. * @ignoreNaming
  98816. */
  98817. WarnedWebAudioUnsupported: boolean;
  98818. /**
  98819. * Defines if the audio engine relies on a custom unlocked button.
  98820. * In this case, the embedded button will not be displayed.
  98821. */
  98822. useCustomUnlockedButton: boolean;
  98823. /**
  98824. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98825. */
  98826. readonly unlocked: boolean;
  98827. /**
  98828. * Event raised when audio has been unlocked on the browser.
  98829. */
  98830. onAudioUnlockedObservable: Observable<AudioEngine>;
  98831. /**
  98832. * Event raised when audio has been locked on the browser.
  98833. */
  98834. onAudioLockedObservable: Observable<AudioEngine>;
  98835. /**
  98836. * Flags the audio engine in Locked state.
  98837. * This happens due to new browser policies preventing audio to autoplay.
  98838. */
  98839. lock(): void;
  98840. /**
  98841. * Unlocks the audio engine once a user action has been done on the dom.
  98842. * This is helpful to resume play once browser policies have been satisfied.
  98843. */
  98844. unlock(): void;
  98845. }
  98846. /**
  98847. * This represents the default audio engine used in babylon.
  98848. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98850. */
  98851. export class AudioEngine implements IAudioEngine {
  98852. private _audioContext;
  98853. private _audioContextInitialized;
  98854. private _muteButton;
  98855. private _hostElement;
  98856. /**
  98857. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98858. */
  98859. canUseWebAudio: boolean;
  98860. /**
  98861. * The master gain node defines the global audio volume of your audio engine.
  98862. */
  98863. masterGain: GainNode;
  98864. /**
  98865. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98866. * @ignoreNaming
  98867. */
  98868. WarnedWebAudioUnsupported: boolean;
  98869. /**
  98870. * Gets whether or not mp3 are supported by your browser.
  98871. */
  98872. isMP3supported: boolean;
  98873. /**
  98874. * Gets whether or not ogg are supported by your browser.
  98875. */
  98876. isOGGsupported: boolean;
  98877. /**
  98878. * Gets whether audio has been unlocked on the device.
  98879. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98880. * a user interaction has happened.
  98881. */
  98882. unlocked: boolean;
  98883. /**
  98884. * Defines if the audio engine relies on a custom unlocked button.
  98885. * In this case, the embedded button will not be displayed.
  98886. */
  98887. useCustomUnlockedButton: boolean;
  98888. /**
  98889. * Event raised when audio has been unlocked on the browser.
  98890. */
  98891. onAudioUnlockedObservable: Observable<AudioEngine>;
  98892. /**
  98893. * Event raised when audio has been locked on the browser.
  98894. */
  98895. onAudioLockedObservable: Observable<AudioEngine>;
  98896. /**
  98897. * Gets the current AudioContext if available.
  98898. */
  98899. readonly audioContext: Nullable<AudioContext>;
  98900. private _connectedAnalyser;
  98901. /**
  98902. * Instantiates a new audio engine.
  98903. *
  98904. * There should be only one per page as some browsers restrict the number
  98905. * of audio contexts you can create.
  98906. * @param hostElement defines the host element where to display the mute icon if necessary
  98907. */
  98908. constructor(hostElement?: Nullable<HTMLElement>);
  98909. /**
  98910. * Flags the audio engine in Locked state.
  98911. * This happens due to new browser policies preventing audio to autoplay.
  98912. */
  98913. lock(): void;
  98914. /**
  98915. * Unlocks the audio engine once a user action has been done on the dom.
  98916. * This is helpful to resume play once browser policies have been satisfied.
  98917. */
  98918. unlock(): void;
  98919. private _resumeAudioContext;
  98920. private _initializeAudioContext;
  98921. private _tryToRun;
  98922. private _triggerRunningState;
  98923. private _triggerSuspendedState;
  98924. private _displayMuteButton;
  98925. private _moveButtonToTopLeft;
  98926. private _onResize;
  98927. private _hideMuteButton;
  98928. /**
  98929. * Destroy and release the resources associated with the audio ccontext.
  98930. */
  98931. dispose(): void;
  98932. /**
  98933. * Gets the global volume sets on the master gain.
  98934. * @returns the global volume if set or -1 otherwise
  98935. */
  98936. getGlobalVolume(): number;
  98937. /**
  98938. * Sets the global volume of your experience (sets on the master gain).
  98939. * @param newVolume Defines the new global volume of the application
  98940. */
  98941. setGlobalVolume(newVolume: number): void;
  98942. /**
  98943. * Connect the audio engine to an audio analyser allowing some amazing
  98944. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98946. * @param analyser The analyser to connect to the engine
  98947. */
  98948. connectToAnalyser(analyser: Analyser): void;
  98949. }
  98950. }
  98951. declare module BABYLON {
  98952. /**
  98953. * Interface used to present a loading screen while loading a scene
  98954. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98955. */
  98956. export interface ILoadingScreen {
  98957. /**
  98958. * Function called to display the loading screen
  98959. */
  98960. displayLoadingUI: () => void;
  98961. /**
  98962. * Function called to hide the loading screen
  98963. */
  98964. hideLoadingUI: () => void;
  98965. /**
  98966. * Gets or sets the color to use for the background
  98967. */
  98968. loadingUIBackgroundColor: string;
  98969. /**
  98970. * Gets or sets the text to display while loading
  98971. */
  98972. loadingUIText: string;
  98973. }
  98974. /**
  98975. * Class used for the default loading screen
  98976. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98977. */
  98978. export class DefaultLoadingScreen implements ILoadingScreen {
  98979. private _renderingCanvas;
  98980. private _loadingText;
  98981. private _loadingDivBackgroundColor;
  98982. private _loadingDiv;
  98983. private _loadingTextDiv;
  98984. /** Gets or sets the logo url to use for the default loading screen */
  98985. static DefaultLogoUrl: string;
  98986. /** Gets or sets the spinner url to use for the default loading screen */
  98987. static DefaultSpinnerUrl: string;
  98988. /**
  98989. * Creates a new default loading screen
  98990. * @param _renderingCanvas defines the canvas used to render the scene
  98991. * @param _loadingText defines the default text to display
  98992. * @param _loadingDivBackgroundColor defines the default background color
  98993. */
  98994. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98995. /**
  98996. * Function called to display the loading screen
  98997. */
  98998. displayLoadingUI(): void;
  98999. /**
  99000. * Function called to hide the loading screen
  99001. */
  99002. hideLoadingUI(): void;
  99003. /**
  99004. * Gets or sets the text to display while loading
  99005. */
  99006. loadingUIText: string;
  99007. /**
  99008. * Gets or sets the color to use for the background
  99009. */
  99010. loadingUIBackgroundColor: string;
  99011. private _resizeLoadingUI;
  99012. }
  99013. }
  99014. declare module BABYLON {
  99015. /**
  99016. * Interface for any object that can request an animation frame
  99017. */
  99018. export interface ICustomAnimationFrameRequester {
  99019. /**
  99020. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99021. */
  99022. renderFunction?: Function;
  99023. /**
  99024. * Called to request the next frame to render to
  99025. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99026. */
  99027. requestAnimationFrame: Function;
  99028. /**
  99029. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99030. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99031. */
  99032. requestID?: number;
  99033. }
  99034. }
  99035. declare module BABYLON {
  99036. /**
  99037. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99038. */
  99039. export class PerformanceMonitor {
  99040. private _enabled;
  99041. private _rollingFrameTime;
  99042. private _lastFrameTimeMs;
  99043. /**
  99044. * constructor
  99045. * @param frameSampleSize The number of samples required to saturate the sliding window
  99046. */
  99047. constructor(frameSampleSize?: number);
  99048. /**
  99049. * Samples current frame
  99050. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99051. */
  99052. sampleFrame(timeMs?: number): void;
  99053. /**
  99054. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99055. */
  99056. readonly averageFrameTime: number;
  99057. /**
  99058. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99059. */
  99060. readonly averageFrameTimeVariance: number;
  99061. /**
  99062. * Returns the frame time of the most recent frame
  99063. */
  99064. readonly instantaneousFrameTime: number;
  99065. /**
  99066. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99067. */
  99068. readonly averageFPS: number;
  99069. /**
  99070. * Returns the average framerate in frames per second using the most recent frame time
  99071. */
  99072. readonly instantaneousFPS: number;
  99073. /**
  99074. * Returns true if enough samples have been taken to completely fill the sliding window
  99075. */
  99076. readonly isSaturated: boolean;
  99077. /**
  99078. * Enables contributions to the sliding window sample set
  99079. */
  99080. enable(): void;
  99081. /**
  99082. * Disables contributions to the sliding window sample set
  99083. * Samples will not be interpolated over the disabled period
  99084. */
  99085. disable(): void;
  99086. /**
  99087. * Returns true if sampling is enabled
  99088. */
  99089. readonly isEnabled: boolean;
  99090. /**
  99091. * Resets performance monitor
  99092. */
  99093. reset(): void;
  99094. }
  99095. /**
  99096. * RollingAverage
  99097. *
  99098. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99099. */
  99100. export class RollingAverage {
  99101. /**
  99102. * Current average
  99103. */
  99104. average: number;
  99105. /**
  99106. * Current variance
  99107. */
  99108. variance: number;
  99109. protected _samples: Array<number>;
  99110. protected _sampleCount: number;
  99111. protected _pos: number;
  99112. protected _m2: number;
  99113. /**
  99114. * constructor
  99115. * @param length The number of samples required to saturate the sliding window
  99116. */
  99117. constructor(length: number);
  99118. /**
  99119. * Adds a sample to the sample set
  99120. * @param v The sample value
  99121. */
  99122. add(v: number): void;
  99123. /**
  99124. * Returns previously added values or null if outside of history or outside the sliding window domain
  99125. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99126. * @return Value previously recorded with add() or null if outside of range
  99127. */
  99128. history(i: number): number;
  99129. /**
  99130. * Returns true if enough samples have been taken to completely fill the sliding window
  99131. * @return true if sample-set saturated
  99132. */
  99133. isSaturated(): boolean;
  99134. /**
  99135. * Resets the rolling average (equivalent to 0 samples taken so far)
  99136. */
  99137. reset(): void;
  99138. /**
  99139. * Wraps a value around the sample range boundaries
  99140. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99141. * @return Wrapped position in sample range
  99142. */
  99143. protected _wrapPosition(i: number): number;
  99144. }
  99145. }
  99146. declare module BABYLON {
  99147. /**
  99148. * This class is used to track a performance counter which is number based.
  99149. * The user has access to many properties which give statistics of different nature.
  99150. *
  99151. * The implementer can track two kinds of Performance Counter: time and count.
  99152. * 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.
  99153. * 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.
  99154. */
  99155. export class PerfCounter {
  99156. /**
  99157. * Gets or sets a global boolean to turn on and off all the counters
  99158. */
  99159. static Enabled: boolean;
  99160. /**
  99161. * Returns the smallest value ever
  99162. */
  99163. readonly min: number;
  99164. /**
  99165. * Returns the biggest value ever
  99166. */
  99167. readonly max: number;
  99168. /**
  99169. * Returns the average value since the performance counter is running
  99170. */
  99171. readonly average: number;
  99172. /**
  99173. * Returns the average value of the last second the counter was monitored
  99174. */
  99175. readonly lastSecAverage: number;
  99176. /**
  99177. * Returns the current value
  99178. */
  99179. readonly current: number;
  99180. /**
  99181. * Gets the accumulated total
  99182. */
  99183. readonly total: number;
  99184. /**
  99185. * Gets the total value count
  99186. */
  99187. readonly count: number;
  99188. /**
  99189. * Creates a new counter
  99190. */
  99191. constructor();
  99192. /**
  99193. * Call this method to start monitoring a new frame.
  99194. * 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.
  99195. */
  99196. fetchNewFrame(): void;
  99197. /**
  99198. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99199. * @param newCount the count value to add to the monitored count
  99200. * @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.
  99201. */
  99202. addCount(newCount: number, fetchResult: boolean): void;
  99203. /**
  99204. * Start monitoring this performance counter
  99205. */
  99206. beginMonitoring(): void;
  99207. /**
  99208. * Compute the time lapsed since the previous beginMonitoring() call.
  99209. * @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
  99210. */
  99211. endMonitoring(newFrame?: boolean): void;
  99212. private _fetchResult;
  99213. private _startMonitoringTime;
  99214. private _min;
  99215. private _max;
  99216. private _average;
  99217. private _current;
  99218. private _totalValueCount;
  99219. private _totalAccumulated;
  99220. private _lastSecAverage;
  99221. private _lastSecAccumulated;
  99222. private _lastSecTime;
  99223. private _lastSecValueCount;
  99224. }
  99225. }
  99226. declare module BABYLON {
  99227. /**
  99228. * Defines the interface used by display changed events
  99229. */
  99230. export interface IDisplayChangedEventArgs {
  99231. /** Gets the vrDisplay object (if any) */
  99232. vrDisplay: Nullable<any>;
  99233. /** Gets a boolean indicating if webVR is supported */
  99234. vrSupported: boolean;
  99235. }
  99236. /**
  99237. * Defines the interface used by objects containing a viewport (like a camera)
  99238. */
  99239. interface IViewportOwnerLike {
  99240. /**
  99241. * Gets or sets the viewport
  99242. */
  99243. viewport: IViewportLike;
  99244. }
  99245. /**
  99246. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99247. */
  99248. export class Engine extends ThinEngine {
  99249. /** Defines that alpha blending is disabled */
  99250. static readonly ALPHA_DISABLE: number;
  99251. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99252. static readonly ALPHA_ADD: number;
  99253. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99254. static readonly ALPHA_COMBINE: number;
  99255. /** Defines that alpha blending to DEST - SRC * DEST */
  99256. static readonly ALPHA_SUBTRACT: number;
  99257. /** Defines that alpha blending to SRC * DEST */
  99258. static readonly ALPHA_MULTIPLY: number;
  99259. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99260. static readonly ALPHA_MAXIMIZED: number;
  99261. /** Defines that alpha blending to SRC + DEST */
  99262. static readonly ALPHA_ONEONE: number;
  99263. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99264. static readonly ALPHA_PREMULTIPLIED: number;
  99265. /**
  99266. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99267. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99268. */
  99269. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99270. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99271. static readonly ALPHA_INTERPOLATE: number;
  99272. /**
  99273. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99274. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99275. */
  99276. static readonly ALPHA_SCREENMODE: number;
  99277. /** Defines that the ressource is not delayed*/
  99278. static readonly DELAYLOADSTATE_NONE: number;
  99279. /** Defines that the ressource was successfully delay loaded */
  99280. static readonly DELAYLOADSTATE_LOADED: number;
  99281. /** Defines that the ressource is currently delay loading */
  99282. static readonly DELAYLOADSTATE_LOADING: number;
  99283. /** Defines that the ressource is delayed and has not started loading */
  99284. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99286. static readonly NEVER: number;
  99287. /** 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 */
  99288. static readonly ALWAYS: number;
  99289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99290. static readonly LESS: number;
  99291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99292. static readonly EQUAL: number;
  99293. /** 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 */
  99294. static readonly LEQUAL: number;
  99295. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99296. static readonly GREATER: number;
  99297. /** 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 */
  99298. static readonly GEQUAL: number;
  99299. /** 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 */
  99300. static readonly NOTEQUAL: number;
  99301. /** Passed to stencilOperation to specify that stencil value must be kept */
  99302. static readonly KEEP: number;
  99303. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99304. static readonly REPLACE: number;
  99305. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99306. static readonly INCR: number;
  99307. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99308. static readonly DECR: number;
  99309. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99310. static readonly INVERT: number;
  99311. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99312. static readonly INCR_WRAP: number;
  99313. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99314. static readonly DECR_WRAP: number;
  99315. /** Texture is not repeating outside of 0..1 UVs */
  99316. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99317. /** Texture is repeating outside of 0..1 UVs */
  99318. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99319. /** Texture is repeating and mirrored */
  99320. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99321. /** ALPHA */
  99322. static readonly TEXTUREFORMAT_ALPHA: number;
  99323. /** LUMINANCE */
  99324. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99325. /** LUMINANCE_ALPHA */
  99326. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99327. /** RGB */
  99328. static readonly TEXTUREFORMAT_RGB: number;
  99329. /** RGBA */
  99330. static readonly TEXTUREFORMAT_RGBA: number;
  99331. /** RED */
  99332. static readonly TEXTUREFORMAT_RED: number;
  99333. /** RED (2nd reference) */
  99334. static readonly TEXTUREFORMAT_R: number;
  99335. /** RG */
  99336. static readonly TEXTUREFORMAT_RG: number;
  99337. /** RED_INTEGER */
  99338. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99339. /** RED_INTEGER (2nd reference) */
  99340. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99341. /** RG_INTEGER */
  99342. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99343. /** RGB_INTEGER */
  99344. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99345. /** RGBA_INTEGER */
  99346. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99347. /** UNSIGNED_BYTE */
  99348. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99349. /** UNSIGNED_BYTE (2nd reference) */
  99350. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99351. /** FLOAT */
  99352. static readonly TEXTURETYPE_FLOAT: number;
  99353. /** HALF_FLOAT */
  99354. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99355. /** BYTE */
  99356. static readonly TEXTURETYPE_BYTE: number;
  99357. /** SHORT */
  99358. static readonly TEXTURETYPE_SHORT: number;
  99359. /** UNSIGNED_SHORT */
  99360. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99361. /** INT */
  99362. static readonly TEXTURETYPE_INT: number;
  99363. /** UNSIGNED_INT */
  99364. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99365. /** UNSIGNED_SHORT_4_4_4_4 */
  99366. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99367. /** UNSIGNED_SHORT_5_5_5_1 */
  99368. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99369. /** UNSIGNED_SHORT_5_6_5 */
  99370. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99371. /** UNSIGNED_INT_2_10_10_10_REV */
  99372. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99373. /** UNSIGNED_INT_24_8 */
  99374. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99375. /** UNSIGNED_INT_10F_11F_11F_REV */
  99376. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99377. /** UNSIGNED_INT_5_9_9_9_REV */
  99378. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99379. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99380. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99381. /** nearest is mag = nearest and min = nearest and mip = linear */
  99382. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99384. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99385. /** Trilinear is mag = linear and min = linear and mip = linear */
  99386. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99387. /** nearest is mag = nearest and min = nearest and mip = linear */
  99388. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99390. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99391. /** Trilinear is mag = linear and min = linear and mip = linear */
  99392. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99393. /** mag = nearest and min = nearest and mip = nearest */
  99394. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99395. /** mag = nearest and min = linear and mip = nearest */
  99396. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99397. /** mag = nearest and min = linear and mip = linear */
  99398. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99399. /** mag = nearest and min = linear and mip = none */
  99400. static readonly TEXTURE_NEAREST_LINEAR: number;
  99401. /** mag = nearest and min = nearest and mip = none */
  99402. static readonly TEXTURE_NEAREST_NEAREST: number;
  99403. /** mag = linear and min = nearest and mip = nearest */
  99404. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99405. /** mag = linear and min = nearest and mip = linear */
  99406. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99407. /** mag = linear and min = linear and mip = none */
  99408. static readonly TEXTURE_LINEAR_LINEAR: number;
  99409. /** mag = linear and min = nearest and mip = none */
  99410. static readonly TEXTURE_LINEAR_NEAREST: number;
  99411. /** Explicit coordinates mode */
  99412. static readonly TEXTURE_EXPLICIT_MODE: number;
  99413. /** Spherical coordinates mode */
  99414. static readonly TEXTURE_SPHERICAL_MODE: number;
  99415. /** Planar coordinates mode */
  99416. static readonly TEXTURE_PLANAR_MODE: number;
  99417. /** Cubic coordinates mode */
  99418. static readonly TEXTURE_CUBIC_MODE: number;
  99419. /** Projection coordinates mode */
  99420. static readonly TEXTURE_PROJECTION_MODE: number;
  99421. /** Skybox coordinates mode */
  99422. static readonly TEXTURE_SKYBOX_MODE: number;
  99423. /** Inverse Cubic coordinates mode */
  99424. static readonly TEXTURE_INVCUBIC_MODE: number;
  99425. /** Equirectangular coordinates mode */
  99426. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99427. /** Equirectangular Fixed coordinates mode */
  99428. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99429. /** Equirectangular Fixed Mirrored coordinates mode */
  99430. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99431. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99432. static readonly SCALEMODE_FLOOR: number;
  99433. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99434. static readonly SCALEMODE_NEAREST: number;
  99435. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99436. static readonly SCALEMODE_CEILING: number;
  99437. /**
  99438. * Returns the current npm package of the sdk
  99439. */
  99440. static readonly NpmPackage: string;
  99441. /**
  99442. * Returns the current version of the framework
  99443. */
  99444. static readonly Version: string;
  99445. /** Gets the list of created engines */
  99446. static readonly Instances: Engine[];
  99447. /**
  99448. * Gets the latest created engine
  99449. */
  99450. static readonly LastCreatedEngine: Nullable<Engine>;
  99451. /**
  99452. * Gets the latest created scene
  99453. */
  99454. static readonly LastCreatedScene: Nullable<Scene>;
  99455. /**
  99456. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99457. * @param flag defines which part of the materials must be marked as dirty
  99458. * @param predicate defines a predicate used to filter which materials should be affected
  99459. */
  99460. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99461. /**
  99462. * Method called to create the default loading screen.
  99463. * This can be overriden in your own app.
  99464. * @param canvas The rendering canvas element
  99465. * @returns The loading screen
  99466. */
  99467. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99468. /**
  99469. * Method called to create the default rescale post process on each engine.
  99470. */
  99471. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99472. /**
  99473. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99474. **/
  99475. enableOfflineSupport: boolean;
  99476. /**
  99477. * 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)
  99478. **/
  99479. disableManifestCheck: boolean;
  99480. /**
  99481. * Gets the list of created scenes
  99482. */
  99483. scenes: Scene[];
  99484. /**
  99485. * Event raised when a new scene is created
  99486. */
  99487. onNewSceneAddedObservable: Observable<Scene>;
  99488. /**
  99489. * Gets the list of created postprocesses
  99490. */
  99491. postProcesses: PostProcess[];
  99492. /**
  99493. * Gets a boolean indicating if the pointer is currently locked
  99494. */
  99495. isPointerLock: boolean;
  99496. /**
  99497. * Observable event triggered each time the rendering canvas is resized
  99498. */
  99499. onResizeObservable: Observable<Engine>;
  99500. /**
  99501. * Observable event triggered each time the canvas loses focus
  99502. */
  99503. onCanvasBlurObservable: Observable<Engine>;
  99504. /**
  99505. * Observable event triggered each time the canvas gains focus
  99506. */
  99507. onCanvasFocusObservable: Observable<Engine>;
  99508. /**
  99509. * Observable event triggered each time the canvas receives pointerout event
  99510. */
  99511. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99512. /**
  99513. * Observable raised when the engine begins a new frame
  99514. */
  99515. onBeginFrameObservable: Observable<Engine>;
  99516. /**
  99517. * If set, will be used to request the next animation frame for the render loop
  99518. */
  99519. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99520. /**
  99521. * Observable raised when the engine ends the current frame
  99522. */
  99523. onEndFrameObservable: Observable<Engine>;
  99524. /**
  99525. * Observable raised when the engine is about to compile a shader
  99526. */
  99527. onBeforeShaderCompilationObservable: Observable<Engine>;
  99528. /**
  99529. * Observable raised when the engine has jsut compiled a shader
  99530. */
  99531. onAfterShaderCompilationObservable: Observable<Engine>;
  99532. /**
  99533. * Gets the audio engine
  99534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99535. * @ignorenaming
  99536. */
  99537. static audioEngine: IAudioEngine;
  99538. /**
  99539. * Default AudioEngine factory responsible of creating the Audio Engine.
  99540. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99541. */
  99542. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99543. /**
  99544. * Default offline support factory responsible of creating a tool used to store data locally.
  99545. * By default, this will create a Database object if the workload has been embedded.
  99546. */
  99547. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99548. private _loadingScreen;
  99549. private _pointerLockRequested;
  99550. private _dummyFramebuffer;
  99551. private _rescalePostProcess;
  99552. /** @hidden */
  99553. protected _alphaMode: number;
  99554. /** @hidden */
  99555. protected _alphaEquation: number;
  99556. private _deterministicLockstep;
  99557. private _lockstepMaxSteps;
  99558. protected readonly _supportsHardwareTextureRescaling: boolean;
  99559. private _fps;
  99560. private _deltaTime;
  99561. /** @hidden */
  99562. _drawCalls: PerfCounter;
  99563. /**
  99564. * Turn this value on if you want to pause FPS computation when in background
  99565. */
  99566. disablePerformanceMonitorInBackground: boolean;
  99567. private _performanceMonitor;
  99568. /**
  99569. * Gets the performance monitor attached to this engine
  99570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99571. */
  99572. readonly performanceMonitor: PerformanceMonitor;
  99573. private _onFocus;
  99574. private _onBlur;
  99575. private _onCanvasPointerOut;
  99576. private _onCanvasBlur;
  99577. private _onCanvasFocus;
  99578. private _onFullscreenChange;
  99579. private _onPointerLockChange;
  99580. /**
  99581. * Gets the HTML element used to attach event listeners
  99582. * @returns a HTML element
  99583. */
  99584. getInputElement(): Nullable<HTMLElement>;
  99585. /**
  99586. * Creates a new engine
  99587. * @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
  99588. * @param antialias defines enable antialiasing (default: false)
  99589. * @param options defines further options to be sent to the getContext() function
  99590. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99591. */
  99592. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99593. /**
  99594. * Gets current aspect ratio
  99595. * @param viewportOwner defines the camera to use to get the aspect ratio
  99596. * @param useScreen defines if screen size must be used (or the current render target if any)
  99597. * @returns a number defining the aspect ratio
  99598. */
  99599. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99600. /**
  99601. * Gets current screen aspect ratio
  99602. * @returns a number defining the aspect ratio
  99603. */
  99604. getScreenAspectRatio(): number;
  99605. /**
  99606. * Gets host document
  99607. * @returns the host document object
  99608. */
  99609. getHostDocument(): Document;
  99610. /**
  99611. * Gets the client rect of the HTML canvas attached with the current webGL context
  99612. * @returns a client rectanglee
  99613. */
  99614. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99615. /**
  99616. * Gets the client rect of the HTML element used for events
  99617. * @returns a client rectanglee
  99618. */
  99619. getInputElementClientRect(): Nullable<ClientRect>;
  99620. /**
  99621. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99623. * @returns true if engine is in deterministic lock step mode
  99624. */
  99625. isDeterministicLockStep(): boolean;
  99626. /**
  99627. * Gets the max steps when engine is running in deterministic lock step
  99628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99629. * @returns the max steps
  99630. */
  99631. getLockstepMaxSteps(): number;
  99632. /**
  99633. * Force the mipmap generation for the given render target texture
  99634. * @param texture defines the render target texture to use
  99635. */
  99636. generateMipMapsForCubemap(texture: InternalTexture): void;
  99637. /** States */
  99638. /**
  99639. * Set various states to the webGL context
  99640. * @param culling defines backface culling state
  99641. * @param zOffset defines the value to apply to zOffset (0 by default)
  99642. * @param force defines if states must be applied even if cache is up to date
  99643. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99644. */
  99645. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99646. /**
  99647. * Set the z offset to apply to current rendering
  99648. * @param value defines the offset to apply
  99649. */
  99650. setZOffset(value: number): void;
  99651. /**
  99652. * Gets the current value of the zOffset
  99653. * @returns the current zOffset state
  99654. */
  99655. getZOffset(): number;
  99656. /**
  99657. * Enable or disable depth buffering
  99658. * @param enable defines the state to set
  99659. */
  99660. setDepthBuffer(enable: boolean): void;
  99661. /**
  99662. * Gets a boolean indicating if depth writing is enabled
  99663. * @returns the current depth writing state
  99664. */
  99665. getDepthWrite(): boolean;
  99666. /**
  99667. * Enable or disable depth writing
  99668. * @param enable defines the state to set
  99669. */
  99670. setDepthWrite(enable: boolean): void;
  99671. /**
  99672. * Enable or disable color writing
  99673. * @param enable defines the state to set
  99674. */
  99675. setColorWrite(enable: boolean): void;
  99676. /**
  99677. * Gets a boolean indicating if color writing is enabled
  99678. * @returns the current color writing state
  99679. */
  99680. getColorWrite(): boolean;
  99681. /**
  99682. * Sets alpha constants used by some alpha blending modes
  99683. * @param r defines the red component
  99684. * @param g defines the green component
  99685. * @param b defines the blue component
  99686. * @param a defines the alpha component
  99687. */
  99688. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99689. /**
  99690. * Sets the current alpha mode
  99691. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99692. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99694. */
  99695. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99696. /**
  99697. * Gets the current alpha mode
  99698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99699. * @returns the current alpha mode
  99700. */
  99701. getAlphaMode(): number;
  99702. /**
  99703. * Sets the current alpha equation
  99704. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99705. */
  99706. setAlphaEquation(equation: number): void;
  99707. /**
  99708. * Gets the current alpha equation.
  99709. * @returns the current alpha equation
  99710. */
  99711. getAlphaEquation(): number;
  99712. /**
  99713. * Gets a boolean indicating if stencil buffer is enabled
  99714. * @returns the current stencil buffer state
  99715. */
  99716. getStencilBuffer(): boolean;
  99717. /**
  99718. * Enable or disable the stencil buffer
  99719. * @param enable defines if the stencil buffer must be enabled or disabled
  99720. */
  99721. setStencilBuffer(enable: boolean): void;
  99722. /**
  99723. * Gets the current stencil mask
  99724. * @returns a number defining the new stencil mask to use
  99725. */
  99726. getStencilMask(): number;
  99727. /**
  99728. * Sets the current stencil mask
  99729. * @param mask defines the new stencil mask to use
  99730. */
  99731. setStencilMask(mask: number): void;
  99732. /**
  99733. * Gets the current stencil function
  99734. * @returns a number defining the stencil function to use
  99735. */
  99736. getStencilFunction(): number;
  99737. /**
  99738. * Gets the current stencil reference value
  99739. * @returns a number defining the stencil reference value to use
  99740. */
  99741. getStencilFunctionReference(): number;
  99742. /**
  99743. * Gets the current stencil mask
  99744. * @returns a number defining the stencil mask to use
  99745. */
  99746. getStencilFunctionMask(): number;
  99747. /**
  99748. * Sets the current stencil function
  99749. * @param stencilFunc defines the new stencil function to use
  99750. */
  99751. setStencilFunction(stencilFunc: number): void;
  99752. /**
  99753. * Sets the current stencil reference
  99754. * @param reference defines the new stencil reference to use
  99755. */
  99756. setStencilFunctionReference(reference: number): void;
  99757. /**
  99758. * Sets the current stencil mask
  99759. * @param mask defines the new stencil mask to use
  99760. */
  99761. setStencilFunctionMask(mask: number): void;
  99762. /**
  99763. * Gets the current stencil operation when stencil fails
  99764. * @returns a number defining stencil operation to use when stencil fails
  99765. */
  99766. getStencilOperationFail(): number;
  99767. /**
  99768. * Gets the current stencil operation when depth fails
  99769. * @returns a number defining stencil operation to use when depth fails
  99770. */
  99771. getStencilOperationDepthFail(): number;
  99772. /**
  99773. * Gets the current stencil operation when stencil passes
  99774. * @returns a number defining stencil operation to use when stencil passes
  99775. */
  99776. getStencilOperationPass(): number;
  99777. /**
  99778. * Sets the stencil operation to use when stencil fails
  99779. * @param operation defines the stencil operation to use when stencil fails
  99780. */
  99781. setStencilOperationFail(operation: number): void;
  99782. /**
  99783. * Sets the stencil operation to use when depth fails
  99784. * @param operation defines the stencil operation to use when depth fails
  99785. */
  99786. setStencilOperationDepthFail(operation: number): void;
  99787. /**
  99788. * Sets the stencil operation to use when stencil passes
  99789. * @param operation defines the stencil operation to use when stencil passes
  99790. */
  99791. setStencilOperationPass(operation: number): void;
  99792. /**
  99793. * Sets a boolean indicating if the dithering state is enabled or disabled
  99794. * @param value defines the dithering state
  99795. */
  99796. setDitheringState(value: boolean): void;
  99797. /**
  99798. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99799. * @param value defines the rasterizer state
  99800. */
  99801. setRasterizerState(value: boolean): void;
  99802. /**
  99803. * Gets the current depth function
  99804. * @returns a number defining the depth function
  99805. */
  99806. getDepthFunction(): Nullable<number>;
  99807. /**
  99808. * Sets the current depth function
  99809. * @param depthFunc defines the function to use
  99810. */
  99811. setDepthFunction(depthFunc: number): void;
  99812. /**
  99813. * Sets the current depth function to GREATER
  99814. */
  99815. setDepthFunctionToGreater(): void;
  99816. /**
  99817. * Sets the current depth function to GEQUAL
  99818. */
  99819. setDepthFunctionToGreaterOrEqual(): void;
  99820. /**
  99821. * Sets the current depth function to LESS
  99822. */
  99823. setDepthFunctionToLess(): void;
  99824. /**
  99825. * Sets the current depth function to LEQUAL
  99826. */
  99827. setDepthFunctionToLessOrEqual(): void;
  99828. private _cachedStencilBuffer;
  99829. private _cachedStencilFunction;
  99830. private _cachedStencilMask;
  99831. private _cachedStencilOperationPass;
  99832. private _cachedStencilOperationFail;
  99833. private _cachedStencilOperationDepthFail;
  99834. private _cachedStencilReference;
  99835. /**
  99836. * Caches the the state of the stencil buffer
  99837. */
  99838. cacheStencilState(): void;
  99839. /**
  99840. * Restores the state of the stencil buffer
  99841. */
  99842. restoreStencilState(): void;
  99843. /**
  99844. * Directly set the WebGL Viewport
  99845. * @param x defines the x coordinate of the viewport (in screen space)
  99846. * @param y defines the y coordinate of the viewport (in screen space)
  99847. * @param width defines the width of the viewport (in screen space)
  99848. * @param height defines the height of the viewport (in screen space)
  99849. * @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
  99850. */
  99851. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99852. /**
  99853. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99854. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99855. * @param y defines the y-coordinate of the corner of the clear rectangle
  99856. * @param width defines the width of the clear rectangle
  99857. * @param height defines the height of the clear rectangle
  99858. * @param clearColor defines the clear color
  99859. */
  99860. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99861. /**
  99862. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99863. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99864. * @param y defines the y-coordinate of the corner of the clear rectangle
  99865. * @param width defines the width of the clear rectangle
  99866. * @param height defines the height of the clear rectangle
  99867. */
  99868. enableScissor(x: number, y: number, width: number, height: number): void;
  99869. /**
  99870. * Disable previously set scissor test rectangle
  99871. */
  99872. disableScissor(): void;
  99873. protected _reportDrawCall(): void;
  99874. /**
  99875. * Initializes a webVR display and starts listening to display change events
  99876. * The onVRDisplayChangedObservable will be notified upon these changes
  99877. * @returns The onVRDisplayChangedObservable
  99878. */
  99879. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99880. /** @hidden */
  99881. _prepareVRComponent(): void;
  99882. /** @hidden */
  99883. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99884. /** @hidden */
  99885. _submitVRFrame(): void;
  99886. /**
  99887. * Call this function to leave webVR mode
  99888. * Will do nothing if webVR is not supported or if there is no webVR device
  99889. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99890. */
  99891. disableVR(): void;
  99892. /**
  99893. * Gets a boolean indicating that the system is in VR mode and is presenting
  99894. * @returns true if VR mode is engaged
  99895. */
  99896. isVRPresenting(): boolean;
  99897. /** @hidden */
  99898. _requestVRFrame(): void;
  99899. /** @hidden */
  99900. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99901. /**
  99902. * Gets the source code of the vertex shader associated with a specific webGL program
  99903. * @param program defines the program to use
  99904. * @returns a string containing the source code of the vertex shader associated with the program
  99905. */
  99906. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99907. /**
  99908. * Gets the source code of the fragment shader associated with a specific webGL program
  99909. * @param program defines the program to use
  99910. * @returns a string containing the source code of the fragment shader associated with the program
  99911. */
  99912. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99913. /**
  99914. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99915. * @param x defines the x coordinate of the rectangle where pixels must be read
  99916. * @param y defines the y coordinate of the rectangle where pixels must be read
  99917. * @param width defines the width of the rectangle where pixels must be read
  99918. * @param height defines the height of the rectangle where pixels must be read
  99919. * @returns a Uint8Array containing RGBA colors
  99920. */
  99921. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99922. /**
  99923. * Sets a depth stencil texture from a render target to the according uniform.
  99924. * @param channel The texture channel
  99925. * @param uniform The uniform to set
  99926. * @param texture The render target texture containing the depth stencil texture to apply
  99927. */
  99928. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99929. /**
  99930. * Sets a texture to the webGL context from a postprocess
  99931. * @param channel defines the channel to use
  99932. * @param postProcess defines the source postprocess
  99933. */
  99934. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99935. /**
  99936. * Binds the output of the passed in post process to the texture channel specified
  99937. * @param channel The channel the texture should be bound to
  99938. * @param postProcess The post process which's output should be bound
  99939. */
  99940. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99941. /** @hidden */
  99942. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99943. protected _rebuildBuffers(): void;
  99944. /** @hidden */
  99945. _renderFrame(): void;
  99946. _renderLoop(): void;
  99947. /** @hidden */
  99948. _renderViews(): boolean;
  99949. /**
  99950. * Toggle full screen mode
  99951. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99952. */
  99953. switchFullscreen(requestPointerLock: boolean): void;
  99954. /**
  99955. * Enters full screen mode
  99956. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99957. */
  99958. enterFullscreen(requestPointerLock: boolean): void;
  99959. /**
  99960. * Exits full screen mode
  99961. */
  99962. exitFullscreen(): void;
  99963. /**
  99964. * Enters Pointerlock mode
  99965. */
  99966. enterPointerlock(): void;
  99967. /**
  99968. * Exits Pointerlock mode
  99969. */
  99970. exitPointerlock(): void;
  99971. /**
  99972. * Begin a new frame
  99973. */
  99974. beginFrame(): void;
  99975. /**
  99976. * Enf the current frame
  99977. */
  99978. endFrame(): void;
  99979. resize(): void;
  99980. /**
  99981. * Set the compressed texture format to use, based on the formats you have, and the formats
  99982. * supported by the hardware / browser.
  99983. *
  99984. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99985. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99986. * to API arguments needed to compressed textures. This puts the burden on the container
  99987. * generator to house the arcane code for determining these for current & future formats.
  99988. *
  99989. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99990. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99991. *
  99992. * Note: The result of this call is not taken into account when a texture is base64.
  99993. *
  99994. * @param formatsAvailable defines the list of those format families you have created
  99995. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99996. *
  99997. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99998. * @returns The extension selected.
  99999. */
  100000. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100001. /**
  100002. * Force a specific size of the canvas
  100003. * @param width defines the new canvas' width
  100004. * @param height defines the new canvas' height
  100005. */
  100006. setSize(width: number, height: number): void;
  100007. /**
  100008. * Updates a dynamic vertex buffer.
  100009. * @param vertexBuffer the vertex buffer to update
  100010. * @param data the data used to update the vertex buffer
  100011. * @param byteOffset the byte offset of the data
  100012. * @param byteLength the byte length of the data
  100013. */
  100014. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100015. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100016. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100017. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100018. _releaseTexture(texture: InternalTexture): void;
  100019. /**
  100020. * @hidden
  100021. * Rescales a texture
  100022. * @param source input texutre
  100023. * @param destination destination texture
  100024. * @param scene scene to use to render the resize
  100025. * @param internalFormat format to use when resizing
  100026. * @param onComplete callback to be called when resize has completed
  100027. */
  100028. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100029. /**
  100030. * Gets the current framerate
  100031. * @returns a number representing the framerate
  100032. */
  100033. getFps(): number;
  100034. /**
  100035. * Gets the time spent between current and previous frame
  100036. * @returns a number representing the delta time in ms
  100037. */
  100038. getDeltaTime(): number;
  100039. private _measureFps;
  100040. /** @hidden */
  100041. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100042. /**
  100043. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100044. * @param renderTarget The render target to set the frame buffer for
  100045. */
  100046. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100047. /**
  100048. * Update a dynamic index buffer
  100049. * @param indexBuffer defines the target index buffer
  100050. * @param indices defines the data to update
  100051. * @param offset defines the offset in the target index buffer where update should start
  100052. */
  100053. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100054. /**
  100055. * Updates the sample count of a render target texture
  100056. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100057. * @param texture defines the texture to update
  100058. * @param samples defines the sample count to set
  100059. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100060. */
  100061. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100062. /**
  100063. * Updates a depth texture Comparison Mode and Function.
  100064. * If the comparison Function is equal to 0, the mode will be set to none.
  100065. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100066. * @param texture The texture to set the comparison function for
  100067. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100068. */
  100069. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100070. /**
  100071. * Creates a webGL buffer to use with instanciation
  100072. * @param capacity defines the size of the buffer
  100073. * @returns the webGL buffer
  100074. */
  100075. createInstancesBuffer(capacity: number): DataBuffer;
  100076. /**
  100077. * Delete a webGL buffer used with instanciation
  100078. * @param buffer defines the webGL buffer to delete
  100079. */
  100080. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100081. /** @hidden */
  100082. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100083. dispose(): void;
  100084. private _disableTouchAction;
  100085. /**
  100086. * Display the loading screen
  100087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100088. */
  100089. displayLoadingUI(): void;
  100090. /**
  100091. * Hide the loading screen
  100092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100093. */
  100094. hideLoadingUI(): void;
  100095. /**
  100096. * Gets the current loading screen object
  100097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100098. */
  100099. /**
  100100. * Sets the current loading screen object
  100101. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100102. */
  100103. loadingScreen: ILoadingScreen;
  100104. /**
  100105. * Sets the current loading screen text
  100106. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100107. */
  100108. loadingUIText: string;
  100109. /**
  100110. * Sets the current loading screen background color
  100111. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100112. */
  100113. loadingUIBackgroundColor: string;
  100114. /** Pointerlock and fullscreen */
  100115. /**
  100116. * Ask the browser to promote the current element to pointerlock mode
  100117. * @param element defines the DOM element to promote
  100118. */
  100119. static _RequestPointerlock(element: HTMLElement): void;
  100120. /**
  100121. * Asks the browser to exit pointerlock mode
  100122. */
  100123. static _ExitPointerlock(): void;
  100124. /**
  100125. * Ask the browser to promote the current element to fullscreen rendering mode
  100126. * @param element defines the DOM element to promote
  100127. */
  100128. static _RequestFullscreen(element: HTMLElement): void;
  100129. /**
  100130. * Asks the browser to exit fullscreen mode
  100131. */
  100132. static _ExitFullscreen(): void;
  100133. }
  100134. }
  100135. declare module BABYLON {
  100136. /**
  100137. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100138. * during the life time of the application.
  100139. */
  100140. export class EngineStore {
  100141. /** Gets the list of created engines */
  100142. static Instances: Engine[];
  100143. /** @hidden */
  100144. static _LastCreatedScene: Nullable<Scene>;
  100145. /**
  100146. * Gets the latest created engine
  100147. */
  100148. static readonly LastCreatedEngine: Nullable<Engine>;
  100149. /**
  100150. * Gets the latest created scene
  100151. */
  100152. static readonly LastCreatedScene: Nullable<Scene>;
  100153. /**
  100154. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100155. * @ignorenaming
  100156. */
  100157. static UseFallbackTexture: boolean;
  100158. /**
  100159. * Texture content used if a texture cannot loaded
  100160. * @ignorenaming
  100161. */
  100162. static FallbackTexture: string;
  100163. }
  100164. }
  100165. declare module BABYLON {
  100166. /**
  100167. * Helper class that provides a small promise polyfill
  100168. */
  100169. export class PromisePolyfill {
  100170. /**
  100171. * Static function used to check if the polyfill is required
  100172. * If this is the case then the function will inject the polyfill to window.Promise
  100173. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100174. */
  100175. static Apply(force?: boolean): void;
  100176. }
  100177. }
  100178. declare module BABYLON {
  100179. /**
  100180. * Interface for screenshot methods with describe argument called `size` as object with options
  100181. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100182. */
  100183. export interface IScreenshotSize {
  100184. /**
  100185. * number in pixels for canvas height
  100186. */
  100187. height?: number;
  100188. /**
  100189. * multiplier allowing render at a higher or lower resolution
  100190. * If value is defined then height and width will be ignored and taken from camera
  100191. */
  100192. precision?: number;
  100193. /**
  100194. * number in pixels for canvas width
  100195. */
  100196. width?: number;
  100197. }
  100198. }
  100199. declare module BABYLON {
  100200. interface IColor4Like {
  100201. r: float;
  100202. g: float;
  100203. b: float;
  100204. a: float;
  100205. }
  100206. /**
  100207. * Class containing a set of static utilities functions
  100208. */
  100209. export class Tools {
  100210. /**
  100211. * Gets or sets the base URL to use to load assets
  100212. */
  100213. static BaseUrl: string;
  100214. /**
  100215. * Enable/Disable Custom HTTP Request Headers globally.
  100216. * default = false
  100217. * @see CustomRequestHeaders
  100218. */
  100219. static UseCustomRequestHeaders: boolean;
  100220. /**
  100221. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100222. * i.e. when loading files, where the server/service expects an Authorization header
  100223. */
  100224. static CustomRequestHeaders: {
  100225. [key: string]: string;
  100226. };
  100227. /**
  100228. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100229. */
  100230. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100231. /**
  100232. * Default behaviour for cors in the application.
  100233. * It can be a string if the expected behavior is identical in the entire app.
  100234. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100235. */
  100236. static CorsBehavior: string | ((url: string | string[]) => string);
  100237. /**
  100238. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100239. * @ignorenaming
  100240. */
  100241. static UseFallbackTexture: boolean;
  100242. /**
  100243. * Use this object to register external classes like custom textures or material
  100244. * to allow the laoders to instantiate them
  100245. */
  100246. static RegisteredExternalClasses: {
  100247. [key: string]: Object;
  100248. };
  100249. /**
  100250. * Texture content used if a texture cannot loaded
  100251. * @ignorenaming
  100252. */
  100253. static fallbackTexture: string;
  100254. /**
  100255. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100256. * @param u defines the coordinate on X axis
  100257. * @param v defines the coordinate on Y axis
  100258. * @param width defines the width of the source data
  100259. * @param height defines the height of the source data
  100260. * @param pixels defines the source byte array
  100261. * @param color defines the output color
  100262. */
  100263. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100264. /**
  100265. * Interpolates between a and b via alpha
  100266. * @param a The lower value (returned when alpha = 0)
  100267. * @param b The upper value (returned when alpha = 1)
  100268. * @param alpha The interpolation-factor
  100269. * @return The mixed value
  100270. */
  100271. static Mix(a: number, b: number, alpha: number): number;
  100272. /**
  100273. * Tries to instantiate a new object from a given class name
  100274. * @param className defines the class name to instantiate
  100275. * @returns the new object or null if the system was not able to do the instantiation
  100276. */
  100277. static Instantiate(className: string): any;
  100278. /**
  100279. * Provides a slice function that will work even on IE
  100280. * @param data defines the array to slice
  100281. * @param start defines the start of the data (optional)
  100282. * @param end defines the end of the data (optional)
  100283. * @returns the new sliced array
  100284. */
  100285. static Slice<T>(data: T, start?: number, end?: number): T;
  100286. /**
  100287. * Polyfill for setImmediate
  100288. * @param action defines the action to execute after the current execution block
  100289. */
  100290. static SetImmediate(action: () => void): void;
  100291. /**
  100292. * Function indicating if a number is an exponent of 2
  100293. * @param value defines the value to test
  100294. * @returns true if the value is an exponent of 2
  100295. */
  100296. static IsExponentOfTwo(value: number): boolean;
  100297. private static _tmpFloatArray;
  100298. /**
  100299. * Returns the nearest 32-bit single precision float representation of a Number
  100300. * @param value A Number. If the parameter is of a different type, it will get converted
  100301. * to a number or to NaN if it cannot be converted
  100302. * @returns number
  100303. */
  100304. static FloatRound(value: number): number;
  100305. /**
  100306. * Extracts the filename from a path
  100307. * @param path defines the path to use
  100308. * @returns the filename
  100309. */
  100310. static GetFilename(path: string): string;
  100311. /**
  100312. * Extracts the "folder" part of a path (everything before the filename).
  100313. * @param uri The URI to extract the info from
  100314. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100315. * @returns The "folder" part of the path
  100316. */
  100317. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100318. /**
  100319. * Extracts text content from a DOM element hierarchy
  100320. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100321. */
  100322. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100323. /**
  100324. * Convert an angle in radians to degrees
  100325. * @param angle defines the angle to convert
  100326. * @returns the angle in degrees
  100327. */
  100328. static ToDegrees(angle: number): number;
  100329. /**
  100330. * Convert an angle in degrees to radians
  100331. * @param angle defines the angle to convert
  100332. * @returns the angle in radians
  100333. */
  100334. static ToRadians(angle: number): number;
  100335. /**
  100336. * Returns an array if obj is not an array
  100337. * @param obj defines the object to evaluate as an array
  100338. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100339. * @returns either obj directly if obj is an array or a new array containing obj
  100340. */
  100341. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100342. /**
  100343. * Gets the pointer prefix to use
  100344. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100345. */
  100346. static GetPointerPrefix(): string;
  100347. /**
  100348. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100349. * @param url define the url we are trying
  100350. * @param element define the dom element where to configure the cors policy
  100351. */
  100352. static SetCorsBehavior(url: string | string[], element: {
  100353. crossOrigin: string | null;
  100354. }): void;
  100355. /**
  100356. * Removes unwanted characters from an url
  100357. * @param url defines the url to clean
  100358. * @returns the cleaned url
  100359. */
  100360. static CleanUrl(url: string): string;
  100361. /**
  100362. * Gets or sets a function used to pre-process url before using them to load assets
  100363. */
  100364. static PreprocessUrl: (url: string) => string;
  100365. /**
  100366. * Loads an image as an HTMLImageElement.
  100367. * @param input url string, ArrayBuffer, or Blob to load
  100368. * @param onLoad callback called when the image successfully loads
  100369. * @param onError callback called when the image fails to load
  100370. * @param offlineProvider offline provider for caching
  100371. * @param mimeType optional mime type
  100372. * @returns the HTMLImageElement of the loaded image
  100373. */
  100374. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100375. /**
  100376. * Loads a file from a url
  100377. * @param url url string, ArrayBuffer, or Blob to load
  100378. * @param onSuccess callback called when the file successfully loads
  100379. * @param onProgress callback called while file is loading (if the server supports this mode)
  100380. * @param offlineProvider defines the offline provider for caching
  100381. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100382. * @param onError callback called when the file fails to load
  100383. * @returns a file request object
  100384. */
  100385. 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;
  100386. /**
  100387. * Loads a file from a url
  100388. * @param url the file url to load
  100389. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100390. */
  100391. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100392. /**
  100393. * Load a script (identified by an url). When the url returns, the
  100394. * content of this file is added into a new script element, attached to the DOM (body element)
  100395. * @param scriptUrl defines the url of the script to laod
  100396. * @param onSuccess defines the callback called when the script is loaded
  100397. * @param onError defines the callback to call if an error occurs
  100398. * @param scriptId defines the id of the script element
  100399. */
  100400. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100401. /**
  100402. * Load an asynchronous script (identified by an url). When the url returns, the
  100403. * content of this file is added into a new script element, attached to the DOM (body element)
  100404. * @param scriptUrl defines the url of the script to laod
  100405. * @param scriptId defines the id of the script element
  100406. * @returns a promise request object
  100407. */
  100408. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100409. /**
  100410. * Loads a file from a blob
  100411. * @param fileToLoad defines the blob to use
  100412. * @param callback defines the callback to call when data is loaded
  100413. * @param progressCallback defines the callback to call during loading process
  100414. * @returns a file request object
  100415. */
  100416. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100417. /**
  100418. * Reads a file from a File object
  100419. * @param file defines the file to load
  100420. * @param onSuccess defines the callback to call when data is loaded
  100421. * @param onProgress defines the callback to call during loading process
  100422. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100423. * @param onError defines the callback to call when an error occurs
  100424. * @returns a file request object
  100425. */
  100426. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100427. /**
  100428. * Creates a data url from a given string content
  100429. * @param content defines the content to convert
  100430. * @returns the new data url link
  100431. */
  100432. static FileAsURL(content: string): string;
  100433. /**
  100434. * Format the given number to a specific decimal format
  100435. * @param value defines the number to format
  100436. * @param decimals defines the number of decimals to use
  100437. * @returns the formatted string
  100438. */
  100439. static Format(value: number, decimals?: number): string;
  100440. /**
  100441. * Tries to copy an object by duplicating every property
  100442. * @param source defines the source object
  100443. * @param destination defines the target object
  100444. * @param doNotCopyList defines a list of properties to avoid
  100445. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100446. */
  100447. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100448. /**
  100449. * Gets a boolean indicating if the given object has no own property
  100450. * @param obj defines the object to test
  100451. * @returns true if object has no own property
  100452. */
  100453. static IsEmpty(obj: any): boolean;
  100454. /**
  100455. * Function used to register events at window level
  100456. * @param windowElement defines the Window object to use
  100457. * @param events defines the events to register
  100458. */
  100459. static RegisterTopRootEvents(windowElement: Window, events: {
  100460. name: string;
  100461. handler: Nullable<(e: FocusEvent) => any>;
  100462. }[]): void;
  100463. /**
  100464. * Function used to unregister events from window level
  100465. * @param windowElement defines the Window object to use
  100466. * @param events defines the events to unregister
  100467. */
  100468. static UnregisterTopRootEvents(windowElement: Window, events: {
  100469. name: string;
  100470. handler: Nullable<(e: FocusEvent) => any>;
  100471. }[]): void;
  100472. /**
  100473. * @ignore
  100474. */
  100475. static _ScreenshotCanvas: HTMLCanvasElement;
  100476. /**
  100477. * Dumps the current bound framebuffer
  100478. * @param width defines the rendering width
  100479. * @param height defines the rendering height
  100480. * @param engine defines the hosting engine
  100481. * @param successCallback defines the callback triggered once the data are available
  100482. * @param mimeType defines the mime type of the result
  100483. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100484. */
  100485. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100486. /**
  100487. * Converts the canvas data to blob.
  100488. * This acts as a polyfill for browsers not supporting the to blob function.
  100489. * @param canvas Defines the canvas to extract the data from
  100490. * @param successCallback Defines the callback triggered once the data are available
  100491. * @param mimeType Defines the mime type of the result
  100492. */
  100493. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100494. /**
  100495. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100496. * @param successCallback defines the callback triggered once the data are available
  100497. * @param mimeType defines the mime type of the result
  100498. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100499. */
  100500. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100501. /**
  100502. * Downloads a blob in the browser
  100503. * @param blob defines the blob to download
  100504. * @param fileName defines the name of the downloaded file
  100505. */
  100506. static Download(blob: Blob, fileName: string): void;
  100507. /**
  100508. * Captures a screenshot of the current rendering
  100509. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100510. * @param engine defines the rendering engine
  100511. * @param camera defines the source camera
  100512. * @param size This parameter can be set to a single number or to an object with the
  100513. * following (optional) properties: precision, width, height. If a single number is passed,
  100514. * it will be used for both width and height. If an object is passed, the screenshot size
  100515. * will be derived from the parameters. The precision property is a multiplier allowing
  100516. * rendering at a higher or lower resolution
  100517. * @param successCallback defines the callback receives a single parameter which contains the
  100518. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100519. * src parameter of an <img> to display it
  100520. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100521. * Check your browser for supported MIME types
  100522. */
  100523. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100524. /**
  100525. * Captures a screenshot of the current rendering
  100526. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100527. * @param engine defines the rendering engine
  100528. * @param camera defines the source camera
  100529. * @param size This parameter can be set to a single number or to an object with the
  100530. * following (optional) properties: precision, width, height. If a single number is passed,
  100531. * it will be used for both width and height. If an object is passed, the screenshot size
  100532. * will be derived from the parameters. The precision property is a multiplier allowing
  100533. * rendering at a higher or lower resolution
  100534. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100535. * Check your browser for supported MIME types
  100536. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100537. * to the src parameter of an <img> to display it
  100538. */
  100539. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100540. /**
  100541. * Generates an image screenshot from the specified camera.
  100542. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100543. * @param engine The engine to use for rendering
  100544. * @param camera The camera to use for rendering
  100545. * @param size This parameter can be set to a single number or to an object with the
  100546. * following (optional) properties: precision, width, height. If a single number is passed,
  100547. * it will be used for both width and height. If an object is passed, the screenshot size
  100548. * will be derived from the parameters. The precision property is a multiplier allowing
  100549. * rendering at a higher or lower resolution
  100550. * @param successCallback The callback receives a single parameter which contains the
  100551. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100552. * src parameter of an <img> to display it
  100553. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100554. * Check your browser for supported MIME types
  100555. * @param samples Texture samples (default: 1)
  100556. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100557. * @param fileName A name for for the downloaded file.
  100558. */
  100559. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100560. /**
  100561. * Generates an image screenshot from the specified camera.
  100562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100563. * @param engine The engine to use for rendering
  100564. * @param camera The camera to use for rendering
  100565. * @param size This parameter can be set to a single number or to an object with the
  100566. * following (optional) properties: precision, width, height. If a single number is passed,
  100567. * it will be used for both width and height. If an object is passed, the screenshot size
  100568. * will be derived from the parameters. The precision property is a multiplier allowing
  100569. * rendering at a higher or lower resolution
  100570. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100571. * Check your browser for supported MIME types
  100572. * @param samples Texture samples (default: 1)
  100573. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100574. * @param fileName A name for for the downloaded file.
  100575. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100576. * to the src parameter of an <img> to display it
  100577. */
  100578. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100579. /**
  100580. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100581. * Be aware Math.random() could cause collisions, but:
  100582. * "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"
  100583. * @returns a pseudo random id
  100584. */
  100585. static RandomId(): string;
  100586. /**
  100587. * Test if the given uri is a base64 string
  100588. * @param uri The uri to test
  100589. * @return True if the uri is a base64 string or false otherwise
  100590. */
  100591. static IsBase64(uri: string): boolean;
  100592. /**
  100593. * Decode the given base64 uri.
  100594. * @param uri The uri to decode
  100595. * @return The decoded base64 data.
  100596. */
  100597. static DecodeBase64(uri: string): ArrayBuffer;
  100598. /**
  100599. * Gets the absolute url.
  100600. * @param url the input url
  100601. * @return the absolute url
  100602. */
  100603. static GetAbsoluteUrl(url: string): string;
  100604. /**
  100605. * No log
  100606. */
  100607. static readonly NoneLogLevel: number;
  100608. /**
  100609. * Only message logs
  100610. */
  100611. static readonly MessageLogLevel: number;
  100612. /**
  100613. * Only warning logs
  100614. */
  100615. static readonly WarningLogLevel: number;
  100616. /**
  100617. * Only error logs
  100618. */
  100619. static readonly ErrorLogLevel: number;
  100620. /**
  100621. * All logs
  100622. */
  100623. static readonly AllLogLevel: number;
  100624. /**
  100625. * Gets a value indicating the number of loading errors
  100626. * @ignorenaming
  100627. */
  100628. static readonly errorsCount: number;
  100629. /**
  100630. * Callback called when a new log is added
  100631. */
  100632. static OnNewCacheEntry: (entry: string) => void;
  100633. /**
  100634. * Log a message to the console
  100635. * @param message defines the message to log
  100636. */
  100637. static Log(message: string): void;
  100638. /**
  100639. * Write a warning message to the console
  100640. * @param message defines the message to log
  100641. */
  100642. static Warn(message: string): void;
  100643. /**
  100644. * Write an error message to the console
  100645. * @param message defines the message to log
  100646. */
  100647. static Error(message: string): void;
  100648. /**
  100649. * Gets current log cache (list of logs)
  100650. */
  100651. static readonly LogCache: string;
  100652. /**
  100653. * Clears the log cache
  100654. */
  100655. static ClearLogCache(): void;
  100656. /**
  100657. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100658. */
  100659. static LogLevels: number;
  100660. /**
  100661. * Checks if the window object exists
  100662. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100663. */
  100664. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100665. /**
  100666. * No performance log
  100667. */
  100668. static readonly PerformanceNoneLogLevel: number;
  100669. /**
  100670. * Use user marks to log performance
  100671. */
  100672. static readonly PerformanceUserMarkLogLevel: number;
  100673. /**
  100674. * Log performance to the console
  100675. */
  100676. static readonly PerformanceConsoleLogLevel: number;
  100677. private static _performance;
  100678. /**
  100679. * Sets the current performance log level
  100680. */
  100681. static PerformanceLogLevel: number;
  100682. private static _StartPerformanceCounterDisabled;
  100683. private static _EndPerformanceCounterDisabled;
  100684. private static _StartUserMark;
  100685. private static _EndUserMark;
  100686. private static _StartPerformanceConsole;
  100687. private static _EndPerformanceConsole;
  100688. /**
  100689. * Starts a performance counter
  100690. */
  100691. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100692. /**
  100693. * Ends a specific performance coutner
  100694. */
  100695. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100696. /**
  100697. * Gets either window.performance.now() if supported or Date.now() else
  100698. */
  100699. static readonly Now: number;
  100700. /**
  100701. * This method will return the name of the class used to create the instance of the given object.
  100702. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100703. * @param object the object to get the class name from
  100704. * @param isType defines if the object is actually a type
  100705. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100706. */
  100707. static GetClassName(object: any, isType?: boolean): string;
  100708. /**
  100709. * Gets the first element of an array satisfying a given predicate
  100710. * @param array defines the array to browse
  100711. * @param predicate defines the predicate to use
  100712. * @returns null if not found or the element
  100713. */
  100714. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100715. /**
  100716. * This method will return the name of the full name of the class, including its owning module (if any).
  100717. * 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).
  100718. * @param object the object to get the class name from
  100719. * @param isType defines if the object is actually a type
  100720. * @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.
  100721. * @ignorenaming
  100722. */
  100723. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100724. /**
  100725. * Returns a promise that resolves after the given amount of time.
  100726. * @param delay Number of milliseconds to delay
  100727. * @returns Promise that resolves after the given amount of time
  100728. */
  100729. static DelayAsync(delay: number): Promise<void>;
  100730. }
  100731. /**
  100732. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100733. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100734. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100735. * @param name The name of the class, case should be preserved
  100736. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100737. */
  100738. export function className(name: string, module?: string): (target: Object) => void;
  100739. /**
  100740. * An implementation of a loop for asynchronous functions.
  100741. */
  100742. export class AsyncLoop {
  100743. /**
  100744. * Defines the number of iterations for the loop
  100745. */
  100746. iterations: number;
  100747. /**
  100748. * Defines the current index of the loop.
  100749. */
  100750. index: number;
  100751. private _done;
  100752. private _fn;
  100753. private _successCallback;
  100754. /**
  100755. * Constructor.
  100756. * @param iterations the number of iterations.
  100757. * @param func the function to run each iteration
  100758. * @param successCallback the callback that will be called upon succesful execution
  100759. * @param offset starting offset.
  100760. */
  100761. constructor(
  100762. /**
  100763. * Defines the number of iterations for the loop
  100764. */
  100765. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100766. /**
  100767. * Execute the next iteration. Must be called after the last iteration was finished.
  100768. */
  100769. executeNext(): void;
  100770. /**
  100771. * Break the loop and run the success callback.
  100772. */
  100773. breakLoop(): void;
  100774. /**
  100775. * Create and run an async loop.
  100776. * @param iterations the number of iterations.
  100777. * @param fn the function to run each iteration
  100778. * @param successCallback the callback that will be called upon succesful execution
  100779. * @param offset starting offset.
  100780. * @returns the created async loop object
  100781. */
  100782. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100783. /**
  100784. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100785. * @param iterations total number of iterations
  100786. * @param syncedIterations number of synchronous iterations in each async iteration.
  100787. * @param fn the function to call each iteration.
  100788. * @param callback a success call back that will be called when iterating stops.
  100789. * @param breakFunction a break condition (optional)
  100790. * @param timeout timeout settings for the setTimeout function. default - 0.
  100791. * @returns the created async loop object
  100792. */
  100793. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100794. }
  100795. }
  100796. declare module BABYLON {
  100797. /**
  100798. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100799. * The underlying implementation relies on an associative array to ensure the best performances.
  100800. * The value can be anything including 'null' but except 'undefined'
  100801. */
  100802. export class StringDictionary<T> {
  100803. /**
  100804. * This will clear this dictionary and copy the content from the 'source' one.
  100805. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100806. * @param source the dictionary to take the content from and copy to this dictionary
  100807. */
  100808. copyFrom(source: StringDictionary<T>): void;
  100809. /**
  100810. * Get a value based from its key
  100811. * @param key the given key to get the matching value from
  100812. * @return the value if found, otherwise undefined is returned
  100813. */
  100814. get(key: string): T | undefined;
  100815. /**
  100816. * Get a value from its key or add it if it doesn't exist.
  100817. * This method will ensure you that a given key/data will be present in the dictionary.
  100818. * @param key the given key to get the matching value from
  100819. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100820. * The factory will only be invoked if there's no data for the given key.
  100821. * @return the value corresponding to the key.
  100822. */
  100823. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100824. /**
  100825. * Get a value from its key if present in the dictionary otherwise add it
  100826. * @param key the key to get the value from
  100827. * @param val if there's no such key/value pair in the dictionary add it with this value
  100828. * @return the value corresponding to the key
  100829. */
  100830. getOrAdd(key: string, val: T): T;
  100831. /**
  100832. * Check if there's a given key in the dictionary
  100833. * @param key the key to check for
  100834. * @return true if the key is present, false otherwise
  100835. */
  100836. contains(key: string): boolean;
  100837. /**
  100838. * Add a new key and its corresponding value
  100839. * @param key the key to add
  100840. * @param value the value corresponding to the key
  100841. * @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
  100842. */
  100843. add(key: string, value: T): boolean;
  100844. /**
  100845. * Update a specific value associated to a key
  100846. * @param key defines the key to use
  100847. * @param value defines the value to store
  100848. * @returns true if the value was updated (or false if the key was not found)
  100849. */
  100850. set(key: string, value: T): boolean;
  100851. /**
  100852. * Get the element of the given key and remove it from the dictionary
  100853. * @param key defines the key to search
  100854. * @returns the value associated with the key or null if not found
  100855. */
  100856. getAndRemove(key: string): Nullable<T>;
  100857. /**
  100858. * Remove a key/value from the dictionary.
  100859. * @param key the key to remove
  100860. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100861. */
  100862. remove(key: string): boolean;
  100863. /**
  100864. * Clear the whole content of the dictionary
  100865. */
  100866. clear(): void;
  100867. /**
  100868. * Gets the current count
  100869. */
  100870. readonly count: number;
  100871. /**
  100872. * Execute a callback on each key/val of the dictionary.
  100873. * Note that you can remove any element in this dictionary in the callback implementation
  100874. * @param callback the callback to execute on a given key/value pair
  100875. */
  100876. forEach(callback: (key: string, val: T) => void): void;
  100877. /**
  100878. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100879. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100880. * Note that you can remove any element in this dictionary in the callback implementation
  100881. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100882. * @returns the first item
  100883. */
  100884. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100885. private _count;
  100886. private _data;
  100887. }
  100888. }
  100889. declare module BABYLON {
  100890. /** @hidden */
  100891. export interface ICollisionCoordinator {
  100892. createCollider(): Collider;
  100893. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100894. init(scene: Scene): void;
  100895. }
  100896. /** @hidden */
  100897. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100898. private _scene;
  100899. private _scaledPosition;
  100900. private _scaledVelocity;
  100901. private _finalPosition;
  100902. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100903. createCollider(): Collider;
  100904. init(scene: Scene): void;
  100905. private _collideWithWorld;
  100906. }
  100907. }
  100908. declare module BABYLON {
  100909. /**
  100910. * Class used to manage all inputs for the scene.
  100911. */
  100912. export class InputManager {
  100913. /** The distance in pixel that you have to move to prevent some events */
  100914. static DragMovementThreshold: number;
  100915. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100916. static LongPressDelay: number;
  100917. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100918. static DoubleClickDelay: number;
  100919. /** If you need to check double click without raising a single click at first click, enable this flag */
  100920. static ExclusiveDoubleClickMode: boolean;
  100921. private _wheelEventName;
  100922. private _onPointerMove;
  100923. private _onPointerDown;
  100924. private _onPointerUp;
  100925. private _initClickEvent;
  100926. private _initActionManager;
  100927. private _delayedSimpleClick;
  100928. private _delayedSimpleClickTimeout;
  100929. private _previousDelayedSimpleClickTimeout;
  100930. private _meshPickProceed;
  100931. private _previousButtonPressed;
  100932. private _currentPickResult;
  100933. private _previousPickResult;
  100934. private _totalPointersPressed;
  100935. private _doubleClickOccured;
  100936. private _pointerOverMesh;
  100937. private _pickedDownMesh;
  100938. private _pickedUpMesh;
  100939. private _pointerX;
  100940. private _pointerY;
  100941. private _unTranslatedPointerX;
  100942. private _unTranslatedPointerY;
  100943. private _startingPointerPosition;
  100944. private _previousStartingPointerPosition;
  100945. private _startingPointerTime;
  100946. private _previousStartingPointerTime;
  100947. private _pointerCaptures;
  100948. private _onKeyDown;
  100949. private _onKeyUp;
  100950. private _onCanvasFocusObserver;
  100951. private _onCanvasBlurObserver;
  100952. private _scene;
  100953. /**
  100954. * Creates a new InputManager
  100955. * @param scene defines the hosting scene
  100956. */
  100957. constructor(scene: Scene);
  100958. /**
  100959. * Gets the mesh that is currently under the pointer
  100960. */
  100961. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100962. /**
  100963. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100964. */
  100965. readonly unTranslatedPointer: Vector2;
  100966. /**
  100967. * Gets or sets the current on-screen X position of the pointer
  100968. */
  100969. pointerX: number;
  100970. /**
  100971. * Gets or sets the current on-screen Y position of the pointer
  100972. */
  100973. pointerY: number;
  100974. private _updatePointerPosition;
  100975. private _processPointerMove;
  100976. private _setRayOnPointerInfo;
  100977. private _checkPrePointerObservable;
  100978. /**
  100979. * Use this method to simulate a pointer move on a mesh
  100980. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100981. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100982. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100983. */
  100984. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100985. /**
  100986. * Use this method to simulate a pointer down on a mesh
  100987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100990. */
  100991. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100992. private _processPointerDown;
  100993. /** @hidden */
  100994. _isPointerSwiping(): boolean;
  100995. /**
  100996. * Use this method to simulate a pointer up on a mesh
  100997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101000. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101001. */
  101002. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101003. private _processPointerUp;
  101004. /**
  101005. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101006. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101007. * @returns true if the pointer was captured
  101008. */
  101009. isPointerCaptured(pointerId?: number): boolean;
  101010. /**
  101011. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101012. * @param attachUp defines if you want to attach events to pointerup
  101013. * @param attachDown defines if you want to attach events to pointerdown
  101014. * @param attachMove defines if you want to attach events to pointermove
  101015. */
  101016. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101017. /**
  101018. * Detaches all event handlers
  101019. */
  101020. detachControl(): void;
  101021. /**
  101022. * Force the value of meshUnderPointer
  101023. * @param mesh defines the mesh to use
  101024. */
  101025. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101026. /**
  101027. * Gets the mesh under the pointer
  101028. * @returns a Mesh or null if no mesh is under the pointer
  101029. */
  101030. getPointerOverMesh(): Nullable<AbstractMesh>;
  101031. }
  101032. }
  101033. declare module BABYLON {
  101034. /**
  101035. * Helper class used to generate session unique ID
  101036. */
  101037. export class UniqueIdGenerator {
  101038. private static _UniqueIdCounter;
  101039. /**
  101040. * Gets an unique (relatively to the current scene) Id
  101041. */
  101042. static readonly UniqueId: number;
  101043. }
  101044. }
  101045. declare module BABYLON {
  101046. /**
  101047. * This class defines the direct association between an animation and a target
  101048. */
  101049. export class TargetedAnimation {
  101050. /**
  101051. * Animation to perform
  101052. */
  101053. animation: Animation;
  101054. /**
  101055. * Target to animate
  101056. */
  101057. target: any;
  101058. /**
  101059. * Serialize the object
  101060. * @returns the JSON object representing the current entity
  101061. */
  101062. serialize(): any;
  101063. }
  101064. /**
  101065. * Use this class to create coordinated animations on multiple targets
  101066. */
  101067. export class AnimationGroup implements IDisposable {
  101068. /** The name of the animation group */
  101069. name: string;
  101070. private _scene;
  101071. private _targetedAnimations;
  101072. private _animatables;
  101073. private _from;
  101074. private _to;
  101075. private _isStarted;
  101076. private _isPaused;
  101077. private _speedRatio;
  101078. private _loopAnimation;
  101079. /**
  101080. * Gets or sets the unique id of the node
  101081. */
  101082. uniqueId: number;
  101083. /**
  101084. * This observable will notify when one animation have ended
  101085. */
  101086. onAnimationEndObservable: Observable<TargetedAnimation>;
  101087. /**
  101088. * Observer raised when one animation loops
  101089. */
  101090. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101091. /**
  101092. * Observer raised when all animations have looped
  101093. */
  101094. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101095. /**
  101096. * This observable will notify when all animations have ended.
  101097. */
  101098. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101099. /**
  101100. * This observable will notify when all animations have paused.
  101101. */
  101102. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101103. /**
  101104. * This observable will notify when all animations are playing.
  101105. */
  101106. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101107. /**
  101108. * Gets the first frame
  101109. */
  101110. readonly from: number;
  101111. /**
  101112. * Gets the last frame
  101113. */
  101114. readonly to: number;
  101115. /**
  101116. * Define if the animations are started
  101117. */
  101118. readonly isStarted: boolean;
  101119. /**
  101120. * Gets a value indicating that the current group is playing
  101121. */
  101122. readonly isPlaying: boolean;
  101123. /**
  101124. * Gets or sets the speed ratio to use for all animations
  101125. */
  101126. /**
  101127. * Gets or sets the speed ratio to use for all animations
  101128. */
  101129. speedRatio: number;
  101130. /**
  101131. * Gets or sets if all animations should loop or not
  101132. */
  101133. loopAnimation: boolean;
  101134. /**
  101135. * Gets the targeted animations for this animation group
  101136. */
  101137. readonly targetedAnimations: Array<TargetedAnimation>;
  101138. /**
  101139. * returning the list of animatables controlled by this animation group.
  101140. */
  101141. readonly animatables: Array<Animatable>;
  101142. /**
  101143. * Instantiates a new Animation Group.
  101144. * This helps managing several animations at once.
  101145. * @see http://doc.babylonjs.com/how_to/group
  101146. * @param name Defines the name of the group
  101147. * @param scene Defines the scene the group belongs to
  101148. */
  101149. constructor(
  101150. /** The name of the animation group */
  101151. name: string, scene?: Nullable<Scene>);
  101152. /**
  101153. * Add an animation (with its target) in the group
  101154. * @param animation defines the animation we want to add
  101155. * @param target defines the target of the animation
  101156. * @returns the TargetedAnimation object
  101157. */
  101158. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101159. /**
  101160. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101161. * It can add constant keys at begin or end
  101162. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101163. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101164. * @returns the animation group
  101165. */
  101166. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101167. private _animationLoopCount;
  101168. private _animationLoopFlags;
  101169. private _processLoop;
  101170. /**
  101171. * Start all animations on given targets
  101172. * @param loop defines if animations must loop
  101173. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101174. * @param from defines the from key (optional)
  101175. * @param to defines the to key (optional)
  101176. * @returns the current animation group
  101177. */
  101178. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101179. /**
  101180. * Pause all animations
  101181. * @returns the animation group
  101182. */
  101183. pause(): AnimationGroup;
  101184. /**
  101185. * Play all animations to initial state
  101186. * This function will start() the animations if they were not started or will restart() them if they were paused
  101187. * @param loop defines if animations must loop
  101188. * @returns the animation group
  101189. */
  101190. play(loop?: boolean): AnimationGroup;
  101191. /**
  101192. * Reset all animations to initial state
  101193. * @returns the animation group
  101194. */
  101195. reset(): AnimationGroup;
  101196. /**
  101197. * Restart animations from key 0
  101198. * @returns the animation group
  101199. */
  101200. restart(): AnimationGroup;
  101201. /**
  101202. * Stop all animations
  101203. * @returns the animation group
  101204. */
  101205. stop(): AnimationGroup;
  101206. /**
  101207. * Set animation weight for all animatables
  101208. * @param weight defines the weight to use
  101209. * @return the animationGroup
  101210. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101211. */
  101212. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101213. /**
  101214. * Synchronize and normalize all animatables with a source animatable
  101215. * @param root defines the root animatable to synchronize with
  101216. * @return the animationGroup
  101217. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101218. */
  101219. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101220. /**
  101221. * Goes to a specific frame in this animation group
  101222. * @param frame the frame number to go to
  101223. * @return the animationGroup
  101224. */
  101225. goToFrame(frame: number): AnimationGroup;
  101226. /**
  101227. * Dispose all associated resources
  101228. */
  101229. dispose(): void;
  101230. private _checkAnimationGroupEnded;
  101231. /**
  101232. * Clone the current animation group and returns a copy
  101233. * @param newName defines the name of the new group
  101234. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101235. * @returns the new aniamtion group
  101236. */
  101237. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101238. /**
  101239. * Serializes the animationGroup to an object
  101240. * @returns Serialized object
  101241. */
  101242. serialize(): any;
  101243. /**
  101244. * Returns a new AnimationGroup object parsed from the source provided.
  101245. * @param parsedAnimationGroup defines the source
  101246. * @param scene defines the scene that will receive the animationGroup
  101247. * @returns a new AnimationGroup
  101248. */
  101249. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101250. /**
  101251. * Returns the string "AnimationGroup"
  101252. * @returns "AnimationGroup"
  101253. */
  101254. getClassName(): string;
  101255. /**
  101256. * Creates a detailled string about the object
  101257. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101258. * @returns a string representing the object
  101259. */
  101260. toString(fullDetails?: boolean): string;
  101261. }
  101262. }
  101263. declare module BABYLON {
  101264. /**
  101265. * Define an interface for all classes that will hold resources
  101266. */
  101267. export interface IDisposable {
  101268. /**
  101269. * Releases all held resources
  101270. */
  101271. dispose(): void;
  101272. }
  101273. /** Interface defining initialization parameters for Scene class */
  101274. export interface SceneOptions {
  101275. /**
  101276. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101277. * It will improve performance when the number of geometries becomes important.
  101278. */
  101279. useGeometryUniqueIdsMap?: boolean;
  101280. /**
  101281. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101282. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101283. */
  101284. useMaterialMeshMap?: boolean;
  101285. /**
  101286. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101287. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101288. */
  101289. useClonedMeshhMap?: boolean;
  101290. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101291. virtual?: boolean;
  101292. }
  101293. /**
  101294. * Represents a scene to be rendered by the engine.
  101295. * @see http://doc.babylonjs.com/features/scene
  101296. */
  101297. export class Scene extends AbstractScene implements IAnimatable {
  101298. /** The fog is deactivated */
  101299. static readonly FOGMODE_NONE: number;
  101300. /** The fog density is following an exponential function */
  101301. static readonly FOGMODE_EXP: number;
  101302. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101303. static readonly FOGMODE_EXP2: number;
  101304. /** The fog density is following a linear function. */
  101305. static readonly FOGMODE_LINEAR: number;
  101306. /**
  101307. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101308. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101309. */
  101310. static MinDeltaTime: number;
  101311. /**
  101312. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101313. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101314. */
  101315. static MaxDeltaTime: number;
  101316. /**
  101317. * Factory used to create the default material.
  101318. * @param name The name of the material to create
  101319. * @param scene The scene to create the material for
  101320. * @returns The default material
  101321. */
  101322. static DefaultMaterialFactory(scene: Scene): Material;
  101323. /**
  101324. * Factory used to create the a collision coordinator.
  101325. * @returns The collision coordinator
  101326. */
  101327. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101328. /** @hidden */
  101329. _inputManager: InputManager;
  101330. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101331. cameraToUseForPointers: Nullable<Camera>;
  101332. /** @hidden */
  101333. readonly _isScene: boolean;
  101334. /**
  101335. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101336. */
  101337. autoClear: boolean;
  101338. /**
  101339. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101340. */
  101341. autoClearDepthAndStencil: boolean;
  101342. /**
  101343. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101344. */
  101345. clearColor: Color4;
  101346. /**
  101347. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101348. */
  101349. ambientColor: Color3;
  101350. /**
  101351. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101352. * It should only be one of the following (if not the default embedded one):
  101353. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101354. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101355. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101356. * The material properties need to be setup according to the type of texture in use.
  101357. */
  101358. environmentBRDFTexture: BaseTexture;
  101359. /** @hidden */
  101360. protected _environmentTexture: Nullable<BaseTexture>;
  101361. /**
  101362. * Texture used in all pbr material as the reflection texture.
  101363. * As in the majority of the scene they are the same (exception for multi room and so on),
  101364. * this is easier to reference from here than from all the materials.
  101365. */
  101366. /**
  101367. * Texture used in all pbr material as the reflection texture.
  101368. * As in the majority of the scene they are the same (exception for multi room and so on),
  101369. * this is easier to set here than in all the materials.
  101370. */
  101371. environmentTexture: Nullable<BaseTexture>;
  101372. /** @hidden */
  101373. protected _environmentIntensity: number;
  101374. /**
  101375. * Intensity of the environment in all pbr material.
  101376. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101377. * As in the majority of the scene they are the same (exception for multi room and so on),
  101378. * this is easier to reference from here than from all the materials.
  101379. */
  101380. /**
  101381. * Intensity of the environment in all pbr material.
  101382. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101383. * As in the majority of the scene they are the same (exception for multi room and so on),
  101384. * this is easier to set here than in all the materials.
  101385. */
  101386. environmentIntensity: number;
  101387. /** @hidden */
  101388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101389. /**
  101390. * Default image processing configuration used either in the rendering
  101391. * Forward main pass or through the imageProcessingPostProcess if present.
  101392. * As in the majority of the scene they are the same (exception for multi camera),
  101393. * this is easier to reference from here than from all the materials and post process.
  101394. *
  101395. * No setter as we it is a shared configuration, you can set the values instead.
  101396. */
  101397. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101398. private _forceWireframe;
  101399. /**
  101400. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101401. */
  101402. forceWireframe: boolean;
  101403. private _forcePointsCloud;
  101404. /**
  101405. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101406. */
  101407. forcePointsCloud: boolean;
  101408. /**
  101409. * Gets or sets the active clipplane 1
  101410. */
  101411. clipPlane: Nullable<Plane>;
  101412. /**
  101413. * Gets or sets the active clipplane 2
  101414. */
  101415. clipPlane2: Nullable<Plane>;
  101416. /**
  101417. * Gets or sets the active clipplane 3
  101418. */
  101419. clipPlane3: Nullable<Plane>;
  101420. /**
  101421. * Gets or sets the active clipplane 4
  101422. */
  101423. clipPlane4: Nullable<Plane>;
  101424. /**
  101425. * Gets or sets a boolean indicating if animations are enabled
  101426. */
  101427. animationsEnabled: boolean;
  101428. private _animationPropertiesOverride;
  101429. /**
  101430. * Gets or sets the animation properties override
  101431. */
  101432. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101433. /**
  101434. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101435. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101436. */
  101437. useConstantAnimationDeltaTime: boolean;
  101438. /**
  101439. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101440. * Please note that it requires to run a ray cast through the scene on every frame
  101441. */
  101442. constantlyUpdateMeshUnderPointer: boolean;
  101443. /**
  101444. * Defines the HTML cursor to use when hovering over interactive elements
  101445. */
  101446. hoverCursor: string;
  101447. /**
  101448. * Defines the HTML default cursor to use (empty by default)
  101449. */
  101450. defaultCursor: string;
  101451. /**
  101452. * Defines wether cursors are handled by the scene.
  101453. */
  101454. doNotHandleCursors: boolean;
  101455. /**
  101456. * This is used to call preventDefault() on pointer down
  101457. * in order to block unwanted artifacts like system double clicks
  101458. */
  101459. preventDefaultOnPointerDown: boolean;
  101460. /**
  101461. * This is used to call preventDefault() on pointer up
  101462. * in order to block unwanted artifacts like system double clicks
  101463. */
  101464. preventDefaultOnPointerUp: boolean;
  101465. /**
  101466. * Gets or sets user defined metadata
  101467. */
  101468. metadata: any;
  101469. /**
  101470. * For internal use only. Please do not use.
  101471. */
  101472. reservedDataStore: any;
  101473. /**
  101474. * Gets the name of the plugin used to load this scene (null by default)
  101475. */
  101476. loadingPluginName: string;
  101477. /**
  101478. * Use this array to add regular expressions used to disable offline support for specific urls
  101479. */
  101480. disableOfflineSupportExceptionRules: RegExp[];
  101481. /**
  101482. * An event triggered when the scene is disposed.
  101483. */
  101484. onDisposeObservable: Observable<Scene>;
  101485. private _onDisposeObserver;
  101486. /** Sets a function to be executed when this scene is disposed. */
  101487. onDispose: () => void;
  101488. /**
  101489. * An event triggered before rendering the scene (right after animations and physics)
  101490. */
  101491. onBeforeRenderObservable: Observable<Scene>;
  101492. private _onBeforeRenderObserver;
  101493. /** Sets a function to be executed before rendering this scene */
  101494. beforeRender: Nullable<() => void>;
  101495. /**
  101496. * An event triggered after rendering the scene
  101497. */
  101498. onAfterRenderObservable: Observable<Scene>;
  101499. /**
  101500. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101501. */
  101502. onAfterRenderCameraObservable: Observable<Camera>;
  101503. private _onAfterRenderObserver;
  101504. /** Sets a function to be executed after rendering this scene */
  101505. afterRender: Nullable<() => void>;
  101506. /**
  101507. * An event triggered before animating the scene
  101508. */
  101509. onBeforeAnimationsObservable: Observable<Scene>;
  101510. /**
  101511. * An event triggered after animations processing
  101512. */
  101513. onAfterAnimationsObservable: Observable<Scene>;
  101514. /**
  101515. * An event triggered before draw calls are ready to be sent
  101516. */
  101517. onBeforeDrawPhaseObservable: Observable<Scene>;
  101518. /**
  101519. * An event triggered after draw calls have been sent
  101520. */
  101521. onAfterDrawPhaseObservable: Observable<Scene>;
  101522. /**
  101523. * An event triggered when the scene is ready
  101524. */
  101525. onReadyObservable: Observable<Scene>;
  101526. /**
  101527. * An event triggered before rendering a camera
  101528. */
  101529. onBeforeCameraRenderObservable: Observable<Camera>;
  101530. private _onBeforeCameraRenderObserver;
  101531. /** Sets a function to be executed before rendering a camera*/
  101532. beforeCameraRender: () => void;
  101533. /**
  101534. * An event triggered after rendering a camera
  101535. */
  101536. onAfterCameraRenderObservable: Observable<Camera>;
  101537. private _onAfterCameraRenderObserver;
  101538. /** Sets a function to be executed after rendering a camera*/
  101539. afterCameraRender: () => void;
  101540. /**
  101541. * An event triggered when active meshes evaluation is about to start
  101542. */
  101543. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101544. /**
  101545. * An event triggered when active meshes evaluation is done
  101546. */
  101547. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101548. /**
  101549. * An event triggered when particles rendering is about to start
  101550. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101551. */
  101552. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101553. /**
  101554. * An event triggered when particles rendering is done
  101555. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101556. */
  101557. onAfterParticlesRenderingObservable: Observable<Scene>;
  101558. /**
  101559. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101560. */
  101561. onDataLoadedObservable: Observable<Scene>;
  101562. /**
  101563. * An event triggered when a camera is created
  101564. */
  101565. onNewCameraAddedObservable: Observable<Camera>;
  101566. /**
  101567. * An event triggered when a camera is removed
  101568. */
  101569. onCameraRemovedObservable: Observable<Camera>;
  101570. /**
  101571. * An event triggered when a light is created
  101572. */
  101573. onNewLightAddedObservable: Observable<Light>;
  101574. /**
  101575. * An event triggered when a light is removed
  101576. */
  101577. onLightRemovedObservable: Observable<Light>;
  101578. /**
  101579. * An event triggered when a geometry is created
  101580. */
  101581. onNewGeometryAddedObservable: Observable<Geometry>;
  101582. /**
  101583. * An event triggered when a geometry is removed
  101584. */
  101585. onGeometryRemovedObservable: Observable<Geometry>;
  101586. /**
  101587. * An event triggered when a transform node is created
  101588. */
  101589. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101590. /**
  101591. * An event triggered when a transform node is removed
  101592. */
  101593. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101594. /**
  101595. * An event triggered when a mesh is created
  101596. */
  101597. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101598. /**
  101599. * An event triggered when a mesh is removed
  101600. */
  101601. onMeshRemovedObservable: Observable<AbstractMesh>;
  101602. /**
  101603. * An event triggered when a skeleton is created
  101604. */
  101605. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101606. /**
  101607. * An event triggered when a skeleton is removed
  101608. */
  101609. onSkeletonRemovedObservable: Observable<Skeleton>;
  101610. /**
  101611. * An event triggered when a material is created
  101612. */
  101613. onNewMaterialAddedObservable: Observable<Material>;
  101614. /**
  101615. * An event triggered when a material is removed
  101616. */
  101617. onMaterialRemovedObservable: Observable<Material>;
  101618. /**
  101619. * An event triggered when a texture is created
  101620. */
  101621. onNewTextureAddedObservable: Observable<BaseTexture>;
  101622. /**
  101623. * An event triggered when a texture is removed
  101624. */
  101625. onTextureRemovedObservable: Observable<BaseTexture>;
  101626. /**
  101627. * An event triggered when render targets are about to be rendered
  101628. * Can happen multiple times per frame.
  101629. */
  101630. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101631. /**
  101632. * An event triggered when render targets were rendered.
  101633. * Can happen multiple times per frame.
  101634. */
  101635. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101636. /**
  101637. * An event triggered before calculating deterministic simulation step
  101638. */
  101639. onBeforeStepObservable: Observable<Scene>;
  101640. /**
  101641. * An event triggered after calculating deterministic simulation step
  101642. */
  101643. onAfterStepObservable: Observable<Scene>;
  101644. /**
  101645. * An event triggered when the activeCamera property is updated
  101646. */
  101647. onActiveCameraChanged: Observable<Scene>;
  101648. /**
  101649. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101650. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101651. * 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)
  101652. */
  101653. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101654. /**
  101655. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101656. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101657. * 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)
  101658. */
  101659. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101660. /**
  101661. * This Observable will when a mesh has been imported into the scene.
  101662. */
  101663. onMeshImportedObservable: Observable<AbstractMesh>;
  101664. /**
  101665. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101666. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101667. */
  101668. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101669. /** @hidden */
  101670. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101671. /**
  101672. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101673. */
  101674. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101675. /**
  101676. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101677. */
  101678. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101679. /**
  101680. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101681. */
  101682. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101683. /** Callback called when a pointer move is detected */
  101684. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101685. /** Callback called when a pointer down is detected */
  101686. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101687. /** Callback called when a pointer up is detected */
  101688. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101689. /** Callback called when a pointer pick is detected */
  101690. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101691. /**
  101692. * 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).
  101693. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101694. */
  101695. onPrePointerObservable: Observable<PointerInfoPre>;
  101696. /**
  101697. * Observable event triggered each time an input event is received from the rendering canvas
  101698. */
  101699. onPointerObservable: Observable<PointerInfo>;
  101700. /**
  101701. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101702. */
  101703. readonly unTranslatedPointer: Vector2;
  101704. /**
  101705. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101706. */
  101707. static DragMovementThreshold: number;
  101708. /**
  101709. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101710. */
  101711. static LongPressDelay: number;
  101712. /**
  101713. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101714. */
  101715. static DoubleClickDelay: number;
  101716. /** If you need to check double click without raising a single click at first click, enable this flag */
  101717. static ExclusiveDoubleClickMode: boolean;
  101718. /** @hidden */
  101719. _mirroredCameraPosition: Nullable<Vector3>;
  101720. /**
  101721. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101722. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101723. */
  101724. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101725. /**
  101726. * Observable event triggered each time an keyboard event is received from the hosting window
  101727. */
  101728. onKeyboardObservable: Observable<KeyboardInfo>;
  101729. private _useRightHandedSystem;
  101730. /**
  101731. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101732. */
  101733. useRightHandedSystem: boolean;
  101734. private _timeAccumulator;
  101735. private _currentStepId;
  101736. private _currentInternalStep;
  101737. /**
  101738. * Sets the step Id used by deterministic lock step
  101739. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101740. * @param newStepId defines the step Id
  101741. */
  101742. setStepId(newStepId: number): void;
  101743. /**
  101744. * Gets the step Id used by deterministic lock step
  101745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101746. * @returns the step Id
  101747. */
  101748. getStepId(): number;
  101749. /**
  101750. * Gets the internal step used by deterministic lock step
  101751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101752. * @returns the internal step
  101753. */
  101754. getInternalStep(): number;
  101755. private _fogEnabled;
  101756. /**
  101757. * Gets or sets a boolean indicating if fog is enabled on this scene
  101758. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101759. * (Default is true)
  101760. */
  101761. fogEnabled: boolean;
  101762. private _fogMode;
  101763. /**
  101764. * Gets or sets the fog mode to use
  101765. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101766. * | mode | value |
  101767. * | --- | --- |
  101768. * | FOGMODE_NONE | 0 |
  101769. * | FOGMODE_EXP | 1 |
  101770. * | FOGMODE_EXP2 | 2 |
  101771. * | FOGMODE_LINEAR | 3 |
  101772. */
  101773. fogMode: number;
  101774. /**
  101775. * Gets or sets the fog color to use
  101776. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101777. * (Default is Color3(0.2, 0.2, 0.3))
  101778. */
  101779. fogColor: Color3;
  101780. /**
  101781. * Gets or sets the fog density to use
  101782. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101783. * (Default is 0.1)
  101784. */
  101785. fogDensity: number;
  101786. /**
  101787. * Gets or sets the fog start distance to use
  101788. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101789. * (Default is 0)
  101790. */
  101791. fogStart: number;
  101792. /**
  101793. * Gets or sets the fog end distance to use
  101794. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101795. * (Default is 1000)
  101796. */
  101797. fogEnd: number;
  101798. private _shadowsEnabled;
  101799. /**
  101800. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101801. */
  101802. shadowsEnabled: boolean;
  101803. private _lightsEnabled;
  101804. /**
  101805. * Gets or sets a boolean indicating if lights are enabled on this scene
  101806. */
  101807. lightsEnabled: boolean;
  101808. /** All of the active cameras added to this scene. */
  101809. activeCameras: Camera[];
  101810. /** @hidden */
  101811. _activeCamera: Nullable<Camera>;
  101812. /** Gets or sets the current active camera */
  101813. activeCamera: Nullable<Camera>;
  101814. private _defaultMaterial;
  101815. /** The default material used on meshes when no material is affected */
  101816. /** The default material used on meshes when no material is affected */
  101817. defaultMaterial: Material;
  101818. private _texturesEnabled;
  101819. /**
  101820. * Gets or sets a boolean indicating if textures are enabled on this scene
  101821. */
  101822. texturesEnabled: boolean;
  101823. /**
  101824. * Gets or sets a boolean indicating if particles are enabled on this scene
  101825. */
  101826. particlesEnabled: boolean;
  101827. /**
  101828. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101829. */
  101830. spritesEnabled: boolean;
  101831. private _skeletonsEnabled;
  101832. /**
  101833. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101834. */
  101835. skeletonsEnabled: boolean;
  101836. /**
  101837. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101838. */
  101839. lensFlaresEnabled: boolean;
  101840. /**
  101841. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101842. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101843. */
  101844. collisionsEnabled: boolean;
  101845. private _collisionCoordinator;
  101846. /** @hidden */
  101847. readonly collisionCoordinator: ICollisionCoordinator;
  101848. /**
  101849. * Defines the gravity applied to this scene (used only for collisions)
  101850. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101851. */
  101852. gravity: Vector3;
  101853. /**
  101854. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101855. */
  101856. postProcessesEnabled: boolean;
  101857. /**
  101858. * The list of postprocesses added to the scene
  101859. */
  101860. postProcesses: PostProcess[];
  101861. /**
  101862. * Gets the current postprocess manager
  101863. */
  101864. postProcessManager: PostProcessManager;
  101865. /**
  101866. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101867. */
  101868. renderTargetsEnabled: boolean;
  101869. /**
  101870. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101871. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101872. */
  101873. dumpNextRenderTargets: boolean;
  101874. /**
  101875. * The list of user defined render targets added to the scene
  101876. */
  101877. customRenderTargets: RenderTargetTexture[];
  101878. /**
  101879. * Defines if texture loading must be delayed
  101880. * If true, textures will only be loaded when they need to be rendered
  101881. */
  101882. useDelayedTextureLoading: boolean;
  101883. /**
  101884. * Gets the list of meshes imported to the scene through SceneLoader
  101885. */
  101886. importedMeshesFiles: String[];
  101887. /**
  101888. * Gets or sets a boolean indicating if probes are enabled on this scene
  101889. */
  101890. probesEnabled: boolean;
  101891. /**
  101892. * Gets or sets the current offline provider to use to store scene data
  101893. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101894. */
  101895. offlineProvider: IOfflineProvider;
  101896. /**
  101897. * Gets or sets the action manager associated with the scene
  101898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101899. */
  101900. actionManager: AbstractActionManager;
  101901. private _meshesForIntersections;
  101902. /**
  101903. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101904. */
  101905. proceduralTexturesEnabled: boolean;
  101906. private _engine;
  101907. private _totalVertices;
  101908. /** @hidden */
  101909. _activeIndices: PerfCounter;
  101910. /** @hidden */
  101911. _activeParticles: PerfCounter;
  101912. /** @hidden */
  101913. _activeBones: PerfCounter;
  101914. private _animationRatio;
  101915. /** @hidden */
  101916. _animationTimeLast: number;
  101917. /** @hidden */
  101918. _animationTime: number;
  101919. /**
  101920. * Gets or sets a general scale for animation speed
  101921. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101922. */
  101923. animationTimeScale: number;
  101924. /** @hidden */
  101925. _cachedMaterial: Nullable<Material>;
  101926. /** @hidden */
  101927. _cachedEffect: Nullable<Effect>;
  101928. /** @hidden */
  101929. _cachedVisibility: Nullable<number>;
  101930. private _renderId;
  101931. private _frameId;
  101932. private _executeWhenReadyTimeoutId;
  101933. private _intermediateRendering;
  101934. private _viewUpdateFlag;
  101935. private _projectionUpdateFlag;
  101936. /** @hidden */
  101937. _toBeDisposed: Nullable<IDisposable>[];
  101938. private _activeRequests;
  101939. /** @hidden */
  101940. _pendingData: any[];
  101941. private _isDisposed;
  101942. /**
  101943. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101944. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101945. */
  101946. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101947. private _activeMeshes;
  101948. private _processedMaterials;
  101949. private _renderTargets;
  101950. /** @hidden */
  101951. _activeParticleSystems: SmartArray<IParticleSystem>;
  101952. private _activeSkeletons;
  101953. private _softwareSkinnedMeshes;
  101954. private _renderingManager;
  101955. /** @hidden */
  101956. _activeAnimatables: Animatable[];
  101957. private _transformMatrix;
  101958. private _sceneUbo;
  101959. /** @hidden */
  101960. _viewMatrix: Matrix;
  101961. private _projectionMatrix;
  101962. /** @hidden */
  101963. _forcedViewPosition: Nullable<Vector3>;
  101964. /** @hidden */
  101965. _frustumPlanes: Plane[];
  101966. /**
  101967. * Gets the list of frustum planes (built from the active camera)
  101968. */
  101969. readonly frustumPlanes: Plane[];
  101970. /**
  101971. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101972. * This is useful if there are more lights that the maximum simulteanous authorized
  101973. */
  101974. requireLightSorting: boolean;
  101975. /** @hidden */
  101976. readonly useMaterialMeshMap: boolean;
  101977. /** @hidden */
  101978. readonly useClonedMeshhMap: boolean;
  101979. private _externalData;
  101980. private _uid;
  101981. /**
  101982. * @hidden
  101983. * Backing store of defined scene components.
  101984. */
  101985. _components: ISceneComponent[];
  101986. /**
  101987. * @hidden
  101988. * Backing store of defined scene components.
  101989. */
  101990. _serializableComponents: ISceneSerializableComponent[];
  101991. /**
  101992. * List of components to register on the next registration step.
  101993. */
  101994. private _transientComponents;
  101995. /**
  101996. * Registers the transient components if needed.
  101997. */
  101998. private _registerTransientComponents;
  101999. /**
  102000. * @hidden
  102001. * Add a component to the scene.
  102002. * Note that the ccomponent could be registered on th next frame if this is called after
  102003. * the register component stage.
  102004. * @param component Defines the component to add to the scene
  102005. */
  102006. _addComponent(component: ISceneComponent): void;
  102007. /**
  102008. * @hidden
  102009. * Gets a component from the scene.
  102010. * @param name defines the name of the component to retrieve
  102011. * @returns the component or null if not present
  102012. */
  102013. _getComponent(name: string): Nullable<ISceneComponent>;
  102014. /**
  102015. * @hidden
  102016. * Defines the actions happening before camera updates.
  102017. */
  102018. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102019. /**
  102020. * @hidden
  102021. * Defines the actions happening before clear the canvas.
  102022. */
  102023. _beforeClearStage: Stage<SimpleStageAction>;
  102024. /**
  102025. * @hidden
  102026. * Defines the actions when collecting render targets for the frame.
  102027. */
  102028. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102029. /**
  102030. * @hidden
  102031. * Defines the actions happening for one camera in the frame.
  102032. */
  102033. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102034. /**
  102035. * @hidden
  102036. * Defines the actions happening during the per mesh ready checks.
  102037. */
  102038. _isReadyForMeshStage: Stage<MeshStageAction>;
  102039. /**
  102040. * @hidden
  102041. * Defines the actions happening before evaluate active mesh checks.
  102042. */
  102043. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102044. /**
  102045. * @hidden
  102046. * Defines the actions happening during the evaluate sub mesh checks.
  102047. */
  102048. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102049. /**
  102050. * @hidden
  102051. * Defines the actions happening during the active mesh stage.
  102052. */
  102053. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102054. /**
  102055. * @hidden
  102056. * Defines the actions happening during the per camera render target step.
  102057. */
  102058. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102059. /**
  102060. * @hidden
  102061. * Defines the actions happening just before the active camera is drawing.
  102062. */
  102063. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102064. /**
  102065. * @hidden
  102066. * Defines the actions happening just before a render target is drawing.
  102067. */
  102068. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102069. /**
  102070. * @hidden
  102071. * Defines the actions happening just before a rendering group is drawing.
  102072. */
  102073. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102074. /**
  102075. * @hidden
  102076. * Defines the actions happening just before a mesh is drawing.
  102077. */
  102078. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102079. /**
  102080. * @hidden
  102081. * Defines the actions happening just after a mesh has been drawn.
  102082. */
  102083. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102084. /**
  102085. * @hidden
  102086. * Defines the actions happening just after a rendering group has been drawn.
  102087. */
  102088. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102089. /**
  102090. * @hidden
  102091. * Defines the actions happening just after the active camera has been drawn.
  102092. */
  102093. _afterCameraDrawStage: Stage<CameraStageAction>;
  102094. /**
  102095. * @hidden
  102096. * Defines the actions happening just after a render target has been drawn.
  102097. */
  102098. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102099. /**
  102100. * @hidden
  102101. * Defines the actions happening just after rendering all cameras and computing intersections.
  102102. */
  102103. _afterRenderStage: Stage<SimpleStageAction>;
  102104. /**
  102105. * @hidden
  102106. * Defines the actions happening when a pointer move event happens.
  102107. */
  102108. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102109. /**
  102110. * @hidden
  102111. * Defines the actions happening when a pointer down event happens.
  102112. */
  102113. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102114. /**
  102115. * @hidden
  102116. * Defines the actions happening when a pointer up event happens.
  102117. */
  102118. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102119. /**
  102120. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102121. */
  102122. private geometriesByUniqueId;
  102123. /**
  102124. * Creates a new Scene
  102125. * @param engine defines the engine to use to render this scene
  102126. * @param options defines the scene options
  102127. */
  102128. constructor(engine: Engine, options?: SceneOptions);
  102129. /**
  102130. * Gets a string idenfifying the name of the class
  102131. * @returns "Scene" string
  102132. */
  102133. getClassName(): string;
  102134. private _defaultMeshCandidates;
  102135. /**
  102136. * @hidden
  102137. */
  102138. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102139. private _defaultSubMeshCandidates;
  102140. /**
  102141. * @hidden
  102142. */
  102143. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102144. /**
  102145. * Sets the default candidate providers for the scene.
  102146. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102147. * and getCollidingSubMeshCandidates to their default function
  102148. */
  102149. setDefaultCandidateProviders(): void;
  102150. /**
  102151. * Gets the mesh that is currently under the pointer
  102152. */
  102153. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102154. /**
  102155. * Gets or sets the current on-screen X position of the pointer
  102156. */
  102157. pointerX: number;
  102158. /**
  102159. * Gets or sets the current on-screen Y position of the pointer
  102160. */
  102161. pointerY: number;
  102162. /**
  102163. * Gets the cached material (ie. the latest rendered one)
  102164. * @returns the cached material
  102165. */
  102166. getCachedMaterial(): Nullable<Material>;
  102167. /**
  102168. * Gets the cached effect (ie. the latest rendered one)
  102169. * @returns the cached effect
  102170. */
  102171. getCachedEffect(): Nullable<Effect>;
  102172. /**
  102173. * Gets the cached visibility state (ie. the latest rendered one)
  102174. * @returns the cached visibility state
  102175. */
  102176. getCachedVisibility(): Nullable<number>;
  102177. /**
  102178. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102179. * @param material defines the current material
  102180. * @param effect defines the current effect
  102181. * @param visibility defines the current visibility state
  102182. * @returns true if one parameter is not cached
  102183. */
  102184. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102185. /**
  102186. * Gets the engine associated with the scene
  102187. * @returns an Engine
  102188. */
  102189. getEngine(): Engine;
  102190. /**
  102191. * Gets the total number of vertices rendered per frame
  102192. * @returns the total number of vertices rendered per frame
  102193. */
  102194. getTotalVertices(): number;
  102195. /**
  102196. * Gets the performance counter for total vertices
  102197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102198. */
  102199. readonly totalVerticesPerfCounter: PerfCounter;
  102200. /**
  102201. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102202. * @returns the total number of active indices rendered per frame
  102203. */
  102204. getActiveIndices(): number;
  102205. /**
  102206. * Gets the performance counter for active indices
  102207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102208. */
  102209. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102210. /**
  102211. * Gets the total number of active particles rendered per frame
  102212. * @returns the total number of active particles rendered per frame
  102213. */
  102214. getActiveParticles(): number;
  102215. /**
  102216. * Gets the performance counter for active particles
  102217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102218. */
  102219. readonly activeParticlesPerfCounter: PerfCounter;
  102220. /**
  102221. * Gets the total number of active bones rendered per frame
  102222. * @returns the total number of active bones rendered per frame
  102223. */
  102224. getActiveBones(): number;
  102225. /**
  102226. * Gets the performance counter for active bones
  102227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102228. */
  102229. readonly activeBonesPerfCounter: PerfCounter;
  102230. /**
  102231. * Gets the array of active meshes
  102232. * @returns an array of AbstractMesh
  102233. */
  102234. getActiveMeshes(): SmartArray<AbstractMesh>;
  102235. /**
  102236. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102237. * @returns a number
  102238. */
  102239. getAnimationRatio(): number;
  102240. /**
  102241. * Gets an unique Id for the current render phase
  102242. * @returns a number
  102243. */
  102244. getRenderId(): number;
  102245. /**
  102246. * Gets an unique Id for the current frame
  102247. * @returns a number
  102248. */
  102249. getFrameId(): number;
  102250. /** Call this function if you want to manually increment the render Id*/
  102251. incrementRenderId(): void;
  102252. private _createUbo;
  102253. /**
  102254. * Use this method to simulate a pointer move on a mesh
  102255. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102256. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102257. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102258. * @returns the current scene
  102259. */
  102260. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102261. /**
  102262. * Use this method to simulate a pointer down on a mesh
  102263. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102264. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102265. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102266. * @returns the current scene
  102267. */
  102268. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102269. /**
  102270. * Use this method to simulate a pointer up on a mesh
  102271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102274. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102275. * @returns the current scene
  102276. */
  102277. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102278. /**
  102279. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102280. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102281. * @returns true if the pointer was captured
  102282. */
  102283. isPointerCaptured(pointerId?: number): boolean;
  102284. /**
  102285. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102286. * @param attachUp defines if you want to attach events to pointerup
  102287. * @param attachDown defines if you want to attach events to pointerdown
  102288. * @param attachMove defines if you want to attach events to pointermove
  102289. */
  102290. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102291. /** Detaches all event handlers*/
  102292. detachControl(): void;
  102293. /**
  102294. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102295. * Delay loaded resources are not taking in account
  102296. * @return true if all required resources are ready
  102297. */
  102298. isReady(): boolean;
  102299. /** Resets all cached information relative to material (including effect and visibility) */
  102300. resetCachedMaterial(): void;
  102301. /**
  102302. * Registers a function to be called before every frame render
  102303. * @param func defines the function to register
  102304. */
  102305. registerBeforeRender(func: () => void): void;
  102306. /**
  102307. * Unregisters a function called before every frame render
  102308. * @param func defines the function to unregister
  102309. */
  102310. unregisterBeforeRender(func: () => void): void;
  102311. /**
  102312. * Registers a function to be called after every frame render
  102313. * @param func defines the function to register
  102314. */
  102315. registerAfterRender(func: () => void): void;
  102316. /**
  102317. * Unregisters a function called after every frame render
  102318. * @param func defines the function to unregister
  102319. */
  102320. unregisterAfterRender(func: () => void): void;
  102321. private _executeOnceBeforeRender;
  102322. /**
  102323. * The provided function will run before render once and will be disposed afterwards.
  102324. * A timeout delay can be provided so that the function will be executed in N ms.
  102325. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102326. * @param func The function to be executed.
  102327. * @param timeout optional delay in ms
  102328. */
  102329. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102330. /** @hidden */
  102331. _addPendingData(data: any): void;
  102332. /** @hidden */
  102333. _removePendingData(data: any): void;
  102334. /**
  102335. * Returns the number of items waiting to be loaded
  102336. * @returns the number of items waiting to be loaded
  102337. */
  102338. getWaitingItemsCount(): number;
  102339. /**
  102340. * Returns a boolean indicating if the scene is still loading data
  102341. */
  102342. readonly isLoading: boolean;
  102343. /**
  102344. * Registers a function to be executed when the scene is ready
  102345. * @param {Function} func - the function to be executed
  102346. */
  102347. executeWhenReady(func: () => void): void;
  102348. /**
  102349. * Returns a promise that resolves when the scene is ready
  102350. * @returns A promise that resolves when the scene is ready
  102351. */
  102352. whenReadyAsync(): Promise<void>;
  102353. /** @hidden */
  102354. _checkIsReady(): void;
  102355. /**
  102356. * Gets all animatable attached to the scene
  102357. */
  102358. readonly animatables: Animatable[];
  102359. /**
  102360. * Resets the last animation time frame.
  102361. * Useful to override when animations start running when loading a scene for the first time.
  102362. */
  102363. resetLastAnimationTimeFrame(): void;
  102364. /**
  102365. * Gets the current view matrix
  102366. * @returns a Matrix
  102367. */
  102368. getViewMatrix(): Matrix;
  102369. /**
  102370. * Gets the current projection matrix
  102371. * @returns a Matrix
  102372. */
  102373. getProjectionMatrix(): Matrix;
  102374. /**
  102375. * Gets the current transform matrix
  102376. * @returns a Matrix made of View * Projection
  102377. */
  102378. getTransformMatrix(): Matrix;
  102379. /**
  102380. * Sets the current transform matrix
  102381. * @param viewL defines the View matrix to use
  102382. * @param projectionL defines the Projection matrix to use
  102383. * @param viewR defines the right View matrix to use (if provided)
  102384. * @param projectionR defines the right Projection matrix to use (if provided)
  102385. */
  102386. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102387. /**
  102388. * Gets the uniform buffer used to store scene data
  102389. * @returns a UniformBuffer
  102390. */
  102391. getSceneUniformBuffer(): UniformBuffer;
  102392. /**
  102393. * Gets an unique (relatively to the current scene) Id
  102394. * @returns an unique number for the scene
  102395. */
  102396. getUniqueId(): number;
  102397. /**
  102398. * Add a mesh to the list of scene's meshes
  102399. * @param newMesh defines the mesh to add
  102400. * @param recursive if all child meshes should also be added to the scene
  102401. */
  102402. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102403. /**
  102404. * Remove a mesh for the list of scene's meshes
  102405. * @param toRemove defines the mesh to remove
  102406. * @param recursive if all child meshes should also be removed from the scene
  102407. * @returns the index where the mesh was in the mesh list
  102408. */
  102409. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102410. /**
  102411. * Add a transform node to the list of scene's transform nodes
  102412. * @param newTransformNode defines the transform node to add
  102413. */
  102414. addTransformNode(newTransformNode: TransformNode): void;
  102415. /**
  102416. * Remove a transform node for the list of scene's transform nodes
  102417. * @param toRemove defines the transform node to remove
  102418. * @returns the index where the transform node was in the transform node list
  102419. */
  102420. removeTransformNode(toRemove: TransformNode): number;
  102421. /**
  102422. * Remove a skeleton for the list of scene's skeletons
  102423. * @param toRemove defines the skeleton to remove
  102424. * @returns the index where the skeleton was in the skeleton list
  102425. */
  102426. removeSkeleton(toRemove: Skeleton): number;
  102427. /**
  102428. * Remove a morph target for the list of scene's morph targets
  102429. * @param toRemove defines the morph target to remove
  102430. * @returns the index where the morph target was in the morph target list
  102431. */
  102432. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102433. /**
  102434. * Remove a light for the list of scene's lights
  102435. * @param toRemove defines the light to remove
  102436. * @returns the index where the light was in the light list
  102437. */
  102438. removeLight(toRemove: Light): number;
  102439. /**
  102440. * Remove a camera for the list of scene's cameras
  102441. * @param toRemove defines the camera to remove
  102442. * @returns the index where the camera was in the camera list
  102443. */
  102444. removeCamera(toRemove: Camera): number;
  102445. /**
  102446. * Remove a particle system for the list of scene's particle systems
  102447. * @param toRemove defines the particle system to remove
  102448. * @returns the index where the particle system was in the particle system list
  102449. */
  102450. removeParticleSystem(toRemove: IParticleSystem): number;
  102451. /**
  102452. * Remove a animation for the list of scene's animations
  102453. * @param toRemove defines the animation to remove
  102454. * @returns the index where the animation was in the animation list
  102455. */
  102456. removeAnimation(toRemove: Animation): number;
  102457. /**
  102458. * Will stop the animation of the given target
  102459. * @param target - the target
  102460. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102461. * @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)
  102462. */
  102463. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102464. /**
  102465. * Removes the given animation group from this scene.
  102466. * @param toRemove The animation group to remove
  102467. * @returns The index of the removed animation group
  102468. */
  102469. removeAnimationGroup(toRemove: AnimationGroup): number;
  102470. /**
  102471. * Removes the given multi-material from this scene.
  102472. * @param toRemove The multi-material to remove
  102473. * @returns The index of the removed multi-material
  102474. */
  102475. removeMultiMaterial(toRemove: MultiMaterial): number;
  102476. /**
  102477. * Removes the given material from this scene.
  102478. * @param toRemove The material to remove
  102479. * @returns The index of the removed material
  102480. */
  102481. removeMaterial(toRemove: Material): number;
  102482. /**
  102483. * Removes the given action manager from this scene.
  102484. * @param toRemove The action manager to remove
  102485. * @returns The index of the removed action manager
  102486. */
  102487. removeActionManager(toRemove: AbstractActionManager): number;
  102488. /**
  102489. * Removes the given texture from this scene.
  102490. * @param toRemove The texture to remove
  102491. * @returns The index of the removed texture
  102492. */
  102493. removeTexture(toRemove: BaseTexture): number;
  102494. /**
  102495. * Adds the given light to this scene
  102496. * @param newLight The light to add
  102497. */
  102498. addLight(newLight: Light): void;
  102499. /**
  102500. * Sorts the list list based on light priorities
  102501. */
  102502. sortLightsByPriority(): void;
  102503. /**
  102504. * Adds the given camera to this scene
  102505. * @param newCamera The camera to add
  102506. */
  102507. addCamera(newCamera: Camera): void;
  102508. /**
  102509. * Adds the given skeleton to this scene
  102510. * @param newSkeleton The skeleton to add
  102511. */
  102512. addSkeleton(newSkeleton: Skeleton): void;
  102513. /**
  102514. * Adds the given particle system to this scene
  102515. * @param newParticleSystem The particle system to add
  102516. */
  102517. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102518. /**
  102519. * Adds the given animation to this scene
  102520. * @param newAnimation The animation to add
  102521. */
  102522. addAnimation(newAnimation: Animation): void;
  102523. /**
  102524. * Adds the given animation group to this scene.
  102525. * @param newAnimationGroup The animation group to add
  102526. */
  102527. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102528. /**
  102529. * Adds the given multi-material to this scene
  102530. * @param newMultiMaterial The multi-material to add
  102531. */
  102532. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102533. /**
  102534. * Adds the given material to this scene
  102535. * @param newMaterial The material to add
  102536. */
  102537. addMaterial(newMaterial: Material): void;
  102538. /**
  102539. * Adds the given morph target to this scene
  102540. * @param newMorphTargetManager The morph target to add
  102541. */
  102542. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102543. /**
  102544. * Adds the given geometry to this scene
  102545. * @param newGeometry The geometry to add
  102546. */
  102547. addGeometry(newGeometry: Geometry): void;
  102548. /**
  102549. * Adds the given action manager to this scene
  102550. * @param newActionManager The action manager to add
  102551. */
  102552. addActionManager(newActionManager: AbstractActionManager): void;
  102553. /**
  102554. * Adds the given texture to this scene.
  102555. * @param newTexture The texture to add
  102556. */
  102557. addTexture(newTexture: BaseTexture): void;
  102558. /**
  102559. * Switch active camera
  102560. * @param newCamera defines the new active camera
  102561. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102562. */
  102563. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102564. /**
  102565. * sets the active camera of the scene using its ID
  102566. * @param id defines the camera's ID
  102567. * @return the new active camera or null if none found.
  102568. */
  102569. setActiveCameraByID(id: string): Nullable<Camera>;
  102570. /**
  102571. * sets the active camera of the scene using its name
  102572. * @param name defines the camera's name
  102573. * @returns the new active camera or null if none found.
  102574. */
  102575. setActiveCameraByName(name: string): Nullable<Camera>;
  102576. /**
  102577. * get an animation group using its name
  102578. * @param name defines the material's name
  102579. * @return the animation group or null if none found.
  102580. */
  102581. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102582. /**
  102583. * Get a material using its unique id
  102584. * @param uniqueId defines the material's unique id
  102585. * @return the material or null if none found.
  102586. */
  102587. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102588. /**
  102589. * get a material using its id
  102590. * @param id defines the material's ID
  102591. * @return the material or null if none found.
  102592. */
  102593. getMaterialByID(id: string): Nullable<Material>;
  102594. /**
  102595. * Gets a the last added material using a given id
  102596. * @param id defines the material's ID
  102597. * @return the last material with the given id or null if none found.
  102598. */
  102599. getLastMaterialByID(id: string): Nullable<Material>;
  102600. /**
  102601. * Gets a material using its name
  102602. * @param name defines the material's name
  102603. * @return the material or null if none found.
  102604. */
  102605. getMaterialByName(name: string): Nullable<Material>;
  102606. /**
  102607. * Get a texture using its unique id
  102608. * @param uniqueId defines the texture's unique id
  102609. * @return the texture or null if none found.
  102610. */
  102611. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102612. /**
  102613. * Gets a camera using its id
  102614. * @param id defines the id to look for
  102615. * @returns the camera or null if not found
  102616. */
  102617. getCameraByID(id: string): Nullable<Camera>;
  102618. /**
  102619. * Gets a camera using its unique id
  102620. * @param uniqueId defines the unique id to look for
  102621. * @returns the camera or null if not found
  102622. */
  102623. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102624. /**
  102625. * Gets a camera using its name
  102626. * @param name defines the camera's name
  102627. * @return the camera or null if none found.
  102628. */
  102629. getCameraByName(name: string): Nullable<Camera>;
  102630. /**
  102631. * Gets a bone using its id
  102632. * @param id defines the bone's id
  102633. * @return the bone or null if not found
  102634. */
  102635. getBoneByID(id: string): Nullable<Bone>;
  102636. /**
  102637. * Gets a bone using its id
  102638. * @param name defines the bone's name
  102639. * @return the bone or null if not found
  102640. */
  102641. getBoneByName(name: string): Nullable<Bone>;
  102642. /**
  102643. * Gets a light node using its name
  102644. * @param name defines the the light's name
  102645. * @return the light or null if none found.
  102646. */
  102647. getLightByName(name: string): Nullable<Light>;
  102648. /**
  102649. * Gets a light node using its id
  102650. * @param id defines the light's id
  102651. * @return the light or null if none found.
  102652. */
  102653. getLightByID(id: string): Nullable<Light>;
  102654. /**
  102655. * Gets a light node using its scene-generated unique ID
  102656. * @param uniqueId defines the light's unique id
  102657. * @return the light or null if none found.
  102658. */
  102659. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102660. /**
  102661. * Gets a particle system by id
  102662. * @param id defines the particle system id
  102663. * @return the corresponding system or null if none found
  102664. */
  102665. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102666. /**
  102667. * Gets a geometry using its ID
  102668. * @param id defines the geometry's id
  102669. * @return the geometry or null if none found.
  102670. */
  102671. getGeometryByID(id: string): Nullable<Geometry>;
  102672. private _getGeometryByUniqueID;
  102673. /**
  102674. * Add a new geometry to this scene
  102675. * @param geometry defines the geometry to be added to the scene.
  102676. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102677. * @return a boolean defining if the geometry was added or not
  102678. */
  102679. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102680. /**
  102681. * Removes an existing geometry
  102682. * @param geometry defines the geometry to be removed from the scene
  102683. * @return a boolean defining if the geometry was removed or not
  102684. */
  102685. removeGeometry(geometry: Geometry): boolean;
  102686. /**
  102687. * Gets the list of geometries attached to the scene
  102688. * @returns an array of Geometry
  102689. */
  102690. getGeometries(): Geometry[];
  102691. /**
  102692. * Gets the first added mesh found of a given ID
  102693. * @param id defines the id to search for
  102694. * @return the mesh found or null if not found at all
  102695. */
  102696. getMeshByID(id: string): Nullable<AbstractMesh>;
  102697. /**
  102698. * Gets a list of meshes using their id
  102699. * @param id defines the id to search for
  102700. * @returns a list of meshes
  102701. */
  102702. getMeshesByID(id: string): Array<AbstractMesh>;
  102703. /**
  102704. * Gets the first added transform node found of a given ID
  102705. * @param id defines the id to search for
  102706. * @return the found transform node or null if not found at all.
  102707. */
  102708. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102709. /**
  102710. * Gets a transform node with its auto-generated unique id
  102711. * @param uniqueId efines the unique id to search for
  102712. * @return the found transform node or null if not found at all.
  102713. */
  102714. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102715. /**
  102716. * Gets a list of transform nodes using their id
  102717. * @param id defines the id to search for
  102718. * @returns a list of transform nodes
  102719. */
  102720. getTransformNodesByID(id: string): Array<TransformNode>;
  102721. /**
  102722. * Gets a mesh with its auto-generated unique id
  102723. * @param uniqueId defines the unique id to search for
  102724. * @return the found mesh or null if not found at all.
  102725. */
  102726. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102727. /**
  102728. * Gets a the last added mesh using a given id
  102729. * @param id defines the id to search for
  102730. * @return the found mesh or null if not found at all.
  102731. */
  102732. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102733. /**
  102734. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102735. * @param id defines the id to search for
  102736. * @return the found node or null if not found at all
  102737. */
  102738. getLastEntryByID(id: string): Nullable<Node>;
  102739. /**
  102740. * Gets a node (Mesh, Camera, Light) using a given id
  102741. * @param id defines the id to search for
  102742. * @return the found node or null if not found at all
  102743. */
  102744. getNodeByID(id: string): Nullable<Node>;
  102745. /**
  102746. * Gets a node (Mesh, Camera, Light) using a given name
  102747. * @param name defines the name to search for
  102748. * @return the found node or null if not found at all.
  102749. */
  102750. getNodeByName(name: string): Nullable<Node>;
  102751. /**
  102752. * Gets a mesh using a given name
  102753. * @param name defines the name to search for
  102754. * @return the found mesh or null if not found at all.
  102755. */
  102756. getMeshByName(name: string): Nullable<AbstractMesh>;
  102757. /**
  102758. * Gets a transform node using a given name
  102759. * @param name defines the name to search for
  102760. * @return the found transform node or null if not found at all.
  102761. */
  102762. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102763. /**
  102764. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102765. * @param id defines the id to search for
  102766. * @return the found skeleton or null if not found at all.
  102767. */
  102768. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102769. /**
  102770. * Gets a skeleton using a given auto generated unique id
  102771. * @param uniqueId defines the unique id to search for
  102772. * @return the found skeleton or null if not found at all.
  102773. */
  102774. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102775. /**
  102776. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102777. * @param id defines the id to search for
  102778. * @return the found skeleton or null if not found at all.
  102779. */
  102780. getSkeletonById(id: string): Nullable<Skeleton>;
  102781. /**
  102782. * Gets a skeleton using a given name
  102783. * @param name defines the name to search for
  102784. * @return the found skeleton or null if not found at all.
  102785. */
  102786. getSkeletonByName(name: string): Nullable<Skeleton>;
  102787. /**
  102788. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102789. * @param id defines the id to search for
  102790. * @return the found morph target manager or null if not found at all.
  102791. */
  102792. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102793. /**
  102794. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102795. * @param id defines the id to search for
  102796. * @return the found morph target or null if not found at all.
  102797. */
  102798. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102799. /**
  102800. * Gets a boolean indicating if the given mesh is active
  102801. * @param mesh defines the mesh to look for
  102802. * @returns true if the mesh is in the active list
  102803. */
  102804. isActiveMesh(mesh: AbstractMesh): boolean;
  102805. /**
  102806. * Return a unique id as a string which can serve as an identifier for the scene
  102807. */
  102808. readonly uid: string;
  102809. /**
  102810. * Add an externaly attached data from its key.
  102811. * This method call will fail and return false, if such key already exists.
  102812. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102813. * @param key the unique key that identifies the data
  102814. * @param data the data object to associate to the key for this Engine instance
  102815. * @return true if no such key were already present and the data was added successfully, false otherwise
  102816. */
  102817. addExternalData<T>(key: string, data: T): boolean;
  102818. /**
  102819. * Get an externaly attached data from its key
  102820. * @param key the unique key that identifies the data
  102821. * @return the associated data, if present (can be null), or undefined if not present
  102822. */
  102823. getExternalData<T>(key: string): Nullable<T>;
  102824. /**
  102825. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102826. * @param key the unique key that identifies the data
  102827. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102828. * @return the associated data, can be null if the factory returned null.
  102829. */
  102830. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102831. /**
  102832. * Remove an externaly attached data from the Engine instance
  102833. * @param key the unique key that identifies the data
  102834. * @return true if the data was successfully removed, false if it doesn't exist
  102835. */
  102836. removeExternalData(key: string): boolean;
  102837. private _evaluateSubMesh;
  102838. /**
  102839. * Clear the processed materials smart array preventing retention point in material dispose.
  102840. */
  102841. freeProcessedMaterials(): void;
  102842. private _preventFreeActiveMeshesAndRenderingGroups;
  102843. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102844. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102845. * when disposing several meshes in a row or a hierarchy of meshes.
  102846. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102847. */
  102848. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102849. /**
  102850. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102851. */
  102852. freeActiveMeshes(): void;
  102853. /**
  102854. * Clear the info related to rendering groups preventing retention points during dispose.
  102855. */
  102856. freeRenderingGroups(): void;
  102857. /** @hidden */
  102858. _isInIntermediateRendering(): boolean;
  102859. /**
  102860. * Lambda returning the list of potentially active meshes.
  102861. */
  102862. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102863. /**
  102864. * Lambda returning the list of potentially active sub meshes.
  102865. */
  102866. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102867. /**
  102868. * Lambda returning the list of potentially intersecting sub meshes.
  102869. */
  102870. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102871. /**
  102872. * Lambda returning the list of potentially colliding sub meshes.
  102873. */
  102874. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102875. private _activeMeshesFrozen;
  102876. /**
  102877. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102878. * @returns the current scene
  102879. */
  102880. freezeActiveMeshes(): Scene;
  102881. /**
  102882. * Use this function to restart evaluating active meshes on every frame
  102883. * @returns the current scene
  102884. */
  102885. unfreezeActiveMeshes(): Scene;
  102886. private _evaluateActiveMeshes;
  102887. private _activeMesh;
  102888. /**
  102889. * Update the transform matrix to update from the current active camera
  102890. * @param force defines a boolean used to force the update even if cache is up to date
  102891. */
  102892. updateTransformMatrix(force?: boolean): void;
  102893. private _bindFrameBuffer;
  102894. /** @hidden */
  102895. _allowPostProcessClearColor: boolean;
  102896. /** @hidden */
  102897. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102898. private _processSubCameras;
  102899. private _checkIntersections;
  102900. /** @hidden */
  102901. _advancePhysicsEngineStep(step: number): void;
  102902. /**
  102903. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102904. */
  102905. getDeterministicFrameTime: () => number;
  102906. /** @hidden */
  102907. _animate(): void;
  102908. /** Execute all animations (for a frame) */
  102909. animate(): void;
  102910. /**
  102911. * Render the scene
  102912. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102913. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102914. */
  102915. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102916. /**
  102917. * Freeze all materials
  102918. * A frozen material will not be updatable but should be faster to render
  102919. */
  102920. freezeMaterials(): void;
  102921. /**
  102922. * Unfreeze all materials
  102923. * A frozen material will not be updatable but should be faster to render
  102924. */
  102925. unfreezeMaterials(): void;
  102926. /**
  102927. * Releases all held ressources
  102928. */
  102929. dispose(): void;
  102930. /**
  102931. * Gets if the scene is already disposed
  102932. */
  102933. readonly isDisposed: boolean;
  102934. /**
  102935. * Call this function to reduce memory footprint of the scene.
  102936. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102937. */
  102938. clearCachedVertexData(): void;
  102939. /**
  102940. * This function will remove the local cached buffer data from texture.
  102941. * It will save memory but will prevent the texture from being rebuilt
  102942. */
  102943. cleanCachedTextureBuffer(): void;
  102944. /**
  102945. * Get the world extend vectors with an optional filter
  102946. *
  102947. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102948. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102949. */
  102950. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102951. min: Vector3;
  102952. max: Vector3;
  102953. };
  102954. /**
  102955. * Creates a ray that can be used to pick in the scene
  102956. * @param x defines the x coordinate of the origin (on-screen)
  102957. * @param y defines the y coordinate of the origin (on-screen)
  102958. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102959. * @param camera defines the camera to use for the picking
  102960. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102961. * @returns a Ray
  102962. */
  102963. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102964. /**
  102965. * Creates a ray that can be used to pick in the scene
  102966. * @param x defines the x coordinate of the origin (on-screen)
  102967. * @param y defines the y coordinate of the origin (on-screen)
  102968. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102969. * @param result defines the ray where to store the picking ray
  102970. * @param camera defines the camera to use for the picking
  102971. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102972. * @returns the current scene
  102973. */
  102974. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102975. /**
  102976. * Creates a ray that can be used to pick in the scene
  102977. * @param x defines the x coordinate of the origin (on-screen)
  102978. * @param y defines the y coordinate of the origin (on-screen)
  102979. * @param camera defines the camera to use for the picking
  102980. * @returns a Ray
  102981. */
  102982. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102983. /**
  102984. * Creates a ray that can be used to pick in the scene
  102985. * @param x defines the x coordinate of the origin (on-screen)
  102986. * @param y defines the y coordinate of the origin (on-screen)
  102987. * @param result defines the ray where to store the picking ray
  102988. * @param camera defines the camera to use for the picking
  102989. * @returns the current scene
  102990. */
  102991. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102992. /** Launch a ray to try to pick a mesh in the scene
  102993. * @param x position on screen
  102994. * @param y position on screen
  102995. * @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
  102996. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102997. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102998. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102999. * @returns a PickingInfo
  103000. */
  103001. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103002. /** Use the given ray to pick a mesh in the scene
  103003. * @param ray The ray to use to pick meshes
  103004. * @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
  103005. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103006. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103007. * @returns a PickingInfo
  103008. */
  103009. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103010. /**
  103011. * Launch a ray to try to pick a mesh in the scene
  103012. * @param x X position on screen
  103013. * @param y Y position on screen
  103014. * @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
  103015. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103016. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103017. * @returns an array of PickingInfo
  103018. */
  103019. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103020. /**
  103021. * Launch a ray to try to pick a mesh in the scene
  103022. * @param ray Ray to use
  103023. * @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
  103024. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103025. * @returns an array of PickingInfo
  103026. */
  103027. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103028. /**
  103029. * Force the value of meshUnderPointer
  103030. * @param mesh defines the mesh to use
  103031. */
  103032. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103033. /**
  103034. * Gets the mesh under the pointer
  103035. * @returns a Mesh or null if no mesh is under the pointer
  103036. */
  103037. getPointerOverMesh(): Nullable<AbstractMesh>;
  103038. /** @hidden */
  103039. _rebuildGeometries(): void;
  103040. /** @hidden */
  103041. _rebuildTextures(): void;
  103042. private _getByTags;
  103043. /**
  103044. * Get a list of meshes by tags
  103045. * @param tagsQuery defines the tags query to use
  103046. * @param forEach defines a predicate used to filter results
  103047. * @returns an array of Mesh
  103048. */
  103049. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103050. /**
  103051. * Get a list of cameras by tags
  103052. * @param tagsQuery defines the tags query to use
  103053. * @param forEach defines a predicate used to filter results
  103054. * @returns an array of Camera
  103055. */
  103056. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103057. /**
  103058. * Get a list of lights by tags
  103059. * @param tagsQuery defines the tags query to use
  103060. * @param forEach defines a predicate used to filter results
  103061. * @returns an array of Light
  103062. */
  103063. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103064. /**
  103065. * Get a list of materials by tags
  103066. * @param tagsQuery defines the tags query to use
  103067. * @param forEach defines a predicate used to filter results
  103068. * @returns an array of Material
  103069. */
  103070. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103071. /**
  103072. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103073. * This allowed control for front to back rendering or reversly depending of the special needs.
  103074. *
  103075. * @param renderingGroupId The rendering group id corresponding to its index
  103076. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103077. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103078. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103079. */
  103080. 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;
  103081. /**
  103082. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103083. *
  103084. * @param renderingGroupId The rendering group id corresponding to its index
  103085. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103086. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103087. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103088. */
  103089. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103090. /**
  103091. * Gets the current auto clear configuration for one rendering group of the rendering
  103092. * manager.
  103093. * @param index the rendering group index to get the information for
  103094. * @returns The auto clear setup for the requested rendering group
  103095. */
  103096. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103097. private _blockMaterialDirtyMechanism;
  103098. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103099. blockMaterialDirtyMechanism: boolean;
  103100. /**
  103101. * Will flag all materials as dirty to trigger new shader compilation
  103102. * @param flag defines the flag used to specify which material part must be marked as dirty
  103103. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103104. */
  103105. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103106. /** @hidden */
  103107. _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;
  103108. /** @hidden */
  103109. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103110. /** @hidden */
  103111. _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;
  103112. /** @hidden */
  103113. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103114. /** @hidden */
  103115. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103116. /** @hidden */
  103117. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103118. }
  103119. }
  103120. declare module BABYLON {
  103121. /**
  103122. * Set of assets to keep when moving a scene into an asset container.
  103123. */
  103124. export class KeepAssets extends AbstractScene {
  103125. }
  103126. /**
  103127. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103128. */
  103129. export class InstantiatedEntries {
  103130. /**
  103131. * List of new root nodes (eg. nodes with no parent)
  103132. */
  103133. rootNodes: TransformNode[];
  103134. /**
  103135. * List of new skeletons
  103136. */
  103137. skeletons: Skeleton[];
  103138. /**
  103139. * List of new animation groups
  103140. */
  103141. animationGroups: AnimationGroup[];
  103142. }
  103143. /**
  103144. * Container with a set of assets that can be added or removed from a scene.
  103145. */
  103146. export class AssetContainer extends AbstractScene {
  103147. /**
  103148. * The scene the AssetContainer belongs to.
  103149. */
  103150. scene: Scene;
  103151. /**
  103152. * Instantiates an AssetContainer.
  103153. * @param scene The scene the AssetContainer belongs to.
  103154. */
  103155. constructor(scene: Scene);
  103156. /**
  103157. * Instantiate or clone all meshes and add the new ones to the scene.
  103158. * Skeletons and animation groups will all be cloned
  103159. * @param nameFunction defines an optional function used to get new names for clones
  103160. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103161. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103162. */
  103163. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103164. /**
  103165. * Adds all the assets from the container to the scene.
  103166. */
  103167. addAllToScene(): void;
  103168. /**
  103169. * Removes all the assets in the container from the scene
  103170. */
  103171. removeAllFromScene(): void;
  103172. /**
  103173. * Disposes all the assets in the container
  103174. */
  103175. dispose(): void;
  103176. private _moveAssets;
  103177. /**
  103178. * Removes all the assets contained in the scene and adds them to the container.
  103179. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103180. */
  103181. moveAllFromScene(keepAssets?: KeepAssets): void;
  103182. /**
  103183. * 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.
  103184. * @returns the root mesh
  103185. */
  103186. createRootMesh(): Mesh;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /**
  103191. * Defines how the parser contract is defined.
  103192. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103193. */
  103194. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103195. /**
  103196. * Defines how the individual parser contract is defined.
  103197. * These parser can parse an individual asset
  103198. */
  103199. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103200. /**
  103201. * Base class of the scene acting as a container for the different elements composing a scene.
  103202. * This class is dynamically extended by the different components of the scene increasing
  103203. * flexibility and reducing coupling
  103204. */
  103205. export abstract class AbstractScene {
  103206. /**
  103207. * Stores the list of available parsers in the application.
  103208. */
  103209. private static _BabylonFileParsers;
  103210. /**
  103211. * Stores the list of available individual parsers in the application.
  103212. */
  103213. private static _IndividualBabylonFileParsers;
  103214. /**
  103215. * Adds a parser in the list of available ones
  103216. * @param name Defines the name of the parser
  103217. * @param parser Defines the parser to add
  103218. */
  103219. static AddParser(name: string, parser: BabylonFileParser): void;
  103220. /**
  103221. * Gets a general parser from the list of avaialble ones
  103222. * @param name Defines the name of the parser
  103223. * @returns the requested parser or null
  103224. */
  103225. static GetParser(name: string): Nullable<BabylonFileParser>;
  103226. /**
  103227. * Adds n individual parser in the list of available ones
  103228. * @param name Defines the name of the parser
  103229. * @param parser Defines the parser to add
  103230. */
  103231. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103232. /**
  103233. * Gets an individual parser from the list of avaialble ones
  103234. * @param name Defines the name of the parser
  103235. * @returns the requested parser or null
  103236. */
  103237. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103238. /**
  103239. * Parser json data and populate both a scene and its associated container object
  103240. * @param jsonData Defines the data to parse
  103241. * @param scene Defines the scene to parse the data for
  103242. * @param container Defines the container attached to the parsing sequence
  103243. * @param rootUrl Defines the root url of the data
  103244. */
  103245. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103246. /**
  103247. * Gets the list of root nodes (ie. nodes with no parent)
  103248. */
  103249. rootNodes: Node[];
  103250. /** All of the cameras added to this scene
  103251. * @see http://doc.babylonjs.com/babylon101/cameras
  103252. */
  103253. cameras: Camera[];
  103254. /**
  103255. * All of the lights added to this scene
  103256. * @see http://doc.babylonjs.com/babylon101/lights
  103257. */
  103258. lights: Light[];
  103259. /**
  103260. * All of the (abstract) meshes added to this scene
  103261. */
  103262. meshes: AbstractMesh[];
  103263. /**
  103264. * The list of skeletons added to the scene
  103265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103266. */
  103267. skeletons: Skeleton[];
  103268. /**
  103269. * All of the particle systems added to this scene
  103270. * @see http://doc.babylonjs.com/babylon101/particles
  103271. */
  103272. particleSystems: IParticleSystem[];
  103273. /**
  103274. * Gets a list of Animations associated with the scene
  103275. */
  103276. animations: Animation[];
  103277. /**
  103278. * All of the animation groups added to this scene
  103279. * @see http://doc.babylonjs.com/how_to/group
  103280. */
  103281. animationGroups: AnimationGroup[];
  103282. /**
  103283. * All of the multi-materials added to this scene
  103284. * @see http://doc.babylonjs.com/how_to/multi_materials
  103285. */
  103286. multiMaterials: MultiMaterial[];
  103287. /**
  103288. * All of the materials added to this scene
  103289. * In the context of a Scene, it is not supposed to be modified manually.
  103290. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103291. * Note also that the order of the Material within the array is not significant and might change.
  103292. * @see http://doc.babylonjs.com/babylon101/materials
  103293. */
  103294. materials: Material[];
  103295. /**
  103296. * The list of morph target managers added to the scene
  103297. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103298. */
  103299. morphTargetManagers: MorphTargetManager[];
  103300. /**
  103301. * The list of geometries used in the scene.
  103302. */
  103303. geometries: Geometry[];
  103304. /**
  103305. * All of the tranform nodes added to this scene
  103306. * In the context of a Scene, it is not supposed to be modified manually.
  103307. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103308. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103309. * @see http://doc.babylonjs.com/how_to/transformnode
  103310. */
  103311. transformNodes: TransformNode[];
  103312. /**
  103313. * ActionManagers available on the scene.
  103314. */
  103315. actionManagers: AbstractActionManager[];
  103316. /**
  103317. * Textures to keep.
  103318. */
  103319. textures: BaseTexture[];
  103320. /**
  103321. * Environment texture for the scene
  103322. */
  103323. environmentTexture: Nullable<BaseTexture>;
  103324. }
  103325. }
  103326. declare module BABYLON {
  103327. /**
  103328. * Interface used to define options for Sound class
  103329. */
  103330. export interface ISoundOptions {
  103331. /**
  103332. * Does the sound autoplay once loaded.
  103333. */
  103334. autoplay?: boolean;
  103335. /**
  103336. * Does the sound loop after it finishes playing once.
  103337. */
  103338. loop?: boolean;
  103339. /**
  103340. * Sound's volume
  103341. */
  103342. volume?: number;
  103343. /**
  103344. * Is it a spatial sound?
  103345. */
  103346. spatialSound?: boolean;
  103347. /**
  103348. * Maximum distance to hear that sound
  103349. */
  103350. maxDistance?: number;
  103351. /**
  103352. * Uses user defined attenuation function
  103353. */
  103354. useCustomAttenuation?: boolean;
  103355. /**
  103356. * Define the roll off factor of spatial sounds.
  103357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103358. */
  103359. rolloffFactor?: number;
  103360. /**
  103361. * Define the reference distance the sound should be heard perfectly.
  103362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103363. */
  103364. refDistance?: number;
  103365. /**
  103366. * Define the distance attenuation model the sound will follow.
  103367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103368. */
  103369. distanceModel?: string;
  103370. /**
  103371. * Defines the playback speed (1 by default)
  103372. */
  103373. playbackRate?: number;
  103374. /**
  103375. * Defines if the sound is from a streaming source
  103376. */
  103377. streaming?: boolean;
  103378. /**
  103379. * Defines an optional length (in seconds) inside the sound file
  103380. */
  103381. length?: number;
  103382. /**
  103383. * Defines an optional offset (in seconds) inside the sound file
  103384. */
  103385. offset?: number;
  103386. /**
  103387. * If true, URLs will not be required to state the audio file codec to use.
  103388. */
  103389. skipCodecCheck?: boolean;
  103390. }
  103391. /**
  103392. * Defines a sound that can be played in the application.
  103393. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103395. */
  103396. export class Sound {
  103397. /**
  103398. * The name of the sound in the scene.
  103399. */
  103400. name: string;
  103401. /**
  103402. * Does the sound autoplay once loaded.
  103403. */
  103404. autoplay: boolean;
  103405. /**
  103406. * Does the sound loop after it finishes playing once.
  103407. */
  103408. loop: boolean;
  103409. /**
  103410. * Does the sound use a custom attenuation curve to simulate the falloff
  103411. * happening when the source gets further away from the camera.
  103412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103413. */
  103414. useCustomAttenuation: boolean;
  103415. /**
  103416. * The sound track id this sound belongs to.
  103417. */
  103418. soundTrackId: number;
  103419. /**
  103420. * Is this sound currently played.
  103421. */
  103422. isPlaying: boolean;
  103423. /**
  103424. * Is this sound currently paused.
  103425. */
  103426. isPaused: boolean;
  103427. /**
  103428. * Does this sound enables spatial sound.
  103429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103430. */
  103431. spatialSound: boolean;
  103432. /**
  103433. * Define the reference distance the sound should be heard perfectly.
  103434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103435. */
  103436. refDistance: number;
  103437. /**
  103438. * Define the roll off factor of spatial sounds.
  103439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103440. */
  103441. rolloffFactor: number;
  103442. /**
  103443. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103445. */
  103446. maxDistance: number;
  103447. /**
  103448. * Define the distance attenuation model the sound will follow.
  103449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103450. */
  103451. distanceModel: string;
  103452. /**
  103453. * @hidden
  103454. * Back Compat
  103455. **/
  103456. onended: () => any;
  103457. /**
  103458. * Observable event when the current playing sound finishes.
  103459. */
  103460. onEndedObservable: Observable<Sound>;
  103461. private _panningModel;
  103462. private _playbackRate;
  103463. private _streaming;
  103464. private _startTime;
  103465. private _startOffset;
  103466. private _position;
  103467. /** @hidden */
  103468. _positionInEmitterSpace: boolean;
  103469. private _localDirection;
  103470. private _volume;
  103471. private _isReadyToPlay;
  103472. private _isDirectional;
  103473. private _readyToPlayCallback;
  103474. private _audioBuffer;
  103475. private _soundSource;
  103476. private _streamingSource;
  103477. private _soundPanner;
  103478. private _soundGain;
  103479. private _inputAudioNode;
  103480. private _outputAudioNode;
  103481. private _coneInnerAngle;
  103482. private _coneOuterAngle;
  103483. private _coneOuterGain;
  103484. private _scene;
  103485. private _connectedTransformNode;
  103486. private _customAttenuationFunction;
  103487. private _registerFunc;
  103488. private _isOutputConnected;
  103489. private _htmlAudioElement;
  103490. private _urlType;
  103491. private _length?;
  103492. private _offset?;
  103493. /** @hidden */
  103494. static _SceneComponentInitialization: (scene: Scene) => void;
  103495. /**
  103496. * Create a sound and attach it to a scene
  103497. * @param name Name of your sound
  103498. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103499. * @param scene defines the scene the sound belongs to
  103500. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103501. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103502. */
  103503. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103504. /**
  103505. * Release the sound and its associated resources
  103506. */
  103507. dispose(): void;
  103508. /**
  103509. * Gets if the sounds is ready to be played or not.
  103510. * @returns true if ready, otherwise false
  103511. */
  103512. isReady(): boolean;
  103513. private _soundLoaded;
  103514. /**
  103515. * Sets the data of the sound from an audiobuffer
  103516. * @param audioBuffer The audioBuffer containing the data
  103517. */
  103518. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103519. /**
  103520. * Updates the current sounds options such as maxdistance, loop...
  103521. * @param options A JSON object containing values named as the object properties
  103522. */
  103523. updateOptions(options: ISoundOptions): void;
  103524. private _createSpatialParameters;
  103525. private _updateSpatialParameters;
  103526. /**
  103527. * Switch the panning model to HRTF:
  103528. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103530. */
  103531. switchPanningModelToHRTF(): void;
  103532. /**
  103533. * Switch the panning model to Equal Power:
  103534. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103536. */
  103537. switchPanningModelToEqualPower(): void;
  103538. private _switchPanningModel;
  103539. /**
  103540. * Connect this sound to a sound track audio node like gain...
  103541. * @param soundTrackAudioNode the sound track audio node to connect to
  103542. */
  103543. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103544. /**
  103545. * Transform this sound into a directional source
  103546. * @param coneInnerAngle Size of the inner cone in degree
  103547. * @param coneOuterAngle Size of the outer cone in degree
  103548. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103549. */
  103550. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103551. /**
  103552. * Gets or sets the inner angle for the directional cone.
  103553. */
  103554. /**
  103555. * Gets or sets the inner angle for the directional cone.
  103556. */
  103557. directionalConeInnerAngle: number;
  103558. /**
  103559. * Gets or sets the outer angle for the directional cone.
  103560. */
  103561. /**
  103562. * Gets or sets the outer angle for the directional cone.
  103563. */
  103564. directionalConeOuterAngle: number;
  103565. /**
  103566. * Sets the position of the emitter if spatial sound is enabled
  103567. * @param newPosition Defines the new posisiton
  103568. */
  103569. setPosition(newPosition: Vector3): void;
  103570. /**
  103571. * Sets the local direction of the emitter if spatial sound is enabled
  103572. * @param newLocalDirection Defines the new local direction
  103573. */
  103574. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103575. private _updateDirection;
  103576. /** @hidden */
  103577. updateDistanceFromListener(): void;
  103578. /**
  103579. * Sets a new custom attenuation function for the sound.
  103580. * @param callback Defines the function used for the attenuation
  103581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103582. */
  103583. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103584. /**
  103585. * Play the sound
  103586. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103587. * @param offset (optional) Start the sound at a specific time in seconds
  103588. * @param length (optional) Sound duration (in seconds)
  103589. */
  103590. play(time?: number, offset?: number, length?: number): void;
  103591. private _onended;
  103592. /**
  103593. * Stop the sound
  103594. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103595. */
  103596. stop(time?: number): void;
  103597. /**
  103598. * Put the sound in pause
  103599. */
  103600. pause(): void;
  103601. /**
  103602. * Sets a dedicated volume for this sounds
  103603. * @param newVolume Define the new volume of the sound
  103604. * @param time Define time for gradual change to new volume
  103605. */
  103606. setVolume(newVolume: number, time?: number): void;
  103607. /**
  103608. * Set the sound play back rate
  103609. * @param newPlaybackRate Define the playback rate the sound should be played at
  103610. */
  103611. setPlaybackRate(newPlaybackRate: number): void;
  103612. /**
  103613. * Gets the volume of the sound.
  103614. * @returns the volume of the sound
  103615. */
  103616. getVolume(): number;
  103617. /**
  103618. * Attach the sound to a dedicated mesh
  103619. * @param transformNode The transform node to connect the sound with
  103620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103621. */
  103622. attachToMesh(transformNode: TransformNode): void;
  103623. /**
  103624. * Detach the sound from the previously attached mesh
  103625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103626. */
  103627. detachFromMesh(): void;
  103628. private _onRegisterAfterWorldMatrixUpdate;
  103629. /**
  103630. * Clone the current sound in the scene.
  103631. * @returns the new sound clone
  103632. */
  103633. clone(): Nullable<Sound>;
  103634. /**
  103635. * Gets the current underlying audio buffer containing the data
  103636. * @returns the audio buffer
  103637. */
  103638. getAudioBuffer(): Nullable<AudioBuffer>;
  103639. /**
  103640. * Serializes the Sound in a JSON representation
  103641. * @returns the JSON representation of the sound
  103642. */
  103643. serialize(): any;
  103644. /**
  103645. * Parse a JSON representation of a sound to innstantiate in a given scene
  103646. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103647. * @param scene Define the scene the new parsed sound should be created in
  103648. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103649. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103650. * @returns the newly parsed sound
  103651. */
  103652. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103653. }
  103654. }
  103655. declare module BABYLON {
  103656. /**
  103657. * This defines an action helpful to play a defined sound on a triggered action.
  103658. */
  103659. export class PlaySoundAction extends Action {
  103660. private _sound;
  103661. /**
  103662. * Instantiate the action
  103663. * @param triggerOptions defines the trigger options
  103664. * @param sound defines the sound to play
  103665. * @param condition defines the trigger related conditions
  103666. */
  103667. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103668. /** @hidden */
  103669. _prepare(): void;
  103670. /**
  103671. * Execute the action and play the sound.
  103672. */
  103673. execute(): void;
  103674. /**
  103675. * Serializes the actions and its related information.
  103676. * @param parent defines the object to serialize in
  103677. * @returns the serialized object
  103678. */
  103679. serialize(parent: any): any;
  103680. }
  103681. /**
  103682. * This defines an action helpful to stop a defined sound on a triggered action.
  103683. */
  103684. export class StopSoundAction extends Action {
  103685. private _sound;
  103686. /**
  103687. * Instantiate the action
  103688. * @param triggerOptions defines the trigger options
  103689. * @param sound defines the sound to stop
  103690. * @param condition defines the trigger related conditions
  103691. */
  103692. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103693. /** @hidden */
  103694. _prepare(): void;
  103695. /**
  103696. * Execute the action and stop the sound.
  103697. */
  103698. execute(): void;
  103699. /**
  103700. * Serializes the actions and its related information.
  103701. * @param parent defines the object to serialize in
  103702. * @returns the serialized object
  103703. */
  103704. serialize(parent: any): any;
  103705. }
  103706. }
  103707. declare module BABYLON {
  103708. /**
  103709. * This defines an action responsible to change the value of a property
  103710. * by interpolating between its current value and the newly set one once triggered.
  103711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103712. */
  103713. export class InterpolateValueAction extends Action {
  103714. /**
  103715. * Defines the path of the property where the value should be interpolated
  103716. */
  103717. propertyPath: string;
  103718. /**
  103719. * Defines the target value at the end of the interpolation.
  103720. */
  103721. value: any;
  103722. /**
  103723. * Defines the time it will take for the property to interpolate to the value.
  103724. */
  103725. duration: number;
  103726. /**
  103727. * Defines if the other scene animations should be stopped when the action has been triggered
  103728. */
  103729. stopOtherAnimations?: boolean;
  103730. /**
  103731. * Defines a callback raised once the interpolation animation has been done.
  103732. */
  103733. onInterpolationDone?: () => void;
  103734. /**
  103735. * Observable triggered once the interpolation animation has been done.
  103736. */
  103737. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103738. private _target;
  103739. private _effectiveTarget;
  103740. private _property;
  103741. /**
  103742. * Instantiate the action
  103743. * @param triggerOptions defines the trigger options
  103744. * @param target defines the object containing the value to interpolate
  103745. * @param propertyPath defines the path to the property in the target object
  103746. * @param value defines the target value at the end of the interpolation
  103747. * @param duration deines the time it will take for the property to interpolate to the value.
  103748. * @param condition defines the trigger related conditions
  103749. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103750. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103751. */
  103752. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103753. /** @hidden */
  103754. _prepare(): void;
  103755. /**
  103756. * Execute the action starts the value interpolation.
  103757. */
  103758. execute(): void;
  103759. /**
  103760. * Serializes the actions and its related information.
  103761. * @param parent defines the object to serialize in
  103762. * @returns the serialized object
  103763. */
  103764. serialize(parent: any): any;
  103765. }
  103766. }
  103767. declare module BABYLON {
  103768. /**
  103769. * Options allowed during the creation of a sound track.
  103770. */
  103771. export interface ISoundTrackOptions {
  103772. /**
  103773. * The volume the sound track should take during creation
  103774. */
  103775. volume?: number;
  103776. /**
  103777. * Define if the sound track is the main sound track of the scene
  103778. */
  103779. mainTrack?: boolean;
  103780. }
  103781. /**
  103782. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103783. * It will be also used in a future release to apply effects on a specific track.
  103784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103785. */
  103786. export class SoundTrack {
  103787. /**
  103788. * The unique identifier of the sound track in the scene.
  103789. */
  103790. id: number;
  103791. /**
  103792. * The list of sounds included in the sound track.
  103793. */
  103794. soundCollection: Array<Sound>;
  103795. private _outputAudioNode;
  103796. private _scene;
  103797. private _isMainTrack;
  103798. private _connectedAnalyser;
  103799. private _options;
  103800. private _isInitialized;
  103801. /**
  103802. * Creates a new sound track.
  103803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103804. * @param scene Define the scene the sound track belongs to
  103805. * @param options
  103806. */
  103807. constructor(scene: Scene, options?: ISoundTrackOptions);
  103808. private _initializeSoundTrackAudioGraph;
  103809. /**
  103810. * Release the sound track and its associated resources
  103811. */
  103812. dispose(): void;
  103813. /**
  103814. * Adds a sound to this sound track
  103815. * @param sound define the cound to add
  103816. * @ignoreNaming
  103817. */
  103818. AddSound(sound: Sound): void;
  103819. /**
  103820. * Removes a sound to this sound track
  103821. * @param sound define the cound to remove
  103822. * @ignoreNaming
  103823. */
  103824. RemoveSound(sound: Sound): void;
  103825. /**
  103826. * Set a global volume for the full sound track.
  103827. * @param newVolume Define the new volume of the sound track
  103828. */
  103829. setVolume(newVolume: number): void;
  103830. /**
  103831. * Switch the panning model to HRTF:
  103832. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103834. */
  103835. switchPanningModelToHRTF(): void;
  103836. /**
  103837. * Switch the panning model to Equal Power:
  103838. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103840. */
  103841. switchPanningModelToEqualPower(): void;
  103842. /**
  103843. * Connect the sound track to an audio analyser allowing some amazing
  103844. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103846. * @param analyser The analyser to connect to the engine
  103847. */
  103848. connectToAnalyser(analyser: Analyser): void;
  103849. }
  103850. }
  103851. declare module BABYLON {
  103852. interface AbstractScene {
  103853. /**
  103854. * The list of sounds used in the scene.
  103855. */
  103856. sounds: Nullable<Array<Sound>>;
  103857. }
  103858. interface Scene {
  103859. /**
  103860. * @hidden
  103861. * Backing field
  103862. */
  103863. _mainSoundTrack: SoundTrack;
  103864. /**
  103865. * The main sound track played by the scene.
  103866. * It cotains your primary collection of sounds.
  103867. */
  103868. mainSoundTrack: SoundTrack;
  103869. /**
  103870. * The list of sound tracks added to the scene
  103871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103872. */
  103873. soundTracks: Nullable<Array<SoundTrack>>;
  103874. /**
  103875. * Gets a sound using a given name
  103876. * @param name defines the name to search for
  103877. * @return the found sound or null if not found at all.
  103878. */
  103879. getSoundByName(name: string): Nullable<Sound>;
  103880. /**
  103881. * Gets or sets if audio support is enabled
  103882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103883. */
  103884. audioEnabled: boolean;
  103885. /**
  103886. * Gets or sets if audio will be output to headphones
  103887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103888. */
  103889. headphone: boolean;
  103890. /**
  103891. * Gets or sets custom audio listener position provider
  103892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103893. */
  103894. audioListenerPositionProvider: Nullable<() => Vector3>;
  103895. /**
  103896. * Gets or sets a refresh rate when using 3D audio positioning
  103897. */
  103898. audioPositioningRefreshRate: number;
  103899. }
  103900. /**
  103901. * Defines the sound scene component responsible to manage any sounds
  103902. * in a given scene.
  103903. */
  103904. export class AudioSceneComponent implements ISceneSerializableComponent {
  103905. /**
  103906. * The component name helpfull to identify the component in the list of scene components.
  103907. */
  103908. readonly name: string;
  103909. /**
  103910. * The scene the component belongs to.
  103911. */
  103912. scene: Scene;
  103913. private _audioEnabled;
  103914. /**
  103915. * Gets whether audio is enabled or not.
  103916. * Please use related enable/disable method to switch state.
  103917. */
  103918. readonly audioEnabled: boolean;
  103919. private _headphone;
  103920. /**
  103921. * Gets whether audio is outputing to headphone or not.
  103922. * Please use the according Switch methods to change output.
  103923. */
  103924. readonly headphone: boolean;
  103925. /**
  103926. * Gets or sets a refresh rate when using 3D audio positioning
  103927. */
  103928. audioPositioningRefreshRate: number;
  103929. private _audioListenerPositionProvider;
  103930. /**
  103931. * Gets the current audio listener position provider
  103932. */
  103933. /**
  103934. * Sets a custom listener position for all sounds in the scene
  103935. * By default, this is the position of the first active camera
  103936. */
  103937. audioListenerPositionProvider: Nullable<() => Vector3>;
  103938. /**
  103939. * Creates a new instance of the component for the given scene
  103940. * @param scene Defines the scene to register the component in
  103941. */
  103942. constructor(scene: Scene);
  103943. /**
  103944. * Registers the component in a given scene
  103945. */
  103946. register(): void;
  103947. /**
  103948. * Rebuilds the elements related to this component in case of
  103949. * context lost for instance.
  103950. */
  103951. rebuild(): void;
  103952. /**
  103953. * Serializes the component data to the specified json object
  103954. * @param serializationObject The object to serialize to
  103955. */
  103956. serialize(serializationObject: any): void;
  103957. /**
  103958. * Adds all the elements from the container to the scene
  103959. * @param container the container holding the elements
  103960. */
  103961. addFromContainer(container: AbstractScene): void;
  103962. /**
  103963. * Removes all the elements in the container from the scene
  103964. * @param container contains the elements to remove
  103965. * @param dispose if the removed element should be disposed (default: false)
  103966. */
  103967. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103968. /**
  103969. * Disposes the component and the associated ressources.
  103970. */
  103971. dispose(): void;
  103972. /**
  103973. * Disables audio in the associated scene.
  103974. */
  103975. disableAudio(): void;
  103976. /**
  103977. * Enables audio in the associated scene.
  103978. */
  103979. enableAudio(): void;
  103980. /**
  103981. * Switch audio to headphone output.
  103982. */
  103983. switchAudioModeForHeadphones(): void;
  103984. /**
  103985. * Switch audio to normal speakers.
  103986. */
  103987. switchAudioModeForNormalSpeakers(): void;
  103988. private _cachedCameraDirection;
  103989. private _cachedCameraPosition;
  103990. private _lastCheck;
  103991. private _afterRender;
  103992. }
  103993. }
  103994. declare module BABYLON {
  103995. /**
  103996. * Wraps one or more Sound objects and selects one with random weight for playback.
  103997. */
  103998. export class WeightedSound {
  103999. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104000. loop: boolean;
  104001. private _coneInnerAngle;
  104002. private _coneOuterAngle;
  104003. private _volume;
  104004. /** A Sound is currently playing. */
  104005. isPlaying: boolean;
  104006. /** A Sound is currently paused. */
  104007. isPaused: boolean;
  104008. private _sounds;
  104009. private _weights;
  104010. private _currentIndex?;
  104011. /**
  104012. * Creates a new WeightedSound from the list of sounds given.
  104013. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104014. * @param sounds Array of Sounds that will be selected from.
  104015. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104016. */
  104017. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104018. /**
  104019. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104020. */
  104021. /**
  104022. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104023. */
  104024. directionalConeInnerAngle: number;
  104025. /**
  104026. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104027. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104028. */
  104029. /**
  104030. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104031. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104032. */
  104033. directionalConeOuterAngle: number;
  104034. /**
  104035. * Playback volume.
  104036. */
  104037. /**
  104038. * Playback volume.
  104039. */
  104040. volume: number;
  104041. private _onended;
  104042. /**
  104043. * Suspend playback
  104044. */
  104045. pause(): void;
  104046. /**
  104047. * Stop playback
  104048. */
  104049. stop(): void;
  104050. /**
  104051. * Start playback.
  104052. * @param startOffset Position the clip head at a specific time in seconds.
  104053. */
  104054. play(startOffset?: number): void;
  104055. }
  104056. }
  104057. declare module BABYLON {
  104058. /**
  104059. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104061. */
  104062. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104063. /**
  104064. * Gets the name of the behavior.
  104065. */
  104066. readonly name: string;
  104067. /**
  104068. * The easing function used by animations
  104069. */
  104070. static EasingFunction: BackEase;
  104071. /**
  104072. * The easing mode used by animations
  104073. */
  104074. static EasingMode: number;
  104075. /**
  104076. * The duration of the animation, in milliseconds
  104077. */
  104078. transitionDuration: number;
  104079. /**
  104080. * Length of the distance animated by the transition when lower radius is reached
  104081. */
  104082. lowerRadiusTransitionRange: number;
  104083. /**
  104084. * Length of the distance animated by the transition when upper radius is reached
  104085. */
  104086. upperRadiusTransitionRange: number;
  104087. private _autoTransitionRange;
  104088. /**
  104089. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104090. */
  104091. /**
  104092. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104093. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104094. */
  104095. autoTransitionRange: boolean;
  104096. private _attachedCamera;
  104097. private _onAfterCheckInputsObserver;
  104098. private _onMeshTargetChangedObserver;
  104099. /**
  104100. * Initializes the behavior.
  104101. */
  104102. init(): void;
  104103. /**
  104104. * Attaches the behavior to its arc rotate camera.
  104105. * @param camera Defines the camera to attach the behavior to
  104106. */
  104107. attach(camera: ArcRotateCamera): void;
  104108. /**
  104109. * Detaches the behavior from its current arc rotate camera.
  104110. */
  104111. detach(): void;
  104112. private _radiusIsAnimating;
  104113. private _radiusBounceTransition;
  104114. private _animatables;
  104115. private _cachedWheelPrecision;
  104116. /**
  104117. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104118. * @param radiusLimit The limit to check against.
  104119. * @return Bool to indicate if at limit.
  104120. */
  104121. private _isRadiusAtLimit;
  104122. /**
  104123. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104124. * @param radiusDelta The delta by which to animate to. Can be negative.
  104125. */
  104126. private _applyBoundRadiusAnimation;
  104127. /**
  104128. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104129. */
  104130. protected _clearAnimationLocks(): void;
  104131. /**
  104132. * Stops and removes all animations that have been applied to the camera
  104133. */
  104134. stopAllAnimations(): void;
  104135. }
  104136. }
  104137. declare module BABYLON {
  104138. /**
  104139. * 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.
  104140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104141. */
  104142. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104143. /**
  104144. * Gets the name of the behavior.
  104145. */
  104146. readonly name: string;
  104147. private _mode;
  104148. private _radiusScale;
  104149. private _positionScale;
  104150. private _defaultElevation;
  104151. private _elevationReturnTime;
  104152. private _elevationReturnWaitTime;
  104153. private _zoomStopsAnimation;
  104154. private _framingTime;
  104155. /**
  104156. * The easing function used by animations
  104157. */
  104158. static EasingFunction: ExponentialEase;
  104159. /**
  104160. * The easing mode used by animations
  104161. */
  104162. static EasingMode: number;
  104163. /**
  104164. * Sets the current mode used by the behavior
  104165. */
  104166. /**
  104167. * Gets current mode used by the behavior.
  104168. */
  104169. mode: number;
  104170. /**
  104171. * Sets the scale applied to the radius (1 by default)
  104172. */
  104173. /**
  104174. * Gets the scale applied to the radius
  104175. */
  104176. radiusScale: number;
  104177. /**
  104178. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104179. */
  104180. /**
  104181. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104182. */
  104183. positionScale: number;
  104184. /**
  104185. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104186. * behaviour is triggered, in radians.
  104187. */
  104188. /**
  104189. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104190. * behaviour is triggered, in radians.
  104191. */
  104192. defaultElevation: number;
  104193. /**
  104194. * Sets the time (in milliseconds) taken to return to the default beta position.
  104195. * Negative value indicates camera should not return to default.
  104196. */
  104197. /**
  104198. * Gets the time (in milliseconds) taken to return to the default beta position.
  104199. * Negative value indicates camera should not return to default.
  104200. */
  104201. elevationReturnTime: number;
  104202. /**
  104203. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104204. */
  104205. /**
  104206. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104207. */
  104208. elevationReturnWaitTime: number;
  104209. /**
  104210. * Sets the flag that indicates if user zooming should stop animation.
  104211. */
  104212. /**
  104213. * Gets the flag that indicates if user zooming should stop animation.
  104214. */
  104215. zoomStopsAnimation: boolean;
  104216. /**
  104217. * Sets the transition time when framing the mesh, in milliseconds
  104218. */
  104219. /**
  104220. * Gets the transition time when framing the mesh, in milliseconds
  104221. */
  104222. framingTime: number;
  104223. /**
  104224. * Define if the behavior should automatically change the configured
  104225. * camera limits and sensibilities.
  104226. */
  104227. autoCorrectCameraLimitsAndSensibility: boolean;
  104228. private _onPrePointerObservableObserver;
  104229. private _onAfterCheckInputsObserver;
  104230. private _onMeshTargetChangedObserver;
  104231. private _attachedCamera;
  104232. private _isPointerDown;
  104233. private _lastInteractionTime;
  104234. /**
  104235. * Initializes the behavior.
  104236. */
  104237. init(): void;
  104238. /**
  104239. * Attaches the behavior to its arc rotate camera.
  104240. * @param camera Defines the camera to attach the behavior to
  104241. */
  104242. attach(camera: ArcRotateCamera): void;
  104243. /**
  104244. * Detaches the behavior from its current arc rotate camera.
  104245. */
  104246. detach(): void;
  104247. private _animatables;
  104248. private _betaIsAnimating;
  104249. private _betaTransition;
  104250. private _radiusTransition;
  104251. private _vectorTransition;
  104252. /**
  104253. * Targets the given mesh and updates zoom level accordingly.
  104254. * @param mesh The mesh to target.
  104255. * @param radius Optional. If a cached radius position already exists, overrides default.
  104256. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104257. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104258. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104259. */
  104260. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104261. /**
  104262. * Targets the given mesh with its children and updates zoom level accordingly.
  104263. * @param mesh The mesh to target.
  104264. * @param radius Optional. If a cached radius position already exists, overrides default.
  104265. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104266. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104267. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104268. */
  104269. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104270. /**
  104271. * Targets the given meshes with their children and updates zoom level accordingly.
  104272. * @param meshes The mesh to target.
  104273. * @param radius Optional. If a cached radius position already exists, overrides default.
  104274. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104275. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104276. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104277. */
  104278. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104279. /**
  104280. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104281. * @param minimumWorld Determines the smaller position of the bounding box extend
  104282. * @param maximumWorld Determines the bigger position of the bounding box extend
  104283. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104284. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104285. */
  104286. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104287. /**
  104288. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104289. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104290. * frustum width.
  104291. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104292. * to fully enclose the mesh in the viewing frustum.
  104293. */
  104294. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104295. /**
  104296. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104297. * is automatically returned to its default position (expected to be above ground plane).
  104298. */
  104299. private _maintainCameraAboveGround;
  104300. /**
  104301. * Returns the frustum slope based on the canvas ratio and camera FOV
  104302. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104303. */
  104304. private _getFrustumSlope;
  104305. /**
  104306. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104307. */
  104308. private _clearAnimationLocks;
  104309. /**
  104310. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104311. */
  104312. private _applyUserInteraction;
  104313. /**
  104314. * Stops and removes all animations that have been applied to the camera
  104315. */
  104316. stopAllAnimations(): void;
  104317. /**
  104318. * Gets a value indicating if the user is moving the camera
  104319. */
  104320. readonly isUserIsMoving: boolean;
  104321. /**
  104322. * The camera can move all the way towards the mesh.
  104323. */
  104324. static IgnoreBoundsSizeMode: number;
  104325. /**
  104326. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104327. */
  104328. static FitFrustumSidesMode: number;
  104329. }
  104330. }
  104331. declare module BABYLON {
  104332. /**
  104333. * Base class for Camera Pointer Inputs.
  104334. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104335. * for example usage.
  104336. */
  104337. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104338. /**
  104339. * Defines the camera the input is attached to.
  104340. */
  104341. abstract camera: Camera;
  104342. /**
  104343. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104344. */
  104345. protected _altKey: boolean;
  104346. protected _ctrlKey: boolean;
  104347. protected _metaKey: boolean;
  104348. protected _shiftKey: boolean;
  104349. /**
  104350. * Which mouse buttons were pressed at time of last mouse event.
  104351. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104352. */
  104353. protected _buttonsPressed: number;
  104354. /**
  104355. * Defines the buttons associated with the input to handle camera move.
  104356. */
  104357. buttons: number[];
  104358. /**
  104359. * Attach the input controls to a specific dom element to get the input from.
  104360. * @param element Defines the element the controls should be listened from
  104361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104362. */
  104363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104364. /**
  104365. * Detach the current controls from the specified dom element.
  104366. * @param element Defines the element to stop listening the inputs from
  104367. */
  104368. detachControl(element: Nullable<HTMLElement>): void;
  104369. /**
  104370. * Gets the class name of the current input.
  104371. * @returns the class name
  104372. */
  104373. getClassName(): string;
  104374. /**
  104375. * Get the friendly name associated with the input class.
  104376. * @returns the input friendly name
  104377. */
  104378. getSimpleName(): string;
  104379. /**
  104380. * Called on pointer POINTERDOUBLETAP event.
  104381. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104382. */
  104383. protected onDoubleTap(type: string): void;
  104384. /**
  104385. * Called on pointer POINTERMOVE event if only a single touch is active.
  104386. * Override this method to provide functionality.
  104387. */
  104388. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104389. /**
  104390. * Called on pointer POINTERMOVE event if multiple touches are active.
  104391. * Override this method to provide functionality.
  104392. */
  104393. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104394. /**
  104395. * Called on JS contextmenu event.
  104396. * Override this method to provide functionality.
  104397. */
  104398. protected onContextMenu(evt: PointerEvent): void;
  104399. /**
  104400. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104401. * press.
  104402. * Override this method to provide functionality.
  104403. */
  104404. protected onButtonDown(evt: PointerEvent): void;
  104405. /**
  104406. * Called each time a new POINTERUP event occurs. Ie, for each button
  104407. * release.
  104408. * Override this method to provide functionality.
  104409. */
  104410. protected onButtonUp(evt: PointerEvent): void;
  104411. /**
  104412. * Called when window becomes inactive.
  104413. * Override this method to provide functionality.
  104414. */
  104415. protected onLostFocus(): void;
  104416. private _pointerInput;
  104417. private _observer;
  104418. private _onLostFocus;
  104419. private pointA;
  104420. private pointB;
  104421. }
  104422. }
  104423. declare module BABYLON {
  104424. /**
  104425. * Manage the pointers inputs to control an arc rotate camera.
  104426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104427. */
  104428. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104429. /**
  104430. * Defines the camera the input is attached to.
  104431. */
  104432. camera: ArcRotateCamera;
  104433. /**
  104434. * Gets the class name of the current input.
  104435. * @returns the class name
  104436. */
  104437. getClassName(): string;
  104438. /**
  104439. * Defines the buttons associated with the input to handle camera move.
  104440. */
  104441. buttons: number[];
  104442. /**
  104443. * Defines the pointer angular sensibility along the X axis or how fast is
  104444. * the camera rotating.
  104445. */
  104446. angularSensibilityX: number;
  104447. /**
  104448. * Defines the pointer angular sensibility along the Y axis or how fast is
  104449. * the camera rotating.
  104450. */
  104451. angularSensibilityY: number;
  104452. /**
  104453. * Defines the pointer pinch precision or how fast is the camera zooming.
  104454. */
  104455. pinchPrecision: number;
  104456. /**
  104457. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104458. * from 0.
  104459. * It defines the percentage of current camera.radius to use as delta when
  104460. * pinch zoom is used.
  104461. */
  104462. pinchDeltaPercentage: number;
  104463. /**
  104464. * Defines the pointer panning sensibility or how fast is the camera moving.
  104465. */
  104466. panningSensibility: number;
  104467. /**
  104468. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104469. */
  104470. multiTouchPanning: boolean;
  104471. /**
  104472. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104473. * zoom (pinch) through multitouch.
  104474. */
  104475. multiTouchPanAndZoom: boolean;
  104476. /**
  104477. * Revers pinch action direction.
  104478. */
  104479. pinchInwards: boolean;
  104480. private _isPanClick;
  104481. private _twoFingerActivityCount;
  104482. private _isPinching;
  104483. /**
  104484. * Called on pointer POINTERMOVE event if only a single touch is active.
  104485. */
  104486. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104487. /**
  104488. * Called on pointer POINTERDOUBLETAP event.
  104489. */
  104490. protected onDoubleTap(type: string): void;
  104491. /**
  104492. * Called on pointer POINTERMOVE event if multiple touches are active.
  104493. */
  104494. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104495. /**
  104496. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104497. * press.
  104498. */
  104499. protected onButtonDown(evt: PointerEvent): void;
  104500. /**
  104501. * Called each time a new POINTERUP event occurs. Ie, for each button
  104502. * release.
  104503. */
  104504. protected onButtonUp(evt: PointerEvent): void;
  104505. /**
  104506. * Called when window becomes inactive.
  104507. */
  104508. protected onLostFocus(): void;
  104509. }
  104510. }
  104511. declare module BABYLON {
  104512. /**
  104513. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104515. */
  104516. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104517. /**
  104518. * Defines the camera the input is attached to.
  104519. */
  104520. camera: ArcRotateCamera;
  104521. /**
  104522. * Defines the list of key codes associated with the up action (increase alpha)
  104523. */
  104524. keysUp: number[];
  104525. /**
  104526. * Defines the list of key codes associated with the down action (decrease alpha)
  104527. */
  104528. keysDown: number[];
  104529. /**
  104530. * Defines the list of key codes associated with the left action (increase beta)
  104531. */
  104532. keysLeft: number[];
  104533. /**
  104534. * Defines the list of key codes associated with the right action (decrease beta)
  104535. */
  104536. keysRight: number[];
  104537. /**
  104538. * Defines the list of key codes associated with the reset action.
  104539. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104540. */
  104541. keysReset: number[];
  104542. /**
  104543. * Defines the panning sensibility of the inputs.
  104544. * (How fast is the camera paning)
  104545. */
  104546. panningSensibility: number;
  104547. /**
  104548. * Defines the zooming sensibility of the inputs.
  104549. * (How fast is the camera zooming)
  104550. */
  104551. zoomingSensibility: number;
  104552. /**
  104553. * Defines wether maintaining the alt key down switch the movement mode from
  104554. * orientation to zoom.
  104555. */
  104556. useAltToZoom: boolean;
  104557. /**
  104558. * Rotation speed of the camera
  104559. */
  104560. angularSpeed: number;
  104561. private _keys;
  104562. private _ctrlPressed;
  104563. private _altPressed;
  104564. private _onCanvasBlurObserver;
  104565. private _onKeyboardObserver;
  104566. private _engine;
  104567. private _scene;
  104568. /**
  104569. * Attach the input controls to a specific dom element to get the input from.
  104570. * @param element Defines the element the controls should be listened from
  104571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104572. */
  104573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104574. /**
  104575. * Detach the current controls from the specified dom element.
  104576. * @param element Defines the element to stop listening the inputs from
  104577. */
  104578. detachControl(element: Nullable<HTMLElement>): void;
  104579. /**
  104580. * Update the current camera state depending on the inputs that have been used this frame.
  104581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104582. */
  104583. checkInputs(): void;
  104584. /**
  104585. * Gets the class name of the current intput.
  104586. * @returns the class name
  104587. */
  104588. getClassName(): string;
  104589. /**
  104590. * Get the friendly name associated with the input class.
  104591. * @returns the input friendly name
  104592. */
  104593. getSimpleName(): string;
  104594. }
  104595. }
  104596. declare module BABYLON {
  104597. /**
  104598. * Manage the mouse wheel inputs to control an arc rotate camera.
  104599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104600. */
  104601. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104602. /**
  104603. * Defines the camera the input is attached to.
  104604. */
  104605. camera: ArcRotateCamera;
  104606. /**
  104607. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104608. */
  104609. wheelPrecision: number;
  104610. /**
  104611. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104612. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104613. */
  104614. wheelDeltaPercentage: number;
  104615. private _wheel;
  104616. private _observer;
  104617. private computeDeltaFromMouseWheelLegacyEvent;
  104618. /**
  104619. * Attach the input controls to a specific dom element to get the input from.
  104620. * @param element Defines the element the controls should be listened from
  104621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104622. */
  104623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104624. /**
  104625. * Detach the current controls from the specified dom element.
  104626. * @param element Defines the element to stop listening the inputs from
  104627. */
  104628. detachControl(element: Nullable<HTMLElement>): void;
  104629. /**
  104630. * Gets the class name of the current intput.
  104631. * @returns the class name
  104632. */
  104633. getClassName(): string;
  104634. /**
  104635. * Get the friendly name associated with the input class.
  104636. * @returns the input friendly name
  104637. */
  104638. getSimpleName(): string;
  104639. }
  104640. }
  104641. declare module BABYLON {
  104642. /**
  104643. * Default Inputs manager for the ArcRotateCamera.
  104644. * It groups all the default supported inputs for ease of use.
  104645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104646. */
  104647. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104648. /**
  104649. * Instantiates a new ArcRotateCameraInputsManager.
  104650. * @param camera Defines the camera the inputs belong to
  104651. */
  104652. constructor(camera: ArcRotateCamera);
  104653. /**
  104654. * Add mouse wheel input support to the input manager.
  104655. * @returns the current input manager
  104656. */
  104657. addMouseWheel(): ArcRotateCameraInputsManager;
  104658. /**
  104659. * Add pointers input support to the input manager.
  104660. * @returns the current input manager
  104661. */
  104662. addPointers(): ArcRotateCameraInputsManager;
  104663. /**
  104664. * Add keyboard input support to the input manager.
  104665. * @returns the current input manager
  104666. */
  104667. addKeyboard(): ArcRotateCameraInputsManager;
  104668. }
  104669. }
  104670. declare module BABYLON {
  104671. /**
  104672. * This represents an orbital type of camera.
  104673. *
  104674. * 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.
  104675. * 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.
  104676. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104677. */
  104678. export class ArcRotateCamera extends TargetCamera {
  104679. /**
  104680. * Defines the rotation angle of the camera along the longitudinal axis.
  104681. */
  104682. alpha: number;
  104683. /**
  104684. * Defines the rotation angle of the camera along the latitudinal axis.
  104685. */
  104686. beta: number;
  104687. /**
  104688. * Defines the radius of the camera from it s target point.
  104689. */
  104690. radius: number;
  104691. protected _target: Vector3;
  104692. protected _targetHost: Nullable<AbstractMesh>;
  104693. /**
  104694. * Defines the target point of the camera.
  104695. * The camera looks towards it form the radius distance.
  104696. */
  104697. target: Vector3;
  104698. /**
  104699. * Define the current local position of the camera in the scene
  104700. */
  104701. position: Vector3;
  104702. protected _upVector: Vector3;
  104703. protected _upToYMatrix: Matrix;
  104704. protected _YToUpMatrix: Matrix;
  104705. /**
  104706. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104707. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104708. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104709. */
  104710. upVector: Vector3;
  104711. /**
  104712. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104713. */
  104714. setMatUp(): void;
  104715. /**
  104716. * Current inertia value on the longitudinal axis.
  104717. * The bigger this number the longer it will take for the camera to stop.
  104718. */
  104719. inertialAlphaOffset: number;
  104720. /**
  104721. * Current inertia value on the latitudinal axis.
  104722. * The bigger this number the longer it will take for the camera to stop.
  104723. */
  104724. inertialBetaOffset: number;
  104725. /**
  104726. * Current inertia value on the radius axis.
  104727. * The bigger this number the longer it will take for the camera to stop.
  104728. */
  104729. inertialRadiusOffset: number;
  104730. /**
  104731. * Minimum allowed angle on the longitudinal axis.
  104732. * This can help limiting how the Camera is able to move in the scene.
  104733. */
  104734. lowerAlphaLimit: Nullable<number>;
  104735. /**
  104736. * Maximum allowed angle on the longitudinal axis.
  104737. * This can help limiting how the Camera is able to move in the scene.
  104738. */
  104739. upperAlphaLimit: Nullable<number>;
  104740. /**
  104741. * Minimum allowed angle on the latitudinal axis.
  104742. * This can help limiting how the Camera is able to move in the scene.
  104743. */
  104744. lowerBetaLimit: number;
  104745. /**
  104746. * Maximum allowed angle on the latitudinal axis.
  104747. * This can help limiting how the Camera is able to move in the scene.
  104748. */
  104749. upperBetaLimit: number;
  104750. /**
  104751. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104752. * This can help limiting how the Camera is able to move in the scene.
  104753. */
  104754. lowerRadiusLimit: Nullable<number>;
  104755. /**
  104756. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104757. * This can help limiting how the Camera is able to move in the scene.
  104758. */
  104759. upperRadiusLimit: Nullable<number>;
  104760. /**
  104761. * Defines the current inertia value used during panning of the camera along the X axis.
  104762. */
  104763. inertialPanningX: number;
  104764. /**
  104765. * Defines the current inertia value used during panning of the camera along the Y axis.
  104766. */
  104767. inertialPanningY: number;
  104768. /**
  104769. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104770. * Basically if your fingers moves away from more than this distance you will be considered
  104771. * in pinch mode.
  104772. */
  104773. pinchToPanMaxDistance: number;
  104774. /**
  104775. * Defines the maximum distance the camera can pan.
  104776. * This could help keeping the cammera always in your scene.
  104777. */
  104778. panningDistanceLimit: Nullable<number>;
  104779. /**
  104780. * Defines the target of the camera before paning.
  104781. */
  104782. panningOriginTarget: Vector3;
  104783. /**
  104784. * Defines the value of the inertia used during panning.
  104785. * 0 would mean stop inertia and one would mean no decelleration at all.
  104786. */
  104787. panningInertia: number;
  104788. /**
  104789. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104790. */
  104791. angularSensibilityX: number;
  104792. /**
  104793. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104794. */
  104795. angularSensibilityY: number;
  104796. /**
  104797. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104798. */
  104799. pinchPrecision: number;
  104800. /**
  104801. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104802. * It will be used instead of pinchDeltaPrecision if different from 0.
  104803. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104804. */
  104805. pinchDeltaPercentage: number;
  104806. /**
  104807. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104808. */
  104809. panningSensibility: number;
  104810. /**
  104811. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104812. */
  104813. keysUp: number[];
  104814. /**
  104815. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104816. */
  104817. keysDown: number[];
  104818. /**
  104819. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104820. */
  104821. keysLeft: number[];
  104822. /**
  104823. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104824. */
  104825. keysRight: number[];
  104826. /**
  104827. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104828. */
  104829. wheelPrecision: number;
  104830. /**
  104831. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104832. * It will be used instead of pinchDeltaPrecision if different from 0.
  104833. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104834. */
  104835. wheelDeltaPercentage: number;
  104836. /**
  104837. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104838. */
  104839. zoomOnFactor: number;
  104840. /**
  104841. * Defines a screen offset for the camera position.
  104842. */
  104843. targetScreenOffset: Vector2;
  104844. /**
  104845. * Allows the camera to be completely reversed.
  104846. * If false the camera can not arrive upside down.
  104847. */
  104848. allowUpsideDown: boolean;
  104849. /**
  104850. * Define if double tap/click is used to restore the previously saved state of the camera.
  104851. */
  104852. useInputToRestoreState: boolean;
  104853. /** @hidden */
  104854. _viewMatrix: Matrix;
  104855. /** @hidden */
  104856. _useCtrlForPanning: boolean;
  104857. /** @hidden */
  104858. _panningMouseButton: number;
  104859. /**
  104860. * Defines the input associated to the camera.
  104861. */
  104862. inputs: ArcRotateCameraInputsManager;
  104863. /** @hidden */
  104864. _reset: () => void;
  104865. /**
  104866. * Defines the allowed panning axis.
  104867. */
  104868. panningAxis: Vector3;
  104869. protected _localDirection: Vector3;
  104870. protected _transformedDirection: Vector3;
  104871. private _bouncingBehavior;
  104872. /**
  104873. * Gets the bouncing behavior of the camera if it has been enabled.
  104874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104875. */
  104876. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104877. /**
  104878. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104879. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104880. */
  104881. useBouncingBehavior: boolean;
  104882. private _framingBehavior;
  104883. /**
  104884. * Gets the framing behavior of the camera if it has been enabled.
  104885. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104886. */
  104887. readonly framingBehavior: Nullable<FramingBehavior>;
  104888. /**
  104889. * Defines if the framing behavior of the camera is enabled on the camera.
  104890. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104891. */
  104892. useFramingBehavior: boolean;
  104893. private _autoRotationBehavior;
  104894. /**
  104895. * Gets the auto rotation behavior of the camera if it has been enabled.
  104896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104897. */
  104898. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104899. /**
  104900. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104901. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104902. */
  104903. useAutoRotationBehavior: boolean;
  104904. /**
  104905. * Observable triggered when the mesh target has been changed on the camera.
  104906. */
  104907. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104908. /**
  104909. * Event raised when the camera is colliding with a mesh.
  104910. */
  104911. onCollide: (collidedMesh: AbstractMesh) => void;
  104912. /**
  104913. * Defines whether the camera should check collision with the objects oh the scene.
  104914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104915. */
  104916. checkCollisions: boolean;
  104917. /**
  104918. * Defines the collision radius of the camera.
  104919. * This simulates a sphere around the camera.
  104920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104921. */
  104922. collisionRadius: Vector3;
  104923. protected _collider: Collider;
  104924. protected _previousPosition: Vector3;
  104925. protected _collisionVelocity: Vector3;
  104926. protected _newPosition: Vector3;
  104927. protected _previousAlpha: number;
  104928. protected _previousBeta: number;
  104929. protected _previousRadius: number;
  104930. protected _collisionTriggered: boolean;
  104931. protected _targetBoundingCenter: Nullable<Vector3>;
  104932. private _computationVector;
  104933. /**
  104934. * Instantiates a new ArcRotateCamera in a given scene
  104935. * @param name Defines the name of the camera
  104936. * @param alpha Defines the camera rotation along the logitudinal axis
  104937. * @param beta Defines the camera rotation along the latitudinal axis
  104938. * @param radius Defines the camera distance from its target
  104939. * @param target Defines the camera target
  104940. * @param scene Defines the scene the camera belongs to
  104941. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104942. */
  104943. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104944. /** @hidden */
  104945. _initCache(): void;
  104946. /** @hidden */
  104947. _updateCache(ignoreParentClass?: boolean): void;
  104948. protected _getTargetPosition(): Vector3;
  104949. private _storedAlpha;
  104950. private _storedBeta;
  104951. private _storedRadius;
  104952. private _storedTarget;
  104953. private _storedTargetScreenOffset;
  104954. /**
  104955. * Stores the current state of the camera (alpha, beta, radius and target)
  104956. * @returns the camera itself
  104957. */
  104958. storeState(): Camera;
  104959. /**
  104960. * @hidden
  104961. * Restored camera state. You must call storeState() first
  104962. */
  104963. _restoreStateValues(): boolean;
  104964. /** @hidden */
  104965. _isSynchronizedViewMatrix(): boolean;
  104966. /**
  104967. * Attached controls to the current camera.
  104968. * @param element Defines the element the controls should be listened from
  104969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104970. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104971. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104972. */
  104973. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104974. /**
  104975. * Detach the current controls from the camera.
  104976. * The camera will stop reacting to inputs.
  104977. * @param element Defines the element to stop listening the inputs from
  104978. */
  104979. detachControl(element: HTMLElement): void;
  104980. /** @hidden */
  104981. _checkInputs(): void;
  104982. protected _checkLimits(): void;
  104983. /**
  104984. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104985. */
  104986. rebuildAnglesAndRadius(): void;
  104987. /**
  104988. * Use a position to define the current camera related information like alpha, beta and radius
  104989. * @param position Defines the position to set the camera at
  104990. */
  104991. setPosition(position: Vector3): void;
  104992. /**
  104993. * Defines the target the camera should look at.
  104994. * This will automatically adapt alpha beta and radius to fit within the new target.
  104995. * @param target Defines the new target as a Vector or a mesh
  104996. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104997. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104998. */
  104999. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105000. /** @hidden */
  105001. _getViewMatrix(): Matrix;
  105002. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105003. /**
  105004. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105005. * @param meshes Defines the mesh to zoom on
  105006. * @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)
  105007. */
  105008. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105009. /**
  105010. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105011. * The target will be changed but the radius
  105012. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105013. * @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)
  105014. */
  105015. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105016. min: Vector3;
  105017. max: Vector3;
  105018. distance: number;
  105019. }, doNotUpdateMaxZ?: boolean): void;
  105020. /**
  105021. * @override
  105022. * Override Camera.createRigCamera
  105023. */
  105024. createRigCamera(name: string, cameraIndex: number): Camera;
  105025. /**
  105026. * @hidden
  105027. * @override
  105028. * Override Camera._updateRigCameras
  105029. */
  105030. _updateRigCameras(): void;
  105031. /**
  105032. * Destroy the camera and release the current resources hold by it.
  105033. */
  105034. dispose(): void;
  105035. /**
  105036. * Gets the current object class name.
  105037. * @return the class name
  105038. */
  105039. getClassName(): string;
  105040. }
  105041. }
  105042. declare module BABYLON {
  105043. /**
  105044. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105045. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105046. */
  105047. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105048. /**
  105049. * Gets the name of the behavior.
  105050. */
  105051. readonly name: string;
  105052. private _zoomStopsAnimation;
  105053. private _idleRotationSpeed;
  105054. private _idleRotationWaitTime;
  105055. private _idleRotationSpinupTime;
  105056. /**
  105057. * Sets the flag that indicates if user zooming should stop animation.
  105058. */
  105059. /**
  105060. * Gets the flag that indicates if user zooming should stop animation.
  105061. */
  105062. zoomStopsAnimation: boolean;
  105063. /**
  105064. * Sets the default speed at which the camera rotates around the model.
  105065. */
  105066. /**
  105067. * Gets the default speed at which the camera rotates around the model.
  105068. */
  105069. idleRotationSpeed: number;
  105070. /**
  105071. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105072. */
  105073. /**
  105074. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105075. */
  105076. idleRotationWaitTime: number;
  105077. /**
  105078. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105079. */
  105080. /**
  105081. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105082. */
  105083. idleRotationSpinupTime: number;
  105084. /**
  105085. * Gets a value indicating if the camera is currently rotating because of this behavior
  105086. */
  105087. readonly rotationInProgress: boolean;
  105088. private _onPrePointerObservableObserver;
  105089. private _onAfterCheckInputsObserver;
  105090. private _attachedCamera;
  105091. private _isPointerDown;
  105092. private _lastFrameTime;
  105093. private _lastInteractionTime;
  105094. private _cameraRotationSpeed;
  105095. /**
  105096. * Initializes the behavior.
  105097. */
  105098. init(): void;
  105099. /**
  105100. * Attaches the behavior to its arc rotate camera.
  105101. * @param camera Defines the camera to attach the behavior to
  105102. */
  105103. attach(camera: ArcRotateCamera): void;
  105104. /**
  105105. * Detaches the behavior from its current arc rotate camera.
  105106. */
  105107. detach(): void;
  105108. /**
  105109. * Returns true if user is scrolling.
  105110. * @return true if user is scrolling.
  105111. */
  105112. private _userIsZooming;
  105113. private _lastFrameRadius;
  105114. private _shouldAnimationStopForInteraction;
  105115. /**
  105116. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105117. */
  105118. private _applyUserInteraction;
  105119. private _userIsMoving;
  105120. }
  105121. }
  105122. declare module BABYLON {
  105123. /**
  105124. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105125. */
  105126. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105127. private ui;
  105128. /**
  105129. * The name of the behavior
  105130. */
  105131. name: string;
  105132. /**
  105133. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105134. */
  105135. distanceAwayFromFace: number;
  105136. /**
  105137. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105138. */
  105139. distanceAwayFromBottomOfFace: number;
  105140. private _faceVectors;
  105141. private _target;
  105142. private _scene;
  105143. private _onRenderObserver;
  105144. private _tmpMatrix;
  105145. private _tmpVector;
  105146. /**
  105147. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105148. * @param ui The transform node that should be attched to the mesh
  105149. */
  105150. constructor(ui: TransformNode);
  105151. /**
  105152. * Initializes the behavior
  105153. */
  105154. init(): void;
  105155. private _closestFace;
  105156. private _zeroVector;
  105157. private _lookAtTmpMatrix;
  105158. private _lookAtToRef;
  105159. /**
  105160. * Attaches the AttachToBoxBehavior to the passed in mesh
  105161. * @param target The mesh that the specified node will be attached to
  105162. */
  105163. attach(target: Mesh): void;
  105164. /**
  105165. * Detaches the behavior from the mesh
  105166. */
  105167. detach(): void;
  105168. }
  105169. }
  105170. declare module BABYLON {
  105171. /**
  105172. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105173. */
  105174. export class FadeInOutBehavior implements Behavior<Mesh> {
  105175. /**
  105176. * Time in milliseconds to delay before fading in (Default: 0)
  105177. */
  105178. delay: number;
  105179. /**
  105180. * Time in milliseconds for the mesh to fade in (Default: 300)
  105181. */
  105182. fadeInTime: number;
  105183. private _millisecondsPerFrame;
  105184. private _hovered;
  105185. private _hoverValue;
  105186. private _ownerNode;
  105187. /**
  105188. * Instatiates the FadeInOutBehavior
  105189. */
  105190. constructor();
  105191. /**
  105192. * The name of the behavior
  105193. */
  105194. readonly name: string;
  105195. /**
  105196. * Initializes the behavior
  105197. */
  105198. init(): void;
  105199. /**
  105200. * Attaches the fade behavior on the passed in mesh
  105201. * @param ownerNode The mesh that will be faded in/out once attached
  105202. */
  105203. attach(ownerNode: Mesh): void;
  105204. /**
  105205. * Detaches the behavior from the mesh
  105206. */
  105207. detach(): void;
  105208. /**
  105209. * Triggers the mesh to begin fading in or out
  105210. * @param value if the object should fade in or out (true to fade in)
  105211. */
  105212. fadeIn(value: boolean): void;
  105213. private _update;
  105214. private _setAllVisibility;
  105215. }
  105216. }
  105217. declare module BABYLON {
  105218. /**
  105219. * Class containing a set of static utilities functions for managing Pivots
  105220. * @hidden
  105221. */
  105222. export class PivotTools {
  105223. private static _PivotCached;
  105224. private static _OldPivotPoint;
  105225. private static _PivotTranslation;
  105226. private static _PivotTmpVector;
  105227. /** @hidden */
  105228. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105229. /** @hidden */
  105230. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105231. }
  105232. }
  105233. declare module BABYLON {
  105234. /**
  105235. * Class containing static functions to help procedurally build meshes
  105236. */
  105237. export class PlaneBuilder {
  105238. /**
  105239. * Creates a plane mesh
  105240. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105241. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105242. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105246. * @param name defines the name of the mesh
  105247. * @param options defines the options used to create the mesh
  105248. * @param scene defines the hosting scene
  105249. * @returns the plane mesh
  105250. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105251. */
  105252. static CreatePlane(name: string, options: {
  105253. size?: number;
  105254. width?: number;
  105255. height?: number;
  105256. sideOrientation?: number;
  105257. frontUVs?: Vector4;
  105258. backUVs?: Vector4;
  105259. updatable?: boolean;
  105260. sourcePlane?: Plane;
  105261. }, scene?: Nullable<Scene>): Mesh;
  105262. }
  105263. }
  105264. declare module BABYLON {
  105265. /**
  105266. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105267. */
  105268. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105269. private static _AnyMouseID;
  105270. /**
  105271. * Abstract mesh the behavior is set on
  105272. */
  105273. attachedNode: AbstractMesh;
  105274. private _dragPlane;
  105275. private _scene;
  105276. private _pointerObserver;
  105277. private _beforeRenderObserver;
  105278. private static _planeScene;
  105279. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105280. /**
  105281. * 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)
  105282. */
  105283. maxDragAngle: number;
  105284. /**
  105285. * @hidden
  105286. */
  105287. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105288. /**
  105289. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105290. */
  105291. currentDraggingPointerID: number;
  105292. /**
  105293. * The last position where the pointer hit the drag plane in world space
  105294. */
  105295. lastDragPosition: Vector3;
  105296. /**
  105297. * If the behavior is currently in a dragging state
  105298. */
  105299. dragging: boolean;
  105300. /**
  105301. * 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)
  105302. */
  105303. dragDeltaRatio: number;
  105304. /**
  105305. * If the drag plane orientation should be updated during the dragging (Default: true)
  105306. */
  105307. updateDragPlane: boolean;
  105308. private _debugMode;
  105309. private _moving;
  105310. /**
  105311. * Fires each time the attached mesh is dragged with the pointer
  105312. * * delta between last drag position and current drag position in world space
  105313. * * dragDistance along the drag axis
  105314. * * dragPlaneNormal normal of the current drag plane used during the drag
  105315. * * dragPlanePoint in world space where the drag intersects the drag plane
  105316. */
  105317. onDragObservable: Observable<{
  105318. delta: Vector3;
  105319. dragPlanePoint: Vector3;
  105320. dragPlaneNormal: Vector3;
  105321. dragDistance: number;
  105322. pointerId: number;
  105323. }>;
  105324. /**
  105325. * Fires each time a drag begins (eg. mouse down on mesh)
  105326. */
  105327. onDragStartObservable: Observable<{
  105328. dragPlanePoint: Vector3;
  105329. pointerId: number;
  105330. }>;
  105331. /**
  105332. * Fires each time a drag ends (eg. mouse release after drag)
  105333. */
  105334. onDragEndObservable: Observable<{
  105335. dragPlanePoint: Vector3;
  105336. pointerId: number;
  105337. }>;
  105338. /**
  105339. * If the attached mesh should be moved when dragged
  105340. */
  105341. moveAttached: boolean;
  105342. /**
  105343. * If the drag behavior will react to drag events (Default: true)
  105344. */
  105345. enabled: boolean;
  105346. /**
  105347. * If pointer events should start and release the drag (Default: true)
  105348. */
  105349. startAndReleaseDragOnPointerEvents: boolean;
  105350. /**
  105351. * If camera controls should be detached during the drag
  105352. */
  105353. detachCameraControls: boolean;
  105354. /**
  105355. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105356. */
  105357. useObjectOrienationForDragging: boolean;
  105358. private _options;
  105359. /**
  105360. * Creates a pointer drag behavior that can be attached to a mesh
  105361. * @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)
  105362. */
  105363. constructor(options?: {
  105364. dragAxis?: Vector3;
  105365. dragPlaneNormal?: Vector3;
  105366. });
  105367. /**
  105368. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105369. */
  105370. validateDrag: (targetPosition: Vector3) => boolean;
  105371. /**
  105372. * The name of the behavior
  105373. */
  105374. readonly name: string;
  105375. /**
  105376. * Initializes the behavior
  105377. */
  105378. init(): void;
  105379. private _tmpVector;
  105380. private _alternatePickedPoint;
  105381. private _worldDragAxis;
  105382. private _targetPosition;
  105383. private _attachedElement;
  105384. /**
  105385. * Attaches the drag behavior the passed in mesh
  105386. * @param ownerNode The mesh that will be dragged around once attached
  105387. * @param predicate Predicate to use for pick filtering
  105388. */
  105389. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105390. /**
  105391. * Force relase the drag action by code.
  105392. */
  105393. releaseDrag(): void;
  105394. private _startDragRay;
  105395. private _lastPointerRay;
  105396. /**
  105397. * Simulates the start of a pointer drag event on the behavior
  105398. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105399. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105400. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105401. */
  105402. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105403. private _startDrag;
  105404. private _dragDelta;
  105405. private _moveDrag;
  105406. private _pickWithRayOnDragPlane;
  105407. private _pointA;
  105408. private _pointB;
  105409. private _pointC;
  105410. private _lineA;
  105411. private _lineB;
  105412. private _localAxis;
  105413. private _lookAt;
  105414. private _updateDragPlanePosition;
  105415. /**
  105416. * Detaches the behavior from the mesh
  105417. */
  105418. detach(): void;
  105419. }
  105420. }
  105421. declare module BABYLON {
  105422. /**
  105423. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105424. */
  105425. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105426. private _dragBehaviorA;
  105427. private _dragBehaviorB;
  105428. private _startDistance;
  105429. private _initialScale;
  105430. private _targetScale;
  105431. private _ownerNode;
  105432. private _sceneRenderObserver;
  105433. /**
  105434. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105435. */
  105436. constructor();
  105437. /**
  105438. * The name of the behavior
  105439. */
  105440. readonly name: string;
  105441. /**
  105442. * Initializes the behavior
  105443. */
  105444. init(): void;
  105445. private _getCurrentDistance;
  105446. /**
  105447. * Attaches the scale behavior the passed in mesh
  105448. * @param ownerNode The mesh that will be scaled around once attached
  105449. */
  105450. attach(ownerNode: Mesh): void;
  105451. /**
  105452. * Detaches the behavior from the mesh
  105453. */
  105454. detach(): void;
  105455. }
  105456. }
  105457. declare module BABYLON {
  105458. /**
  105459. * 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
  105460. */
  105461. export class SixDofDragBehavior implements Behavior<Mesh> {
  105462. private static _virtualScene;
  105463. private _ownerNode;
  105464. private _sceneRenderObserver;
  105465. private _scene;
  105466. private _targetPosition;
  105467. private _virtualOriginMesh;
  105468. private _virtualDragMesh;
  105469. private _pointerObserver;
  105470. private _moving;
  105471. private _startingOrientation;
  105472. /**
  105473. * 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)
  105474. */
  105475. private zDragFactor;
  105476. /**
  105477. * If the object should rotate to face the drag origin
  105478. */
  105479. rotateDraggedObject: boolean;
  105480. /**
  105481. * If the behavior is currently in a dragging state
  105482. */
  105483. dragging: boolean;
  105484. /**
  105485. * 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)
  105486. */
  105487. dragDeltaRatio: number;
  105488. /**
  105489. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105490. */
  105491. currentDraggingPointerID: number;
  105492. /**
  105493. * If camera controls should be detached during the drag
  105494. */
  105495. detachCameraControls: boolean;
  105496. /**
  105497. * Fires each time a drag starts
  105498. */
  105499. onDragStartObservable: Observable<{}>;
  105500. /**
  105501. * Fires each time a drag ends (eg. mouse release after drag)
  105502. */
  105503. onDragEndObservable: Observable<{}>;
  105504. /**
  105505. * 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
  105506. */
  105507. constructor();
  105508. /**
  105509. * The name of the behavior
  105510. */
  105511. readonly name: string;
  105512. /**
  105513. * Initializes the behavior
  105514. */
  105515. init(): void;
  105516. /**
  105517. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105518. */
  105519. private readonly _pointerCamera;
  105520. /**
  105521. * Attaches the scale behavior the passed in mesh
  105522. * @param ownerNode The mesh that will be scaled around once attached
  105523. */
  105524. attach(ownerNode: Mesh): void;
  105525. /**
  105526. * Detaches the behavior from the mesh
  105527. */
  105528. detach(): void;
  105529. }
  105530. }
  105531. declare module BABYLON {
  105532. /**
  105533. * Class used to apply inverse kinematics to bones
  105534. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105535. */
  105536. export class BoneIKController {
  105537. private static _tmpVecs;
  105538. private static _tmpQuat;
  105539. private static _tmpMats;
  105540. /**
  105541. * Gets or sets the target mesh
  105542. */
  105543. targetMesh: AbstractMesh;
  105544. /** Gets or sets the mesh used as pole */
  105545. poleTargetMesh: AbstractMesh;
  105546. /**
  105547. * Gets or sets the bone used as pole
  105548. */
  105549. poleTargetBone: Nullable<Bone>;
  105550. /**
  105551. * Gets or sets the target position
  105552. */
  105553. targetPosition: Vector3;
  105554. /**
  105555. * Gets or sets the pole target position
  105556. */
  105557. poleTargetPosition: Vector3;
  105558. /**
  105559. * Gets or sets the pole target local offset
  105560. */
  105561. poleTargetLocalOffset: Vector3;
  105562. /**
  105563. * Gets or sets the pole angle
  105564. */
  105565. poleAngle: number;
  105566. /**
  105567. * Gets or sets the mesh associated with the controller
  105568. */
  105569. mesh: AbstractMesh;
  105570. /**
  105571. * 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)
  105572. */
  105573. slerpAmount: number;
  105574. private _bone1Quat;
  105575. private _bone1Mat;
  105576. private _bone2Ang;
  105577. private _bone1;
  105578. private _bone2;
  105579. private _bone1Length;
  105580. private _bone2Length;
  105581. private _maxAngle;
  105582. private _maxReach;
  105583. private _rightHandedSystem;
  105584. private _bendAxis;
  105585. private _slerping;
  105586. private _adjustRoll;
  105587. /**
  105588. * Gets or sets maximum allowed angle
  105589. */
  105590. maxAngle: number;
  105591. /**
  105592. * Creates a new BoneIKController
  105593. * @param mesh defines the mesh to control
  105594. * @param bone defines the bone to control
  105595. * @param options defines options to set up the controller
  105596. */
  105597. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105598. targetMesh?: AbstractMesh;
  105599. poleTargetMesh?: AbstractMesh;
  105600. poleTargetBone?: Bone;
  105601. poleTargetLocalOffset?: Vector3;
  105602. poleAngle?: number;
  105603. bendAxis?: Vector3;
  105604. maxAngle?: number;
  105605. slerpAmount?: number;
  105606. });
  105607. private _setMaxAngle;
  105608. /**
  105609. * Force the controller to update the bones
  105610. */
  105611. update(): void;
  105612. }
  105613. }
  105614. declare module BABYLON {
  105615. /**
  105616. * Class used to make a bone look toward a point in space
  105617. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105618. */
  105619. export class BoneLookController {
  105620. private static _tmpVecs;
  105621. private static _tmpQuat;
  105622. private static _tmpMats;
  105623. /**
  105624. * The target Vector3 that the bone will look at
  105625. */
  105626. target: Vector3;
  105627. /**
  105628. * The mesh that the bone is attached to
  105629. */
  105630. mesh: AbstractMesh;
  105631. /**
  105632. * The bone that will be looking to the target
  105633. */
  105634. bone: Bone;
  105635. /**
  105636. * The up axis of the coordinate system that is used when the bone is rotated
  105637. */
  105638. upAxis: Vector3;
  105639. /**
  105640. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105641. */
  105642. upAxisSpace: Space;
  105643. /**
  105644. * Used to make an adjustment to the yaw of the bone
  105645. */
  105646. adjustYaw: number;
  105647. /**
  105648. * Used to make an adjustment to the pitch of the bone
  105649. */
  105650. adjustPitch: number;
  105651. /**
  105652. * Used to make an adjustment to the roll of the bone
  105653. */
  105654. adjustRoll: number;
  105655. /**
  105656. * 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)
  105657. */
  105658. slerpAmount: number;
  105659. private _minYaw;
  105660. private _maxYaw;
  105661. private _minPitch;
  105662. private _maxPitch;
  105663. private _minYawSin;
  105664. private _minYawCos;
  105665. private _maxYawSin;
  105666. private _maxYawCos;
  105667. private _midYawConstraint;
  105668. private _minPitchTan;
  105669. private _maxPitchTan;
  105670. private _boneQuat;
  105671. private _slerping;
  105672. private _transformYawPitch;
  105673. private _transformYawPitchInv;
  105674. private _firstFrameSkipped;
  105675. private _yawRange;
  105676. private _fowardAxis;
  105677. /**
  105678. * Gets or sets the minimum yaw angle that the bone can look to
  105679. */
  105680. minYaw: number;
  105681. /**
  105682. * Gets or sets the maximum yaw angle that the bone can look to
  105683. */
  105684. maxYaw: number;
  105685. /**
  105686. * Gets or sets the minimum pitch angle that the bone can look to
  105687. */
  105688. minPitch: number;
  105689. /**
  105690. * Gets or sets the maximum pitch angle that the bone can look to
  105691. */
  105692. maxPitch: number;
  105693. /**
  105694. * Create a BoneLookController
  105695. * @param mesh the mesh that the bone belongs to
  105696. * @param bone the bone that will be looking to the target
  105697. * @param target the target Vector3 to look at
  105698. * @param options optional settings:
  105699. * * maxYaw: the maximum angle the bone will yaw to
  105700. * * minYaw: the minimum angle the bone will yaw to
  105701. * * maxPitch: the maximum angle the bone will pitch to
  105702. * * minPitch: the minimum angle the bone will yaw to
  105703. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105704. * * upAxis: the up axis of the coordinate system
  105705. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105706. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105707. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105708. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105709. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105710. * * adjustRoll: used to make an adjustment to the roll of the bone
  105711. **/
  105712. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105713. maxYaw?: number;
  105714. minYaw?: number;
  105715. maxPitch?: number;
  105716. minPitch?: number;
  105717. slerpAmount?: number;
  105718. upAxis?: Vector3;
  105719. upAxisSpace?: Space;
  105720. yawAxis?: Vector3;
  105721. pitchAxis?: Vector3;
  105722. adjustYaw?: number;
  105723. adjustPitch?: number;
  105724. adjustRoll?: number;
  105725. });
  105726. /**
  105727. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105728. */
  105729. update(): void;
  105730. private _getAngleDiff;
  105731. private _getAngleBetween;
  105732. private _isAngleBetween;
  105733. }
  105734. }
  105735. declare module BABYLON {
  105736. /**
  105737. * Manage the gamepad inputs to control an arc rotate camera.
  105738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105739. */
  105740. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105741. /**
  105742. * Defines the camera the input is attached to.
  105743. */
  105744. camera: ArcRotateCamera;
  105745. /**
  105746. * Defines the gamepad the input is gathering event from.
  105747. */
  105748. gamepad: Nullable<Gamepad>;
  105749. /**
  105750. * Defines the gamepad rotation sensiblity.
  105751. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105752. */
  105753. gamepadRotationSensibility: number;
  105754. /**
  105755. * Defines the gamepad move sensiblity.
  105756. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105757. */
  105758. gamepadMoveSensibility: number;
  105759. private _yAxisScale;
  105760. /**
  105761. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105762. */
  105763. invertYAxis: boolean;
  105764. private _onGamepadConnectedObserver;
  105765. private _onGamepadDisconnectedObserver;
  105766. /**
  105767. * Attach the input controls to a specific dom element to get the input from.
  105768. * @param element Defines the element the controls should be listened from
  105769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105770. */
  105771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105772. /**
  105773. * Detach the current controls from the specified dom element.
  105774. * @param element Defines the element to stop listening the inputs from
  105775. */
  105776. detachControl(element: Nullable<HTMLElement>): void;
  105777. /**
  105778. * Update the current camera state depending on the inputs that have been used this frame.
  105779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105780. */
  105781. checkInputs(): void;
  105782. /**
  105783. * Gets the class name of the current intput.
  105784. * @returns the class name
  105785. */
  105786. getClassName(): string;
  105787. /**
  105788. * Get the friendly name associated with the input class.
  105789. * @returns the input friendly name
  105790. */
  105791. getSimpleName(): string;
  105792. }
  105793. }
  105794. declare module BABYLON {
  105795. interface ArcRotateCameraInputsManager {
  105796. /**
  105797. * Add orientation input support to the input manager.
  105798. * @returns the current input manager
  105799. */
  105800. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105801. }
  105802. /**
  105803. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105805. */
  105806. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105807. /**
  105808. * Defines the camera the input is attached to.
  105809. */
  105810. camera: ArcRotateCamera;
  105811. /**
  105812. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105813. */
  105814. alphaCorrection: number;
  105815. /**
  105816. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105817. */
  105818. gammaCorrection: number;
  105819. private _alpha;
  105820. private _gamma;
  105821. private _dirty;
  105822. private _deviceOrientationHandler;
  105823. /**
  105824. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105825. */
  105826. constructor();
  105827. /**
  105828. * Attach the input controls to a specific dom element to get the input from.
  105829. * @param element Defines the element the controls should be listened from
  105830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105831. */
  105832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105833. /** @hidden */
  105834. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105835. /**
  105836. * Update the current camera state depending on the inputs that have been used this frame.
  105837. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105838. */
  105839. checkInputs(): void;
  105840. /**
  105841. * Detach the current controls from the specified dom element.
  105842. * @param element Defines the element to stop listening the inputs from
  105843. */
  105844. detachControl(element: Nullable<HTMLElement>): void;
  105845. /**
  105846. * Gets the class name of the current intput.
  105847. * @returns the class name
  105848. */
  105849. getClassName(): string;
  105850. /**
  105851. * Get the friendly name associated with the input class.
  105852. * @returns the input friendly name
  105853. */
  105854. getSimpleName(): string;
  105855. }
  105856. }
  105857. declare module BABYLON {
  105858. /**
  105859. * Listen to mouse events to control the camera.
  105860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105861. */
  105862. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105863. /**
  105864. * Defines the camera the input is attached to.
  105865. */
  105866. camera: FlyCamera;
  105867. /**
  105868. * Defines if touch is enabled. (Default is true.)
  105869. */
  105870. touchEnabled: boolean;
  105871. /**
  105872. * Defines the buttons associated with the input to handle camera rotation.
  105873. */
  105874. buttons: number[];
  105875. /**
  105876. * Assign buttons for Yaw control.
  105877. */
  105878. buttonsYaw: number[];
  105879. /**
  105880. * Assign buttons for Pitch control.
  105881. */
  105882. buttonsPitch: number[];
  105883. /**
  105884. * Assign buttons for Roll control.
  105885. */
  105886. buttonsRoll: number[];
  105887. /**
  105888. * Detect if any button is being pressed while mouse is moved.
  105889. * -1 = Mouse locked.
  105890. * 0 = Left button.
  105891. * 1 = Middle Button.
  105892. * 2 = Right Button.
  105893. */
  105894. activeButton: number;
  105895. /**
  105896. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105897. * Higher values reduce its sensitivity.
  105898. */
  105899. angularSensibility: number;
  105900. private _mousemoveCallback;
  105901. private _observer;
  105902. private _rollObserver;
  105903. private previousPosition;
  105904. private noPreventDefault;
  105905. private element;
  105906. /**
  105907. * Listen to mouse events to control the camera.
  105908. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105910. */
  105911. constructor(touchEnabled?: boolean);
  105912. /**
  105913. * Attach the mouse control to the HTML DOM element.
  105914. * @param element Defines the element that listens to the input events.
  105915. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105916. */
  105917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105918. /**
  105919. * Detach the current controls from the specified dom element.
  105920. * @param element Defines the element to stop listening the inputs from
  105921. */
  105922. detachControl(element: Nullable<HTMLElement>): void;
  105923. /**
  105924. * Gets the class name of the current input.
  105925. * @returns the class name.
  105926. */
  105927. getClassName(): string;
  105928. /**
  105929. * Get the friendly name associated with the input class.
  105930. * @returns the input's friendly name.
  105931. */
  105932. getSimpleName(): string;
  105933. private _pointerInput;
  105934. private _onMouseMove;
  105935. /**
  105936. * Rotate camera by mouse offset.
  105937. */
  105938. private rotateCamera;
  105939. }
  105940. }
  105941. declare module BABYLON {
  105942. /**
  105943. * Default Inputs manager for the FlyCamera.
  105944. * It groups all the default supported inputs for ease of use.
  105945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105946. */
  105947. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105948. /**
  105949. * Instantiates a new FlyCameraInputsManager.
  105950. * @param camera Defines the camera the inputs belong to.
  105951. */
  105952. constructor(camera: FlyCamera);
  105953. /**
  105954. * Add keyboard input support to the input manager.
  105955. * @returns the new FlyCameraKeyboardMoveInput().
  105956. */
  105957. addKeyboard(): FlyCameraInputsManager;
  105958. /**
  105959. * Add mouse input support to the input manager.
  105960. * @param touchEnabled Enable touch screen support.
  105961. * @returns the new FlyCameraMouseInput().
  105962. */
  105963. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105964. }
  105965. }
  105966. declare module BABYLON {
  105967. /**
  105968. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105969. * such as in a 3D Space Shooter or a Flight Simulator.
  105970. */
  105971. export class FlyCamera extends TargetCamera {
  105972. /**
  105973. * Define the collision ellipsoid of the camera.
  105974. * This is helpful for simulating a camera body, like a player's body.
  105975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105976. */
  105977. ellipsoid: Vector3;
  105978. /**
  105979. * Define an offset for the position of the ellipsoid around the camera.
  105980. * This can be helpful if the camera is attached away from the player's body center,
  105981. * such as at its head.
  105982. */
  105983. ellipsoidOffset: Vector3;
  105984. /**
  105985. * Enable or disable collisions of the camera with the rest of the scene objects.
  105986. */
  105987. checkCollisions: boolean;
  105988. /**
  105989. * Enable or disable gravity on the camera.
  105990. */
  105991. applyGravity: boolean;
  105992. /**
  105993. * Define the current direction the camera is moving to.
  105994. */
  105995. cameraDirection: Vector3;
  105996. /**
  105997. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105998. * This overrides and empties cameraRotation.
  105999. */
  106000. rotationQuaternion: Quaternion;
  106001. /**
  106002. * Track Roll to maintain the wanted Rolling when looking around.
  106003. */
  106004. _trackRoll: number;
  106005. /**
  106006. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106007. */
  106008. rollCorrect: number;
  106009. /**
  106010. * Mimic a banked turn, Rolling the camera when Yawing.
  106011. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106012. */
  106013. bankedTurn: boolean;
  106014. /**
  106015. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106016. */
  106017. bankedTurnLimit: number;
  106018. /**
  106019. * Value of 0 disables the banked Roll.
  106020. * Value of 1 is equal to the Yaw angle in radians.
  106021. */
  106022. bankedTurnMultiplier: number;
  106023. /**
  106024. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106025. */
  106026. inputs: FlyCameraInputsManager;
  106027. /**
  106028. * Gets the input sensibility for mouse input.
  106029. * Higher values reduce sensitivity.
  106030. */
  106031. /**
  106032. * Sets the input sensibility for a mouse input.
  106033. * Higher values reduce sensitivity.
  106034. */
  106035. angularSensibility: number;
  106036. /**
  106037. * Get the keys for camera movement forward.
  106038. */
  106039. /**
  106040. * Set the keys for camera movement forward.
  106041. */
  106042. keysForward: number[];
  106043. /**
  106044. * Get the keys for camera movement backward.
  106045. */
  106046. keysBackward: number[];
  106047. /**
  106048. * Get the keys for camera movement up.
  106049. */
  106050. /**
  106051. * Set the keys for camera movement up.
  106052. */
  106053. keysUp: number[];
  106054. /**
  106055. * Get the keys for camera movement down.
  106056. */
  106057. /**
  106058. * Set the keys for camera movement down.
  106059. */
  106060. keysDown: number[];
  106061. /**
  106062. * Get the keys for camera movement left.
  106063. */
  106064. /**
  106065. * Set the keys for camera movement left.
  106066. */
  106067. keysLeft: number[];
  106068. /**
  106069. * Set the keys for camera movement right.
  106070. */
  106071. /**
  106072. * Set the keys for camera movement right.
  106073. */
  106074. keysRight: number[];
  106075. /**
  106076. * Event raised when the camera collides with a mesh in the scene.
  106077. */
  106078. onCollide: (collidedMesh: AbstractMesh) => void;
  106079. private _collider;
  106080. private _needMoveForGravity;
  106081. private _oldPosition;
  106082. private _diffPosition;
  106083. private _newPosition;
  106084. /** @hidden */
  106085. _localDirection: Vector3;
  106086. /** @hidden */
  106087. _transformedDirection: Vector3;
  106088. /**
  106089. * Instantiates a FlyCamera.
  106090. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106091. * such as in a 3D Space Shooter or a Flight Simulator.
  106092. * @param name Define the name of the camera in the scene.
  106093. * @param position Define the starting position of the camera in the scene.
  106094. * @param scene Define the scene the camera belongs to.
  106095. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106096. */
  106097. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106098. /**
  106099. * Attach a control to the HTML DOM element.
  106100. * @param element Defines the element that listens to the input events.
  106101. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106102. */
  106103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106104. /**
  106105. * Detach a control from the HTML DOM element.
  106106. * The camera will stop reacting to that input.
  106107. * @param element Defines the element that listens to the input events.
  106108. */
  106109. detachControl(element: HTMLElement): void;
  106110. private _collisionMask;
  106111. /**
  106112. * Get the mask that the camera ignores in collision events.
  106113. */
  106114. /**
  106115. * Set the mask that the camera ignores in collision events.
  106116. */
  106117. collisionMask: number;
  106118. /** @hidden */
  106119. _collideWithWorld(displacement: Vector3): void;
  106120. /** @hidden */
  106121. private _onCollisionPositionChange;
  106122. /** @hidden */
  106123. _checkInputs(): void;
  106124. /** @hidden */
  106125. _decideIfNeedsToMove(): boolean;
  106126. /** @hidden */
  106127. _updatePosition(): void;
  106128. /**
  106129. * Restore the Roll to its target value at the rate specified.
  106130. * @param rate - Higher means slower restoring.
  106131. * @hidden
  106132. */
  106133. restoreRoll(rate: number): void;
  106134. /**
  106135. * Destroy the camera and release the current resources held by it.
  106136. */
  106137. dispose(): void;
  106138. /**
  106139. * Get the current object class name.
  106140. * @returns the class name.
  106141. */
  106142. getClassName(): string;
  106143. }
  106144. }
  106145. declare module BABYLON {
  106146. /**
  106147. * Listen to keyboard events to control the camera.
  106148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106149. */
  106150. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106151. /**
  106152. * Defines the camera the input is attached to.
  106153. */
  106154. camera: FlyCamera;
  106155. /**
  106156. * The list of keyboard keys used to control the forward move of the camera.
  106157. */
  106158. keysForward: number[];
  106159. /**
  106160. * The list of keyboard keys used to control the backward move of the camera.
  106161. */
  106162. keysBackward: number[];
  106163. /**
  106164. * The list of keyboard keys used to control the forward move of the camera.
  106165. */
  106166. keysUp: number[];
  106167. /**
  106168. * The list of keyboard keys used to control the backward move of the camera.
  106169. */
  106170. keysDown: number[];
  106171. /**
  106172. * The list of keyboard keys used to control the right strafe move of the camera.
  106173. */
  106174. keysRight: number[];
  106175. /**
  106176. * The list of keyboard keys used to control the left strafe move of the camera.
  106177. */
  106178. keysLeft: number[];
  106179. private _keys;
  106180. private _onCanvasBlurObserver;
  106181. private _onKeyboardObserver;
  106182. private _engine;
  106183. private _scene;
  106184. /**
  106185. * Attach the input controls to a specific dom element to get the input from.
  106186. * @param element Defines the element the controls should be listened from
  106187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106188. */
  106189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106190. /**
  106191. * Detach the current controls from the specified dom element.
  106192. * @param element Defines the element to stop listening the inputs from
  106193. */
  106194. detachControl(element: Nullable<HTMLElement>): void;
  106195. /**
  106196. * Gets the class name of the current intput.
  106197. * @returns the class name
  106198. */
  106199. getClassName(): string;
  106200. /** @hidden */
  106201. _onLostFocus(e: FocusEvent): void;
  106202. /**
  106203. * Get the friendly name associated with the input class.
  106204. * @returns the input friendly name
  106205. */
  106206. getSimpleName(): string;
  106207. /**
  106208. * Update the current camera state depending on the inputs that have been used this frame.
  106209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106210. */
  106211. checkInputs(): void;
  106212. }
  106213. }
  106214. declare module BABYLON {
  106215. /**
  106216. * Manage the mouse wheel inputs to control a follow camera.
  106217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106218. */
  106219. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106220. /**
  106221. * Defines the camera the input is attached to.
  106222. */
  106223. camera: FollowCamera;
  106224. /**
  106225. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106226. */
  106227. axisControlRadius: boolean;
  106228. /**
  106229. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106230. */
  106231. axisControlHeight: boolean;
  106232. /**
  106233. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106234. */
  106235. axisControlRotation: boolean;
  106236. /**
  106237. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106238. * relation to mouseWheel events.
  106239. */
  106240. wheelPrecision: number;
  106241. /**
  106242. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106243. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106244. */
  106245. wheelDeltaPercentage: number;
  106246. private _wheel;
  106247. private _observer;
  106248. /**
  106249. * Attach the input controls to a specific dom element to get the input from.
  106250. * @param element Defines the element the controls should be listened from
  106251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106252. */
  106253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106254. /**
  106255. * Detach the current controls from the specified dom element.
  106256. * @param element Defines the element to stop listening the inputs from
  106257. */
  106258. detachControl(element: Nullable<HTMLElement>): void;
  106259. /**
  106260. * Gets the class name of the current intput.
  106261. * @returns the class name
  106262. */
  106263. getClassName(): string;
  106264. /**
  106265. * Get the friendly name associated with the input class.
  106266. * @returns the input friendly name
  106267. */
  106268. getSimpleName(): string;
  106269. }
  106270. }
  106271. declare module BABYLON {
  106272. /**
  106273. * Manage the pointers inputs to control an follow camera.
  106274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106275. */
  106276. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106277. /**
  106278. * Defines the camera the input is attached to.
  106279. */
  106280. camera: FollowCamera;
  106281. /**
  106282. * Gets the class name of the current input.
  106283. * @returns the class name
  106284. */
  106285. getClassName(): string;
  106286. /**
  106287. * Defines the pointer angular sensibility along the X axis or how fast is
  106288. * the camera rotating.
  106289. * A negative number will reverse the axis direction.
  106290. */
  106291. angularSensibilityX: number;
  106292. /**
  106293. * Defines the pointer angular sensibility along the Y axis or how fast is
  106294. * the camera rotating.
  106295. * A negative number will reverse the axis direction.
  106296. */
  106297. angularSensibilityY: number;
  106298. /**
  106299. * Defines the pointer pinch precision or how fast is the camera zooming.
  106300. * A negative number will reverse the axis direction.
  106301. */
  106302. pinchPrecision: number;
  106303. /**
  106304. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106305. * from 0.
  106306. * It defines the percentage of current camera.radius to use as delta when
  106307. * pinch zoom is used.
  106308. */
  106309. pinchDeltaPercentage: number;
  106310. /**
  106311. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106312. */
  106313. axisXControlRadius: boolean;
  106314. /**
  106315. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106316. */
  106317. axisXControlHeight: boolean;
  106318. /**
  106319. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106320. */
  106321. axisXControlRotation: boolean;
  106322. /**
  106323. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106324. */
  106325. axisYControlRadius: boolean;
  106326. /**
  106327. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106328. */
  106329. axisYControlHeight: boolean;
  106330. /**
  106331. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106332. */
  106333. axisYControlRotation: boolean;
  106334. /**
  106335. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106336. */
  106337. axisPinchControlRadius: boolean;
  106338. /**
  106339. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106340. */
  106341. axisPinchControlHeight: boolean;
  106342. /**
  106343. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106344. */
  106345. axisPinchControlRotation: boolean;
  106346. /**
  106347. * Log error messages if basic misconfiguration has occurred.
  106348. */
  106349. warningEnable: boolean;
  106350. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106351. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106352. private _warningCounter;
  106353. private _warning;
  106354. }
  106355. }
  106356. declare module BABYLON {
  106357. /**
  106358. * Default Inputs manager for the FollowCamera.
  106359. * It groups all the default supported inputs for ease of use.
  106360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106361. */
  106362. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106363. /**
  106364. * Instantiates a new FollowCameraInputsManager.
  106365. * @param camera Defines the camera the inputs belong to
  106366. */
  106367. constructor(camera: FollowCamera);
  106368. /**
  106369. * Add keyboard input support to the input manager.
  106370. * @returns the current input manager
  106371. */
  106372. addKeyboard(): FollowCameraInputsManager;
  106373. /**
  106374. * Add mouse wheel input support to the input manager.
  106375. * @returns the current input manager
  106376. */
  106377. addMouseWheel(): FollowCameraInputsManager;
  106378. /**
  106379. * Add pointers input support to the input manager.
  106380. * @returns the current input manager
  106381. */
  106382. addPointers(): FollowCameraInputsManager;
  106383. /**
  106384. * Add orientation input support to the input manager.
  106385. * @returns the current input manager
  106386. */
  106387. addVRDeviceOrientation(): FollowCameraInputsManager;
  106388. }
  106389. }
  106390. declare module BABYLON {
  106391. /**
  106392. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106393. * an arc rotate version arcFollowCamera are available.
  106394. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106395. */
  106396. export class FollowCamera extends TargetCamera {
  106397. /**
  106398. * Distance the follow camera should follow an object at
  106399. */
  106400. radius: number;
  106401. /**
  106402. * Minimum allowed distance of the camera to the axis of rotation
  106403. * (The camera can not get closer).
  106404. * This can help limiting how the Camera is able to move in the scene.
  106405. */
  106406. lowerRadiusLimit: Nullable<number>;
  106407. /**
  106408. * Maximum allowed distance of the camera to the axis of rotation
  106409. * (The camera can not get further).
  106410. * This can help limiting how the Camera is able to move in the scene.
  106411. */
  106412. upperRadiusLimit: Nullable<number>;
  106413. /**
  106414. * Define a rotation offset between the camera and the object it follows
  106415. */
  106416. rotationOffset: number;
  106417. /**
  106418. * Minimum allowed angle to camera position relative to target object.
  106419. * This can help limiting how the Camera is able to move in the scene.
  106420. */
  106421. lowerRotationOffsetLimit: Nullable<number>;
  106422. /**
  106423. * Maximum allowed angle to camera position relative to target object.
  106424. * This can help limiting how the Camera is able to move in the scene.
  106425. */
  106426. upperRotationOffsetLimit: Nullable<number>;
  106427. /**
  106428. * Define a height offset between the camera and the object it follows.
  106429. * It can help following an object from the top (like a car chaing a plane)
  106430. */
  106431. heightOffset: number;
  106432. /**
  106433. * Minimum allowed height of camera position relative to target object.
  106434. * This can help limiting how the Camera is able to move in the scene.
  106435. */
  106436. lowerHeightOffsetLimit: Nullable<number>;
  106437. /**
  106438. * Maximum allowed height of camera position relative to target object.
  106439. * This can help limiting how the Camera is able to move in the scene.
  106440. */
  106441. upperHeightOffsetLimit: Nullable<number>;
  106442. /**
  106443. * Define how fast the camera can accelerate to follow it s target.
  106444. */
  106445. cameraAcceleration: number;
  106446. /**
  106447. * Define the speed limit of the camera following an object.
  106448. */
  106449. maxCameraSpeed: number;
  106450. /**
  106451. * Define the target of the camera.
  106452. */
  106453. lockedTarget: Nullable<AbstractMesh>;
  106454. /**
  106455. * Defines the input associated with the camera.
  106456. */
  106457. inputs: FollowCameraInputsManager;
  106458. /**
  106459. * Instantiates the follow camera.
  106460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106461. * @param name Define the name of the camera in the scene
  106462. * @param position Define the position of the camera
  106463. * @param scene Define the scene the camera belong to
  106464. * @param lockedTarget Define the target of the camera
  106465. */
  106466. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106467. private _follow;
  106468. /**
  106469. * Attached controls to the current camera.
  106470. * @param element Defines the element the controls should be listened from
  106471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106472. */
  106473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106474. /**
  106475. * Detach the current controls from the camera.
  106476. * The camera will stop reacting to inputs.
  106477. * @param element Defines the element to stop listening the inputs from
  106478. */
  106479. detachControl(element: HTMLElement): void;
  106480. /** @hidden */
  106481. _checkInputs(): void;
  106482. private _checkLimits;
  106483. /**
  106484. * Gets the camera class name.
  106485. * @returns the class name
  106486. */
  106487. getClassName(): string;
  106488. }
  106489. /**
  106490. * Arc Rotate version of the follow camera.
  106491. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106492. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106493. */
  106494. export class ArcFollowCamera extends TargetCamera {
  106495. /** The longitudinal angle of the camera */
  106496. alpha: number;
  106497. /** The latitudinal angle of the camera */
  106498. beta: number;
  106499. /** The radius of the camera from its target */
  106500. radius: number;
  106501. /** Define the camera target (the messh it should follow) */
  106502. target: Nullable<AbstractMesh>;
  106503. private _cartesianCoordinates;
  106504. /**
  106505. * Instantiates a new ArcFollowCamera
  106506. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106507. * @param name Define the name of the camera
  106508. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106509. * @param beta Define the rotation angle of the camera around the elevation axis
  106510. * @param radius Define the radius of the camera from its target point
  106511. * @param target Define the target of the camera
  106512. * @param scene Define the scene the camera belongs to
  106513. */
  106514. constructor(name: string,
  106515. /** The longitudinal angle of the camera */
  106516. alpha: number,
  106517. /** The latitudinal angle of the camera */
  106518. beta: number,
  106519. /** The radius of the camera from its target */
  106520. radius: number,
  106521. /** Define the camera target (the messh it should follow) */
  106522. target: Nullable<AbstractMesh>, scene: Scene);
  106523. private _follow;
  106524. /** @hidden */
  106525. _checkInputs(): void;
  106526. /**
  106527. * Returns the class name of the object.
  106528. * It is mostly used internally for serialization purposes.
  106529. */
  106530. getClassName(): string;
  106531. }
  106532. }
  106533. declare module BABYLON {
  106534. /**
  106535. * Manage the keyboard inputs to control the movement of a follow camera.
  106536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106537. */
  106538. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106539. /**
  106540. * Defines the camera the input is attached to.
  106541. */
  106542. camera: FollowCamera;
  106543. /**
  106544. * Defines the list of key codes associated with the up action (increase heightOffset)
  106545. */
  106546. keysHeightOffsetIncr: number[];
  106547. /**
  106548. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106549. */
  106550. keysHeightOffsetDecr: number[];
  106551. /**
  106552. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106553. */
  106554. keysHeightOffsetModifierAlt: boolean;
  106555. /**
  106556. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106557. */
  106558. keysHeightOffsetModifierCtrl: boolean;
  106559. /**
  106560. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106561. */
  106562. keysHeightOffsetModifierShift: boolean;
  106563. /**
  106564. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106565. */
  106566. keysRotationOffsetIncr: number[];
  106567. /**
  106568. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106569. */
  106570. keysRotationOffsetDecr: number[];
  106571. /**
  106572. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106573. */
  106574. keysRotationOffsetModifierAlt: boolean;
  106575. /**
  106576. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106577. */
  106578. keysRotationOffsetModifierCtrl: boolean;
  106579. /**
  106580. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106581. */
  106582. keysRotationOffsetModifierShift: boolean;
  106583. /**
  106584. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106585. */
  106586. keysRadiusIncr: number[];
  106587. /**
  106588. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106589. */
  106590. keysRadiusDecr: number[];
  106591. /**
  106592. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106593. */
  106594. keysRadiusModifierAlt: boolean;
  106595. /**
  106596. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106597. */
  106598. keysRadiusModifierCtrl: boolean;
  106599. /**
  106600. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106601. */
  106602. keysRadiusModifierShift: boolean;
  106603. /**
  106604. * Defines the rate of change of heightOffset.
  106605. */
  106606. heightSensibility: number;
  106607. /**
  106608. * Defines the rate of change of rotationOffset.
  106609. */
  106610. rotationSensibility: number;
  106611. /**
  106612. * Defines the rate of change of radius.
  106613. */
  106614. radiusSensibility: number;
  106615. private _keys;
  106616. private _ctrlPressed;
  106617. private _altPressed;
  106618. private _shiftPressed;
  106619. private _onCanvasBlurObserver;
  106620. private _onKeyboardObserver;
  106621. private _engine;
  106622. private _scene;
  106623. /**
  106624. * Attach the input controls to a specific dom element to get the input from.
  106625. * @param element Defines the element the controls should be listened from
  106626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106627. */
  106628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106629. /**
  106630. * Detach the current controls from the specified dom element.
  106631. * @param element Defines the element to stop listening the inputs from
  106632. */
  106633. detachControl(element: Nullable<HTMLElement>): void;
  106634. /**
  106635. * Update the current camera state depending on the inputs that have been used this frame.
  106636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106637. */
  106638. checkInputs(): void;
  106639. /**
  106640. * Gets the class name of the current input.
  106641. * @returns the class name
  106642. */
  106643. getClassName(): string;
  106644. /**
  106645. * Get the friendly name associated with the input class.
  106646. * @returns the input friendly name
  106647. */
  106648. getSimpleName(): string;
  106649. /**
  106650. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106651. * allow modification of the heightOffset value.
  106652. */
  106653. private _modifierHeightOffset;
  106654. /**
  106655. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106656. * allow modification of the rotationOffset value.
  106657. */
  106658. private _modifierRotationOffset;
  106659. /**
  106660. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106661. * allow modification of the radius value.
  106662. */
  106663. private _modifierRadius;
  106664. }
  106665. }
  106666. declare module BABYLON {
  106667. interface FreeCameraInputsManager {
  106668. /**
  106669. * @hidden
  106670. */
  106671. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106672. /**
  106673. * Add orientation input support to the input manager.
  106674. * @returns the current input manager
  106675. */
  106676. addDeviceOrientation(): FreeCameraInputsManager;
  106677. }
  106678. /**
  106679. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106680. * Screen rotation is taken into account.
  106681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106682. */
  106683. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106684. private _camera;
  106685. private _screenOrientationAngle;
  106686. private _constantTranform;
  106687. private _screenQuaternion;
  106688. private _alpha;
  106689. private _beta;
  106690. private _gamma;
  106691. /**
  106692. * Can be used to detect if a device orientation sensor is availible on a device
  106693. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106694. * @returns a promise that will resolve on orientation change
  106695. */
  106696. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106697. /**
  106698. * @hidden
  106699. */
  106700. _onDeviceOrientationChangedObservable: Observable<void>;
  106701. /**
  106702. * Instantiates a new input
  106703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106704. */
  106705. constructor();
  106706. /**
  106707. * Define the camera controlled by the input.
  106708. */
  106709. camera: FreeCamera;
  106710. /**
  106711. * Attach the input controls to a specific dom element to get the input from.
  106712. * @param element Defines the element the controls should be listened from
  106713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106714. */
  106715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106716. private _orientationChanged;
  106717. private _deviceOrientation;
  106718. /**
  106719. * Detach the current controls from the specified dom element.
  106720. * @param element Defines the element to stop listening the inputs from
  106721. */
  106722. detachControl(element: Nullable<HTMLElement>): void;
  106723. /**
  106724. * Update the current camera state depending on the inputs that have been used this frame.
  106725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106726. */
  106727. checkInputs(): void;
  106728. /**
  106729. * Gets the class name of the current intput.
  106730. * @returns the class name
  106731. */
  106732. getClassName(): string;
  106733. /**
  106734. * Get the friendly name associated with the input class.
  106735. * @returns the input friendly name
  106736. */
  106737. getSimpleName(): string;
  106738. }
  106739. }
  106740. declare module BABYLON {
  106741. /**
  106742. * Manage the gamepad inputs to control a free camera.
  106743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106744. */
  106745. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106746. /**
  106747. * Define the camera the input is attached to.
  106748. */
  106749. camera: FreeCamera;
  106750. /**
  106751. * Define the Gamepad controlling the input
  106752. */
  106753. gamepad: Nullable<Gamepad>;
  106754. /**
  106755. * Defines the gamepad rotation sensiblity.
  106756. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106757. */
  106758. gamepadAngularSensibility: number;
  106759. /**
  106760. * Defines the gamepad move sensiblity.
  106761. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106762. */
  106763. gamepadMoveSensibility: number;
  106764. private _yAxisScale;
  106765. /**
  106766. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106767. */
  106768. invertYAxis: boolean;
  106769. private _onGamepadConnectedObserver;
  106770. private _onGamepadDisconnectedObserver;
  106771. private _cameraTransform;
  106772. private _deltaTransform;
  106773. private _vector3;
  106774. private _vector2;
  106775. /**
  106776. * Attach the input controls to a specific dom element to get the input from.
  106777. * @param element Defines the element the controls should be listened from
  106778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106779. */
  106780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106781. /**
  106782. * Detach the current controls from the specified dom element.
  106783. * @param element Defines the element to stop listening the inputs from
  106784. */
  106785. detachControl(element: Nullable<HTMLElement>): void;
  106786. /**
  106787. * Update the current camera state depending on the inputs that have been used this frame.
  106788. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106789. */
  106790. checkInputs(): void;
  106791. /**
  106792. * Gets the class name of the current intput.
  106793. * @returns the class name
  106794. */
  106795. getClassName(): string;
  106796. /**
  106797. * Get the friendly name associated with the input class.
  106798. * @returns the input friendly name
  106799. */
  106800. getSimpleName(): string;
  106801. }
  106802. }
  106803. declare module BABYLON {
  106804. /**
  106805. * Defines the potential axis of a Joystick
  106806. */
  106807. export enum JoystickAxis {
  106808. /** X axis */
  106809. X = 0,
  106810. /** Y axis */
  106811. Y = 1,
  106812. /** Z axis */
  106813. Z = 2
  106814. }
  106815. /**
  106816. * Class used to define virtual joystick (used in touch mode)
  106817. */
  106818. export class VirtualJoystick {
  106819. /**
  106820. * Gets or sets a boolean indicating that left and right values must be inverted
  106821. */
  106822. reverseLeftRight: boolean;
  106823. /**
  106824. * Gets or sets a boolean indicating that up and down values must be inverted
  106825. */
  106826. reverseUpDown: boolean;
  106827. /**
  106828. * Gets the offset value for the position (ie. the change of the position value)
  106829. */
  106830. deltaPosition: Vector3;
  106831. /**
  106832. * Gets a boolean indicating if the virtual joystick was pressed
  106833. */
  106834. pressed: boolean;
  106835. /**
  106836. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106837. */
  106838. static Canvas: Nullable<HTMLCanvasElement>;
  106839. private static _globalJoystickIndex;
  106840. private static vjCanvasContext;
  106841. private static vjCanvasWidth;
  106842. private static vjCanvasHeight;
  106843. private static halfWidth;
  106844. private _action;
  106845. private _axisTargetedByLeftAndRight;
  106846. private _axisTargetedByUpAndDown;
  106847. private _joystickSensibility;
  106848. private _inversedSensibility;
  106849. private _joystickPointerID;
  106850. private _joystickColor;
  106851. private _joystickPointerPos;
  106852. private _joystickPreviousPointerPos;
  106853. private _joystickPointerStartPos;
  106854. private _deltaJoystickVector;
  106855. private _leftJoystick;
  106856. private _touches;
  106857. private _onPointerDownHandlerRef;
  106858. private _onPointerMoveHandlerRef;
  106859. private _onPointerUpHandlerRef;
  106860. private _onResize;
  106861. /**
  106862. * Creates a new virtual joystick
  106863. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106864. */
  106865. constructor(leftJoystick?: boolean);
  106866. /**
  106867. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106868. * @param newJoystickSensibility defines the new sensibility
  106869. */
  106870. setJoystickSensibility(newJoystickSensibility: number): void;
  106871. private _onPointerDown;
  106872. private _onPointerMove;
  106873. private _onPointerUp;
  106874. /**
  106875. * Change the color of the virtual joystick
  106876. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106877. */
  106878. setJoystickColor(newColor: string): void;
  106879. /**
  106880. * Defines a callback to call when the joystick is touched
  106881. * @param action defines the callback
  106882. */
  106883. setActionOnTouch(action: () => any): void;
  106884. /**
  106885. * Defines which axis you'd like to control for left & right
  106886. * @param axis defines the axis to use
  106887. */
  106888. setAxisForLeftRight(axis: JoystickAxis): void;
  106889. /**
  106890. * Defines which axis you'd like to control for up & down
  106891. * @param axis defines the axis to use
  106892. */
  106893. setAxisForUpDown(axis: JoystickAxis): void;
  106894. private _drawVirtualJoystick;
  106895. /**
  106896. * Release internal HTML canvas
  106897. */
  106898. releaseCanvas(): void;
  106899. }
  106900. }
  106901. declare module BABYLON {
  106902. interface FreeCameraInputsManager {
  106903. /**
  106904. * Add virtual joystick input support to the input manager.
  106905. * @returns the current input manager
  106906. */
  106907. addVirtualJoystick(): FreeCameraInputsManager;
  106908. }
  106909. /**
  106910. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106912. */
  106913. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106914. /**
  106915. * Defines the camera the input is attached to.
  106916. */
  106917. camera: FreeCamera;
  106918. private _leftjoystick;
  106919. private _rightjoystick;
  106920. /**
  106921. * Gets the left stick of the virtual joystick.
  106922. * @returns The virtual Joystick
  106923. */
  106924. getLeftJoystick(): VirtualJoystick;
  106925. /**
  106926. * Gets the right stick of the virtual joystick.
  106927. * @returns The virtual Joystick
  106928. */
  106929. getRightJoystick(): VirtualJoystick;
  106930. /**
  106931. * Update the current camera state depending on the inputs that have been used this frame.
  106932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106933. */
  106934. checkInputs(): void;
  106935. /**
  106936. * Attach the input controls to a specific dom element to get the input from.
  106937. * @param element Defines the element the controls should be listened from
  106938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106939. */
  106940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106941. /**
  106942. * Detach the current controls from the specified dom element.
  106943. * @param element Defines the element to stop listening the inputs from
  106944. */
  106945. detachControl(element: Nullable<HTMLElement>): void;
  106946. /**
  106947. * Gets the class name of the current intput.
  106948. * @returns the class name
  106949. */
  106950. getClassName(): string;
  106951. /**
  106952. * Get the friendly name associated with the input class.
  106953. * @returns the input friendly name
  106954. */
  106955. getSimpleName(): string;
  106956. }
  106957. }
  106958. declare module BABYLON {
  106959. /**
  106960. * This represents a FPS type of camera controlled by touch.
  106961. * This is like a universal camera minus the Gamepad controls.
  106962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106963. */
  106964. export class TouchCamera extends FreeCamera {
  106965. /**
  106966. * Defines the touch sensibility for rotation.
  106967. * The higher the faster.
  106968. */
  106969. touchAngularSensibility: number;
  106970. /**
  106971. * Defines the touch sensibility for move.
  106972. * The higher the faster.
  106973. */
  106974. touchMoveSensibility: number;
  106975. /**
  106976. * Instantiates a new touch camera.
  106977. * This represents a FPS type of camera controlled by touch.
  106978. * This is like a universal camera minus the Gamepad controls.
  106979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106980. * @param name Define the name of the camera in the scene
  106981. * @param position Define the start position of the camera in the scene
  106982. * @param scene Define the scene the camera belongs to
  106983. */
  106984. constructor(name: string, position: Vector3, scene: Scene);
  106985. /**
  106986. * Gets the current object class name.
  106987. * @return the class name
  106988. */
  106989. getClassName(): string;
  106990. /** @hidden */
  106991. _setupInputs(): void;
  106992. }
  106993. }
  106994. declare module BABYLON {
  106995. /**
  106996. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106997. * being tilted forward or back and left or right.
  106998. */
  106999. export class DeviceOrientationCamera extends FreeCamera {
  107000. private _initialQuaternion;
  107001. private _quaternionCache;
  107002. private _tmpDragQuaternion;
  107003. private _disablePointerInputWhenUsingDeviceOrientation;
  107004. /**
  107005. * Creates a new device orientation camera
  107006. * @param name The name of the camera
  107007. * @param position The start position camera
  107008. * @param scene The scene the camera belongs to
  107009. */
  107010. constructor(name: string, position: Vector3, scene: Scene);
  107011. /**
  107012. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107013. */
  107014. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107015. private _dragFactor;
  107016. /**
  107017. * Enabled turning on the y axis when the orientation sensor is active
  107018. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107019. */
  107020. enableHorizontalDragging(dragFactor?: number): void;
  107021. /**
  107022. * Gets the current instance class name ("DeviceOrientationCamera").
  107023. * This helps avoiding instanceof at run time.
  107024. * @returns the class name
  107025. */
  107026. getClassName(): string;
  107027. /**
  107028. * @hidden
  107029. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107030. */
  107031. _checkInputs(): void;
  107032. /**
  107033. * Reset the camera to its default orientation on the specified axis only.
  107034. * @param axis The axis to reset
  107035. */
  107036. resetToCurrentRotation(axis?: Axis): void;
  107037. }
  107038. }
  107039. declare module BABYLON {
  107040. /**
  107041. * Defines supported buttons for XBox360 compatible gamepads
  107042. */
  107043. export enum Xbox360Button {
  107044. /** A */
  107045. A = 0,
  107046. /** B */
  107047. B = 1,
  107048. /** X */
  107049. X = 2,
  107050. /** Y */
  107051. Y = 3,
  107052. /** Start */
  107053. Start = 4,
  107054. /** Back */
  107055. Back = 5,
  107056. /** Left button */
  107057. LB = 6,
  107058. /** Right button */
  107059. RB = 7,
  107060. /** Left stick */
  107061. LeftStick = 8,
  107062. /** Right stick */
  107063. RightStick = 9
  107064. }
  107065. /** Defines values for XBox360 DPad */
  107066. export enum Xbox360Dpad {
  107067. /** Up */
  107068. Up = 0,
  107069. /** Down */
  107070. Down = 1,
  107071. /** Left */
  107072. Left = 2,
  107073. /** Right */
  107074. Right = 3
  107075. }
  107076. /**
  107077. * Defines a XBox360 gamepad
  107078. */
  107079. export class Xbox360Pad extends Gamepad {
  107080. private _leftTrigger;
  107081. private _rightTrigger;
  107082. private _onlefttriggerchanged;
  107083. private _onrighttriggerchanged;
  107084. private _onbuttondown;
  107085. private _onbuttonup;
  107086. private _ondpaddown;
  107087. private _ondpadup;
  107088. /** Observable raised when a button is pressed */
  107089. onButtonDownObservable: Observable<Xbox360Button>;
  107090. /** Observable raised when a button is released */
  107091. onButtonUpObservable: Observable<Xbox360Button>;
  107092. /** Observable raised when a pad is pressed */
  107093. onPadDownObservable: Observable<Xbox360Dpad>;
  107094. /** Observable raised when a pad is released */
  107095. onPadUpObservable: Observable<Xbox360Dpad>;
  107096. private _buttonA;
  107097. private _buttonB;
  107098. private _buttonX;
  107099. private _buttonY;
  107100. private _buttonBack;
  107101. private _buttonStart;
  107102. private _buttonLB;
  107103. private _buttonRB;
  107104. private _buttonLeftStick;
  107105. private _buttonRightStick;
  107106. private _dPadUp;
  107107. private _dPadDown;
  107108. private _dPadLeft;
  107109. private _dPadRight;
  107110. private _isXboxOnePad;
  107111. /**
  107112. * Creates a new XBox360 gamepad object
  107113. * @param id defines the id of this gamepad
  107114. * @param index defines its index
  107115. * @param gamepad defines the internal HTML gamepad object
  107116. * @param xboxOne defines if it is a XBox One gamepad
  107117. */
  107118. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107119. /**
  107120. * Defines the callback to call when left trigger is pressed
  107121. * @param callback defines the callback to use
  107122. */
  107123. onlefttriggerchanged(callback: (value: number) => void): void;
  107124. /**
  107125. * Defines the callback to call when right trigger is pressed
  107126. * @param callback defines the callback to use
  107127. */
  107128. onrighttriggerchanged(callback: (value: number) => void): void;
  107129. /**
  107130. * Gets the left trigger value
  107131. */
  107132. /**
  107133. * Sets the left trigger value
  107134. */
  107135. leftTrigger: number;
  107136. /**
  107137. * Gets the right trigger value
  107138. */
  107139. /**
  107140. * Sets the right trigger value
  107141. */
  107142. rightTrigger: number;
  107143. /**
  107144. * Defines the callback to call when a button is pressed
  107145. * @param callback defines the callback to use
  107146. */
  107147. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107148. /**
  107149. * Defines the callback to call when a button is released
  107150. * @param callback defines the callback to use
  107151. */
  107152. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107153. /**
  107154. * Defines the callback to call when a pad is pressed
  107155. * @param callback defines the callback to use
  107156. */
  107157. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107158. /**
  107159. * Defines the callback to call when a pad is released
  107160. * @param callback defines the callback to use
  107161. */
  107162. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107163. private _setButtonValue;
  107164. private _setDPadValue;
  107165. /**
  107166. * Gets the value of the `A` button
  107167. */
  107168. /**
  107169. * Sets the value of the `A` button
  107170. */
  107171. buttonA: number;
  107172. /**
  107173. * Gets the value of the `B` button
  107174. */
  107175. /**
  107176. * Sets the value of the `B` button
  107177. */
  107178. buttonB: number;
  107179. /**
  107180. * Gets the value of the `X` button
  107181. */
  107182. /**
  107183. * Sets the value of the `X` button
  107184. */
  107185. buttonX: number;
  107186. /**
  107187. * Gets the value of the `Y` button
  107188. */
  107189. /**
  107190. * Sets the value of the `Y` button
  107191. */
  107192. buttonY: number;
  107193. /**
  107194. * Gets the value of the `Start` button
  107195. */
  107196. /**
  107197. * Sets the value of the `Start` button
  107198. */
  107199. buttonStart: number;
  107200. /**
  107201. * Gets the value of the `Back` button
  107202. */
  107203. /**
  107204. * Sets the value of the `Back` button
  107205. */
  107206. buttonBack: number;
  107207. /**
  107208. * Gets the value of the `Left` button
  107209. */
  107210. /**
  107211. * Sets the value of the `Left` button
  107212. */
  107213. buttonLB: number;
  107214. /**
  107215. * Gets the value of the `Right` button
  107216. */
  107217. /**
  107218. * Sets the value of the `Right` button
  107219. */
  107220. buttonRB: number;
  107221. /**
  107222. * Gets the value of the Left joystick
  107223. */
  107224. /**
  107225. * Sets the value of the Left joystick
  107226. */
  107227. buttonLeftStick: number;
  107228. /**
  107229. * Gets the value of the Right joystick
  107230. */
  107231. /**
  107232. * Sets the value of the Right joystick
  107233. */
  107234. buttonRightStick: number;
  107235. /**
  107236. * Gets the value of D-pad up
  107237. */
  107238. /**
  107239. * Sets the value of D-pad up
  107240. */
  107241. dPadUp: number;
  107242. /**
  107243. * Gets the value of D-pad down
  107244. */
  107245. /**
  107246. * Sets the value of D-pad down
  107247. */
  107248. dPadDown: number;
  107249. /**
  107250. * Gets the value of D-pad left
  107251. */
  107252. /**
  107253. * Sets the value of D-pad left
  107254. */
  107255. dPadLeft: number;
  107256. /**
  107257. * Gets the value of D-pad right
  107258. */
  107259. /**
  107260. * Sets the value of D-pad right
  107261. */
  107262. dPadRight: number;
  107263. /**
  107264. * Force the gamepad to synchronize with device values
  107265. */
  107266. update(): void;
  107267. /**
  107268. * Disposes the gamepad
  107269. */
  107270. dispose(): void;
  107271. }
  107272. }
  107273. declare module BABYLON {
  107274. /**
  107275. * Defines supported buttons for DualShock compatible gamepads
  107276. */
  107277. export enum DualShockButton {
  107278. /** Cross */
  107279. Cross = 0,
  107280. /** Circle */
  107281. Circle = 1,
  107282. /** Square */
  107283. Square = 2,
  107284. /** Triangle */
  107285. Triangle = 3,
  107286. /** Options */
  107287. Options = 4,
  107288. /** Share */
  107289. Share = 5,
  107290. /** L1 */
  107291. L1 = 6,
  107292. /** R1 */
  107293. R1 = 7,
  107294. /** Left stick */
  107295. LeftStick = 8,
  107296. /** Right stick */
  107297. RightStick = 9
  107298. }
  107299. /** Defines values for DualShock DPad */
  107300. export enum DualShockDpad {
  107301. /** Up */
  107302. Up = 0,
  107303. /** Down */
  107304. Down = 1,
  107305. /** Left */
  107306. Left = 2,
  107307. /** Right */
  107308. Right = 3
  107309. }
  107310. /**
  107311. * Defines a DualShock gamepad
  107312. */
  107313. export class DualShockPad extends Gamepad {
  107314. private _leftTrigger;
  107315. private _rightTrigger;
  107316. private _onlefttriggerchanged;
  107317. private _onrighttriggerchanged;
  107318. private _onbuttondown;
  107319. private _onbuttonup;
  107320. private _ondpaddown;
  107321. private _ondpadup;
  107322. /** Observable raised when a button is pressed */
  107323. onButtonDownObservable: Observable<DualShockButton>;
  107324. /** Observable raised when a button is released */
  107325. onButtonUpObservable: Observable<DualShockButton>;
  107326. /** Observable raised when a pad is pressed */
  107327. onPadDownObservable: Observable<DualShockDpad>;
  107328. /** Observable raised when a pad is released */
  107329. onPadUpObservable: Observable<DualShockDpad>;
  107330. private _buttonCross;
  107331. private _buttonCircle;
  107332. private _buttonSquare;
  107333. private _buttonTriangle;
  107334. private _buttonShare;
  107335. private _buttonOptions;
  107336. private _buttonL1;
  107337. private _buttonR1;
  107338. private _buttonLeftStick;
  107339. private _buttonRightStick;
  107340. private _dPadUp;
  107341. private _dPadDown;
  107342. private _dPadLeft;
  107343. private _dPadRight;
  107344. /**
  107345. * Creates a new DualShock gamepad object
  107346. * @param id defines the id of this gamepad
  107347. * @param index defines its index
  107348. * @param gamepad defines the internal HTML gamepad object
  107349. */
  107350. constructor(id: string, index: number, gamepad: any);
  107351. /**
  107352. * Defines the callback to call when left trigger is pressed
  107353. * @param callback defines the callback to use
  107354. */
  107355. onlefttriggerchanged(callback: (value: number) => void): void;
  107356. /**
  107357. * Defines the callback to call when right trigger is pressed
  107358. * @param callback defines the callback to use
  107359. */
  107360. onrighttriggerchanged(callback: (value: number) => void): void;
  107361. /**
  107362. * Gets the left trigger value
  107363. */
  107364. /**
  107365. * Sets the left trigger value
  107366. */
  107367. leftTrigger: number;
  107368. /**
  107369. * Gets the right trigger value
  107370. */
  107371. /**
  107372. * Sets the right trigger value
  107373. */
  107374. rightTrigger: number;
  107375. /**
  107376. * Defines the callback to call when a button is pressed
  107377. * @param callback defines the callback to use
  107378. */
  107379. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107380. /**
  107381. * Defines the callback to call when a button is released
  107382. * @param callback defines the callback to use
  107383. */
  107384. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107385. /**
  107386. * Defines the callback to call when a pad is pressed
  107387. * @param callback defines the callback to use
  107388. */
  107389. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107390. /**
  107391. * Defines the callback to call when a pad is released
  107392. * @param callback defines the callback to use
  107393. */
  107394. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107395. private _setButtonValue;
  107396. private _setDPadValue;
  107397. /**
  107398. * Gets the value of the `Cross` button
  107399. */
  107400. /**
  107401. * Sets the value of the `Cross` button
  107402. */
  107403. buttonCross: number;
  107404. /**
  107405. * Gets the value of the `Circle` button
  107406. */
  107407. /**
  107408. * Sets the value of the `Circle` button
  107409. */
  107410. buttonCircle: number;
  107411. /**
  107412. * Gets the value of the `Square` button
  107413. */
  107414. /**
  107415. * Sets the value of the `Square` button
  107416. */
  107417. buttonSquare: number;
  107418. /**
  107419. * Gets the value of the `Triangle` button
  107420. */
  107421. /**
  107422. * Sets the value of the `Triangle` button
  107423. */
  107424. buttonTriangle: number;
  107425. /**
  107426. * Gets the value of the `Options` button
  107427. */
  107428. /**
  107429. * Sets the value of the `Options` button
  107430. */
  107431. buttonOptions: number;
  107432. /**
  107433. * Gets the value of the `Share` button
  107434. */
  107435. /**
  107436. * Sets the value of the `Share` button
  107437. */
  107438. buttonShare: number;
  107439. /**
  107440. * Gets the value of the `L1` button
  107441. */
  107442. /**
  107443. * Sets the value of the `L1` button
  107444. */
  107445. buttonL1: number;
  107446. /**
  107447. * Gets the value of the `R1` button
  107448. */
  107449. /**
  107450. * Sets the value of the `R1` button
  107451. */
  107452. buttonR1: number;
  107453. /**
  107454. * Gets the value of the Left joystick
  107455. */
  107456. /**
  107457. * Sets the value of the Left joystick
  107458. */
  107459. buttonLeftStick: number;
  107460. /**
  107461. * Gets the value of the Right joystick
  107462. */
  107463. /**
  107464. * Sets the value of the Right joystick
  107465. */
  107466. buttonRightStick: number;
  107467. /**
  107468. * Gets the value of D-pad up
  107469. */
  107470. /**
  107471. * Sets the value of D-pad up
  107472. */
  107473. dPadUp: number;
  107474. /**
  107475. * Gets the value of D-pad down
  107476. */
  107477. /**
  107478. * Sets the value of D-pad down
  107479. */
  107480. dPadDown: number;
  107481. /**
  107482. * Gets the value of D-pad left
  107483. */
  107484. /**
  107485. * Sets the value of D-pad left
  107486. */
  107487. dPadLeft: number;
  107488. /**
  107489. * Gets the value of D-pad right
  107490. */
  107491. /**
  107492. * Sets the value of D-pad right
  107493. */
  107494. dPadRight: number;
  107495. /**
  107496. * Force the gamepad to synchronize with device values
  107497. */
  107498. update(): void;
  107499. /**
  107500. * Disposes the gamepad
  107501. */
  107502. dispose(): void;
  107503. }
  107504. }
  107505. declare module BABYLON {
  107506. /**
  107507. * Manager for handling gamepads
  107508. */
  107509. export class GamepadManager {
  107510. private _scene?;
  107511. private _babylonGamepads;
  107512. private _oneGamepadConnected;
  107513. /** @hidden */
  107514. _isMonitoring: boolean;
  107515. private _gamepadEventSupported;
  107516. private _gamepadSupport;
  107517. /**
  107518. * observable to be triggered when the gamepad controller has been connected
  107519. */
  107520. onGamepadConnectedObservable: Observable<Gamepad>;
  107521. /**
  107522. * observable to be triggered when the gamepad controller has been disconnected
  107523. */
  107524. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107525. private _onGamepadConnectedEvent;
  107526. private _onGamepadDisconnectedEvent;
  107527. /**
  107528. * Initializes the gamepad manager
  107529. * @param _scene BabylonJS scene
  107530. */
  107531. constructor(_scene?: Scene | undefined);
  107532. /**
  107533. * The gamepads in the game pad manager
  107534. */
  107535. readonly gamepads: Gamepad[];
  107536. /**
  107537. * Get the gamepad controllers based on type
  107538. * @param type The type of gamepad controller
  107539. * @returns Nullable gamepad
  107540. */
  107541. getGamepadByType(type?: number): Nullable<Gamepad>;
  107542. /**
  107543. * Disposes the gamepad manager
  107544. */
  107545. dispose(): void;
  107546. private _addNewGamepad;
  107547. private _startMonitoringGamepads;
  107548. private _stopMonitoringGamepads;
  107549. /** @hidden */
  107550. _checkGamepadsStatus(): void;
  107551. private _updateGamepadObjects;
  107552. }
  107553. }
  107554. declare module BABYLON {
  107555. interface Scene {
  107556. /** @hidden */
  107557. _gamepadManager: Nullable<GamepadManager>;
  107558. /**
  107559. * Gets the gamepad manager associated with the scene
  107560. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107561. */
  107562. gamepadManager: GamepadManager;
  107563. }
  107564. /**
  107565. * Interface representing a free camera inputs manager
  107566. */
  107567. interface FreeCameraInputsManager {
  107568. /**
  107569. * Adds gamepad input support to the FreeCameraInputsManager.
  107570. * @returns the FreeCameraInputsManager
  107571. */
  107572. addGamepad(): FreeCameraInputsManager;
  107573. }
  107574. /**
  107575. * Interface representing an arc rotate camera inputs manager
  107576. */
  107577. interface ArcRotateCameraInputsManager {
  107578. /**
  107579. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107580. * @returns the camera inputs manager
  107581. */
  107582. addGamepad(): ArcRotateCameraInputsManager;
  107583. }
  107584. /**
  107585. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107586. */
  107587. export class GamepadSystemSceneComponent implements ISceneComponent {
  107588. /**
  107589. * The component name helpfull to identify the component in the list of scene components.
  107590. */
  107591. readonly name: string;
  107592. /**
  107593. * The scene the component belongs to.
  107594. */
  107595. scene: Scene;
  107596. /**
  107597. * Creates a new instance of the component for the given scene
  107598. * @param scene Defines the scene to register the component in
  107599. */
  107600. constructor(scene: Scene);
  107601. /**
  107602. * Registers the component in a given scene
  107603. */
  107604. register(): void;
  107605. /**
  107606. * Rebuilds the elements related to this component in case of
  107607. * context lost for instance.
  107608. */
  107609. rebuild(): void;
  107610. /**
  107611. * Disposes the component and the associated ressources
  107612. */
  107613. dispose(): void;
  107614. private _beforeCameraUpdate;
  107615. }
  107616. }
  107617. declare module BABYLON {
  107618. /**
  107619. * 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,
  107620. * which still works and will still be found in many Playgrounds.
  107621. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107622. */
  107623. export class UniversalCamera extends TouchCamera {
  107624. /**
  107625. * Defines the gamepad rotation sensiblity.
  107626. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107627. */
  107628. gamepadAngularSensibility: number;
  107629. /**
  107630. * Defines the gamepad move sensiblity.
  107631. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107632. */
  107633. gamepadMoveSensibility: number;
  107634. /**
  107635. * 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,
  107636. * which still works and will still be found in many Playgrounds.
  107637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107638. * @param name Define the name of the camera in the scene
  107639. * @param position Define the start position of the camera in the scene
  107640. * @param scene Define the scene the camera belongs to
  107641. */
  107642. constructor(name: string, position: Vector3, scene: Scene);
  107643. /**
  107644. * Gets the current object class name.
  107645. * @return the class name
  107646. */
  107647. getClassName(): string;
  107648. }
  107649. }
  107650. declare module BABYLON {
  107651. /**
  107652. * This represents a FPS type of camera. This is only here for back compat purpose.
  107653. * Please use the UniversalCamera instead as both are identical.
  107654. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107655. */
  107656. export class GamepadCamera extends UniversalCamera {
  107657. /**
  107658. * Instantiates a new Gamepad Camera
  107659. * This represents a FPS type of camera. This is only here for back compat purpose.
  107660. * Please use the UniversalCamera instead as both are identical.
  107661. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107662. * @param name Define the name of the camera in the scene
  107663. * @param position Define the start position of the camera in the scene
  107664. * @param scene Define the scene the camera belongs to
  107665. */
  107666. constructor(name: string, position: Vector3, scene: Scene);
  107667. /**
  107668. * Gets the current object class name.
  107669. * @return the class name
  107670. */
  107671. getClassName(): string;
  107672. }
  107673. }
  107674. declare module BABYLON {
  107675. /** @hidden */
  107676. export var passPixelShader: {
  107677. name: string;
  107678. shader: string;
  107679. };
  107680. }
  107681. declare module BABYLON {
  107682. /** @hidden */
  107683. export var passCubePixelShader: {
  107684. name: string;
  107685. shader: string;
  107686. };
  107687. }
  107688. declare module BABYLON {
  107689. /**
  107690. * PassPostProcess which produces an output the same as it's input
  107691. */
  107692. export class PassPostProcess extends PostProcess {
  107693. /**
  107694. * Creates the PassPostProcess
  107695. * @param name The name of the effect.
  107696. * @param options The required width/height ratio to downsize to before computing the render pass.
  107697. * @param camera The camera to apply the render pass to.
  107698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107699. * @param engine The engine which the post process will be applied. (default: current engine)
  107700. * @param reusable If the post process can be reused on the same frame. (default: false)
  107701. * @param textureType The type of texture to be used when performing the post processing.
  107702. * @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)
  107703. */
  107704. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107705. }
  107706. /**
  107707. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107708. */
  107709. export class PassCubePostProcess extends PostProcess {
  107710. private _face;
  107711. /**
  107712. * Gets or sets the cube face to display.
  107713. * * 0 is +X
  107714. * * 1 is -X
  107715. * * 2 is +Y
  107716. * * 3 is -Y
  107717. * * 4 is +Z
  107718. * * 5 is -Z
  107719. */
  107720. face: number;
  107721. /**
  107722. * Creates the PassCubePostProcess
  107723. * @param name The name of the effect.
  107724. * @param options The required width/height ratio to downsize to before computing the render pass.
  107725. * @param camera The camera to apply the render pass to.
  107726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107727. * @param engine The engine which the post process will be applied. (default: current engine)
  107728. * @param reusable If the post process can be reused on the same frame. (default: false)
  107729. * @param textureType The type of texture to be used when performing the post processing.
  107730. * @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)
  107731. */
  107732. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107733. }
  107734. }
  107735. declare module BABYLON {
  107736. /** @hidden */
  107737. export var anaglyphPixelShader: {
  107738. name: string;
  107739. shader: string;
  107740. };
  107741. }
  107742. declare module BABYLON {
  107743. /**
  107744. * Postprocess used to generate anaglyphic rendering
  107745. */
  107746. export class AnaglyphPostProcess extends PostProcess {
  107747. private _passedProcess;
  107748. /**
  107749. * Creates a new AnaglyphPostProcess
  107750. * @param name defines postprocess name
  107751. * @param options defines creation options or target ratio scale
  107752. * @param rigCameras defines cameras using this postprocess
  107753. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107754. * @param engine defines hosting engine
  107755. * @param reusable defines if the postprocess will be reused multiple times per frame
  107756. */
  107757. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107758. }
  107759. }
  107760. declare module BABYLON {
  107761. /**
  107762. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107763. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107764. */
  107765. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107766. /**
  107767. * Creates a new AnaglyphArcRotateCamera
  107768. * @param name defines camera name
  107769. * @param alpha defines alpha angle (in radians)
  107770. * @param beta defines beta angle (in radians)
  107771. * @param radius defines radius
  107772. * @param target defines camera target
  107773. * @param interaxialDistance defines distance between each color axis
  107774. * @param scene defines the hosting scene
  107775. */
  107776. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107777. /**
  107778. * Gets camera class name
  107779. * @returns AnaglyphArcRotateCamera
  107780. */
  107781. getClassName(): string;
  107782. }
  107783. }
  107784. declare module BABYLON {
  107785. /**
  107786. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107787. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107788. */
  107789. export class AnaglyphFreeCamera extends FreeCamera {
  107790. /**
  107791. * Creates a new AnaglyphFreeCamera
  107792. * @param name defines camera name
  107793. * @param position defines initial position
  107794. * @param interaxialDistance defines distance between each color axis
  107795. * @param scene defines the hosting scene
  107796. */
  107797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107798. /**
  107799. * Gets camera class name
  107800. * @returns AnaglyphFreeCamera
  107801. */
  107802. getClassName(): string;
  107803. }
  107804. }
  107805. declare module BABYLON {
  107806. /**
  107807. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107808. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107809. */
  107810. export class AnaglyphGamepadCamera extends GamepadCamera {
  107811. /**
  107812. * Creates a new AnaglyphGamepadCamera
  107813. * @param name defines camera name
  107814. * @param position defines initial position
  107815. * @param interaxialDistance defines distance between each color axis
  107816. * @param scene defines the hosting scene
  107817. */
  107818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107819. /**
  107820. * Gets camera class name
  107821. * @returns AnaglyphGamepadCamera
  107822. */
  107823. getClassName(): string;
  107824. }
  107825. }
  107826. declare module BABYLON {
  107827. /**
  107828. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107830. */
  107831. export class AnaglyphUniversalCamera extends UniversalCamera {
  107832. /**
  107833. * Creates a new AnaglyphUniversalCamera
  107834. * @param name defines camera name
  107835. * @param position defines initial position
  107836. * @param interaxialDistance defines distance between each color axis
  107837. * @param scene defines the hosting scene
  107838. */
  107839. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107840. /**
  107841. * Gets camera class name
  107842. * @returns AnaglyphUniversalCamera
  107843. */
  107844. getClassName(): string;
  107845. }
  107846. }
  107847. declare module BABYLON {
  107848. /** @hidden */
  107849. export var stereoscopicInterlacePixelShader: {
  107850. name: string;
  107851. shader: string;
  107852. };
  107853. }
  107854. declare module BABYLON {
  107855. /**
  107856. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107857. */
  107858. export class StereoscopicInterlacePostProcess extends PostProcess {
  107859. private _stepSize;
  107860. private _passedProcess;
  107861. /**
  107862. * Initializes a StereoscopicInterlacePostProcess
  107863. * @param name The name of the effect.
  107864. * @param rigCameras The rig cameras to be appled to the post process
  107865. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107867. * @param engine The engine which the post process will be applied. (default: current engine)
  107868. * @param reusable If the post process can be reused on the same frame. (default: false)
  107869. */
  107870. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107871. }
  107872. }
  107873. declare module BABYLON {
  107874. /**
  107875. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107876. * @see http://doc.babylonjs.com/features/cameras
  107877. */
  107878. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107879. /**
  107880. * Creates a new StereoscopicArcRotateCamera
  107881. * @param name defines camera name
  107882. * @param alpha defines alpha angle (in radians)
  107883. * @param beta defines beta angle (in radians)
  107884. * @param radius defines radius
  107885. * @param target defines camera target
  107886. * @param interaxialDistance defines distance between each color axis
  107887. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107888. * @param scene defines the hosting scene
  107889. */
  107890. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107891. /**
  107892. * Gets camera class name
  107893. * @returns StereoscopicArcRotateCamera
  107894. */
  107895. getClassName(): string;
  107896. }
  107897. }
  107898. declare module BABYLON {
  107899. /**
  107900. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107901. * @see http://doc.babylonjs.com/features/cameras
  107902. */
  107903. export class StereoscopicFreeCamera extends FreeCamera {
  107904. /**
  107905. * Creates a new StereoscopicFreeCamera
  107906. * @param name defines camera name
  107907. * @param position defines initial position
  107908. * @param interaxialDistance defines distance between each color axis
  107909. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107910. * @param scene defines the hosting scene
  107911. */
  107912. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107913. /**
  107914. * Gets camera class name
  107915. * @returns StereoscopicFreeCamera
  107916. */
  107917. getClassName(): string;
  107918. }
  107919. }
  107920. declare module BABYLON {
  107921. /**
  107922. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107923. * @see http://doc.babylonjs.com/features/cameras
  107924. */
  107925. export class StereoscopicGamepadCamera extends GamepadCamera {
  107926. /**
  107927. * Creates a new StereoscopicGamepadCamera
  107928. * @param name defines camera name
  107929. * @param position defines initial position
  107930. * @param interaxialDistance defines distance between each color axis
  107931. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107932. * @param scene defines the hosting scene
  107933. */
  107934. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107935. /**
  107936. * Gets camera class name
  107937. * @returns StereoscopicGamepadCamera
  107938. */
  107939. getClassName(): string;
  107940. }
  107941. }
  107942. declare module BABYLON {
  107943. /**
  107944. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107945. * @see http://doc.babylonjs.com/features/cameras
  107946. */
  107947. export class StereoscopicUniversalCamera extends UniversalCamera {
  107948. /**
  107949. * Creates a new StereoscopicUniversalCamera
  107950. * @param name defines camera name
  107951. * @param position defines initial position
  107952. * @param interaxialDistance defines distance between each color axis
  107953. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107954. * @param scene defines the hosting scene
  107955. */
  107956. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107957. /**
  107958. * Gets camera class name
  107959. * @returns StereoscopicUniversalCamera
  107960. */
  107961. getClassName(): string;
  107962. }
  107963. }
  107964. declare module BABYLON {
  107965. /**
  107966. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107967. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107968. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107969. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107970. */
  107971. export class VirtualJoysticksCamera extends FreeCamera {
  107972. /**
  107973. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107974. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107975. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107976. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107977. * @param name Define the name of the camera in the scene
  107978. * @param position Define the start position of the camera in the scene
  107979. * @param scene Define the scene the camera belongs to
  107980. */
  107981. constructor(name: string, position: Vector3, scene: Scene);
  107982. /**
  107983. * Gets the current object class name.
  107984. * @return the class name
  107985. */
  107986. getClassName(): string;
  107987. }
  107988. }
  107989. declare module BABYLON {
  107990. /**
  107991. * This represents all the required metrics to create a VR camera.
  107992. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107993. */
  107994. export class VRCameraMetrics {
  107995. /**
  107996. * Define the horizontal resolution off the screen.
  107997. */
  107998. hResolution: number;
  107999. /**
  108000. * Define the vertical resolution off the screen.
  108001. */
  108002. vResolution: number;
  108003. /**
  108004. * Define the horizontal screen size.
  108005. */
  108006. hScreenSize: number;
  108007. /**
  108008. * Define the vertical screen size.
  108009. */
  108010. vScreenSize: number;
  108011. /**
  108012. * Define the vertical screen center position.
  108013. */
  108014. vScreenCenter: number;
  108015. /**
  108016. * Define the distance of the eyes to the screen.
  108017. */
  108018. eyeToScreenDistance: number;
  108019. /**
  108020. * Define the distance between both lenses
  108021. */
  108022. lensSeparationDistance: number;
  108023. /**
  108024. * Define the distance between both viewer's eyes.
  108025. */
  108026. interpupillaryDistance: number;
  108027. /**
  108028. * Define the distortion factor of the VR postprocess.
  108029. * Please, touch with care.
  108030. */
  108031. distortionK: number[];
  108032. /**
  108033. * Define the chromatic aberration correction factors for the VR post process.
  108034. */
  108035. chromaAbCorrection: number[];
  108036. /**
  108037. * Define the scale factor of the post process.
  108038. * The smaller the better but the slower.
  108039. */
  108040. postProcessScaleFactor: number;
  108041. /**
  108042. * Define an offset for the lens center.
  108043. */
  108044. lensCenterOffset: number;
  108045. /**
  108046. * Define if the current vr camera should compensate the distortion of the lense or not.
  108047. */
  108048. compensateDistortion: boolean;
  108049. /**
  108050. * Defines if multiview should be enabled when rendering (Default: false)
  108051. */
  108052. multiviewEnabled: boolean;
  108053. /**
  108054. * Gets the rendering aspect ratio based on the provided resolutions.
  108055. */
  108056. readonly aspectRatio: number;
  108057. /**
  108058. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108059. */
  108060. readonly aspectRatioFov: number;
  108061. /**
  108062. * @hidden
  108063. */
  108064. readonly leftHMatrix: Matrix;
  108065. /**
  108066. * @hidden
  108067. */
  108068. readonly rightHMatrix: Matrix;
  108069. /**
  108070. * @hidden
  108071. */
  108072. readonly leftPreViewMatrix: Matrix;
  108073. /**
  108074. * @hidden
  108075. */
  108076. readonly rightPreViewMatrix: Matrix;
  108077. /**
  108078. * Get the default VRMetrics based on the most generic setup.
  108079. * @returns the default vr metrics
  108080. */
  108081. static GetDefault(): VRCameraMetrics;
  108082. }
  108083. }
  108084. declare module BABYLON {
  108085. /** @hidden */
  108086. export var vrDistortionCorrectionPixelShader: {
  108087. name: string;
  108088. shader: string;
  108089. };
  108090. }
  108091. declare module BABYLON {
  108092. /**
  108093. * VRDistortionCorrectionPostProcess used for mobile VR
  108094. */
  108095. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108096. private _isRightEye;
  108097. private _distortionFactors;
  108098. private _postProcessScaleFactor;
  108099. private _lensCenterOffset;
  108100. private _scaleIn;
  108101. private _scaleFactor;
  108102. private _lensCenter;
  108103. /**
  108104. * Initializes the VRDistortionCorrectionPostProcess
  108105. * @param name The name of the effect.
  108106. * @param camera The camera to apply the render pass to.
  108107. * @param isRightEye If this is for the right eye distortion
  108108. * @param vrMetrics All the required metrics for the VR camera
  108109. */
  108110. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108111. }
  108112. }
  108113. declare module BABYLON {
  108114. /**
  108115. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108116. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108117. */
  108118. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108119. /**
  108120. * Creates a new VRDeviceOrientationArcRotateCamera
  108121. * @param name defines camera name
  108122. * @param alpha defines the camera rotation along the logitudinal axis
  108123. * @param beta defines the camera rotation along the latitudinal axis
  108124. * @param radius defines the camera distance from its target
  108125. * @param target defines the camera target
  108126. * @param scene defines the scene the camera belongs to
  108127. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108128. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108129. */
  108130. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108131. /**
  108132. * Gets camera class name
  108133. * @returns VRDeviceOrientationArcRotateCamera
  108134. */
  108135. getClassName(): string;
  108136. }
  108137. }
  108138. declare module BABYLON {
  108139. /**
  108140. * Camera used to simulate VR rendering (based on FreeCamera)
  108141. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108142. */
  108143. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108144. /**
  108145. * Creates a new VRDeviceOrientationFreeCamera
  108146. * @param name defines camera name
  108147. * @param position defines the start position of the camera
  108148. * @param scene defines the scene the camera belongs to
  108149. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108150. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108151. */
  108152. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108153. /**
  108154. * Gets camera class name
  108155. * @returns VRDeviceOrientationFreeCamera
  108156. */
  108157. getClassName(): string;
  108158. }
  108159. }
  108160. declare module BABYLON {
  108161. /**
  108162. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108163. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108164. */
  108165. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108166. /**
  108167. * Creates a new VRDeviceOrientationGamepadCamera
  108168. * @param name defines camera name
  108169. * @param position defines the start position of the camera
  108170. * @param scene defines the scene the camera belongs to
  108171. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108172. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108173. */
  108174. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108175. /**
  108176. * Gets camera class name
  108177. * @returns VRDeviceOrientationGamepadCamera
  108178. */
  108179. getClassName(): string;
  108180. }
  108181. }
  108182. declare module BABYLON {
  108183. /**
  108184. * Base class of materials working in push mode in babylon JS
  108185. * @hidden
  108186. */
  108187. export class PushMaterial extends Material {
  108188. protected _activeEffect: Effect;
  108189. protected _normalMatrix: Matrix;
  108190. /**
  108191. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108192. * This means that the material can keep using a previous shader while a new one is being compiled.
  108193. * This is mostly used when shader parallel compilation is supported (true by default)
  108194. */
  108195. allowShaderHotSwapping: boolean;
  108196. constructor(name: string, scene: Scene);
  108197. getEffect(): Effect;
  108198. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108199. /**
  108200. * Binds the given world matrix to the active effect
  108201. *
  108202. * @param world the matrix to bind
  108203. */
  108204. bindOnlyWorldMatrix(world: Matrix): void;
  108205. /**
  108206. * Binds the given normal matrix to the active effect
  108207. *
  108208. * @param normalMatrix the matrix to bind
  108209. */
  108210. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108211. bind(world: Matrix, mesh?: Mesh): void;
  108212. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108213. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108214. }
  108215. }
  108216. declare module BABYLON {
  108217. /**
  108218. * This groups all the flags used to control the materials channel.
  108219. */
  108220. export class MaterialFlags {
  108221. private static _DiffuseTextureEnabled;
  108222. /**
  108223. * Are diffuse textures enabled in the application.
  108224. */
  108225. static DiffuseTextureEnabled: boolean;
  108226. private static _AmbientTextureEnabled;
  108227. /**
  108228. * Are ambient textures enabled in the application.
  108229. */
  108230. static AmbientTextureEnabled: boolean;
  108231. private static _OpacityTextureEnabled;
  108232. /**
  108233. * Are opacity textures enabled in the application.
  108234. */
  108235. static OpacityTextureEnabled: boolean;
  108236. private static _ReflectionTextureEnabled;
  108237. /**
  108238. * Are reflection textures enabled in the application.
  108239. */
  108240. static ReflectionTextureEnabled: boolean;
  108241. private static _EmissiveTextureEnabled;
  108242. /**
  108243. * Are emissive textures enabled in the application.
  108244. */
  108245. static EmissiveTextureEnabled: boolean;
  108246. private static _SpecularTextureEnabled;
  108247. /**
  108248. * Are specular textures enabled in the application.
  108249. */
  108250. static SpecularTextureEnabled: boolean;
  108251. private static _BumpTextureEnabled;
  108252. /**
  108253. * Are bump textures enabled in the application.
  108254. */
  108255. static BumpTextureEnabled: boolean;
  108256. private static _LightmapTextureEnabled;
  108257. /**
  108258. * Are lightmap textures enabled in the application.
  108259. */
  108260. static LightmapTextureEnabled: boolean;
  108261. private static _RefractionTextureEnabled;
  108262. /**
  108263. * Are refraction textures enabled in the application.
  108264. */
  108265. static RefractionTextureEnabled: boolean;
  108266. private static _ColorGradingTextureEnabled;
  108267. /**
  108268. * Are color grading textures enabled in the application.
  108269. */
  108270. static ColorGradingTextureEnabled: boolean;
  108271. private static _FresnelEnabled;
  108272. /**
  108273. * Are fresnels enabled in the application.
  108274. */
  108275. static FresnelEnabled: boolean;
  108276. private static _ClearCoatTextureEnabled;
  108277. /**
  108278. * Are clear coat textures enabled in the application.
  108279. */
  108280. static ClearCoatTextureEnabled: boolean;
  108281. private static _ClearCoatBumpTextureEnabled;
  108282. /**
  108283. * Are clear coat bump textures enabled in the application.
  108284. */
  108285. static ClearCoatBumpTextureEnabled: boolean;
  108286. private static _ClearCoatTintTextureEnabled;
  108287. /**
  108288. * Are clear coat tint textures enabled in the application.
  108289. */
  108290. static ClearCoatTintTextureEnabled: boolean;
  108291. private static _SheenTextureEnabled;
  108292. /**
  108293. * Are sheen textures enabled in the application.
  108294. */
  108295. static SheenTextureEnabled: boolean;
  108296. private static _AnisotropicTextureEnabled;
  108297. /**
  108298. * Are anisotropic textures enabled in the application.
  108299. */
  108300. static AnisotropicTextureEnabled: boolean;
  108301. private static _ThicknessTextureEnabled;
  108302. /**
  108303. * Are thickness textures enabled in the application.
  108304. */
  108305. static ThicknessTextureEnabled: boolean;
  108306. }
  108307. }
  108308. declare module BABYLON {
  108309. /** @hidden */
  108310. export var defaultFragmentDeclaration: {
  108311. name: string;
  108312. shader: string;
  108313. };
  108314. }
  108315. declare module BABYLON {
  108316. /** @hidden */
  108317. export var defaultUboDeclaration: {
  108318. name: string;
  108319. shader: string;
  108320. };
  108321. }
  108322. declare module BABYLON {
  108323. /** @hidden */
  108324. export var lightFragmentDeclaration: {
  108325. name: string;
  108326. shader: string;
  108327. };
  108328. }
  108329. declare module BABYLON {
  108330. /** @hidden */
  108331. export var lightUboDeclaration: {
  108332. name: string;
  108333. shader: string;
  108334. };
  108335. }
  108336. declare module BABYLON {
  108337. /** @hidden */
  108338. export var lightsFragmentFunctions: {
  108339. name: string;
  108340. shader: string;
  108341. };
  108342. }
  108343. declare module BABYLON {
  108344. /** @hidden */
  108345. export var shadowsFragmentFunctions: {
  108346. name: string;
  108347. shader: string;
  108348. };
  108349. }
  108350. declare module BABYLON {
  108351. /** @hidden */
  108352. export var fresnelFunction: {
  108353. name: string;
  108354. shader: string;
  108355. };
  108356. }
  108357. declare module BABYLON {
  108358. /** @hidden */
  108359. export var reflectionFunction: {
  108360. name: string;
  108361. shader: string;
  108362. };
  108363. }
  108364. declare module BABYLON {
  108365. /** @hidden */
  108366. export var bumpFragmentFunctions: {
  108367. name: string;
  108368. shader: string;
  108369. };
  108370. }
  108371. declare module BABYLON {
  108372. /** @hidden */
  108373. export var logDepthDeclaration: {
  108374. name: string;
  108375. shader: string;
  108376. };
  108377. }
  108378. declare module BABYLON {
  108379. /** @hidden */
  108380. export var bumpFragment: {
  108381. name: string;
  108382. shader: string;
  108383. };
  108384. }
  108385. declare module BABYLON {
  108386. /** @hidden */
  108387. export var depthPrePass: {
  108388. name: string;
  108389. shader: string;
  108390. };
  108391. }
  108392. declare module BABYLON {
  108393. /** @hidden */
  108394. export var lightFragment: {
  108395. name: string;
  108396. shader: string;
  108397. };
  108398. }
  108399. declare module BABYLON {
  108400. /** @hidden */
  108401. export var logDepthFragment: {
  108402. name: string;
  108403. shader: string;
  108404. };
  108405. }
  108406. declare module BABYLON {
  108407. /** @hidden */
  108408. export var defaultPixelShader: {
  108409. name: string;
  108410. shader: string;
  108411. };
  108412. }
  108413. declare module BABYLON {
  108414. /** @hidden */
  108415. export var defaultVertexDeclaration: {
  108416. name: string;
  108417. shader: string;
  108418. };
  108419. }
  108420. declare module BABYLON {
  108421. /** @hidden */
  108422. export var bumpVertexDeclaration: {
  108423. name: string;
  108424. shader: string;
  108425. };
  108426. }
  108427. declare module BABYLON {
  108428. /** @hidden */
  108429. export var bumpVertex: {
  108430. name: string;
  108431. shader: string;
  108432. };
  108433. }
  108434. declare module BABYLON {
  108435. /** @hidden */
  108436. export var fogVertex: {
  108437. name: string;
  108438. shader: string;
  108439. };
  108440. }
  108441. declare module BABYLON {
  108442. /** @hidden */
  108443. export var shadowsVertex: {
  108444. name: string;
  108445. shader: string;
  108446. };
  108447. }
  108448. declare module BABYLON {
  108449. /** @hidden */
  108450. export var pointCloudVertex: {
  108451. name: string;
  108452. shader: string;
  108453. };
  108454. }
  108455. declare module BABYLON {
  108456. /** @hidden */
  108457. export var logDepthVertex: {
  108458. name: string;
  108459. shader: string;
  108460. };
  108461. }
  108462. declare module BABYLON {
  108463. /** @hidden */
  108464. export var defaultVertexShader: {
  108465. name: string;
  108466. shader: string;
  108467. };
  108468. }
  108469. declare module BABYLON {
  108470. /** @hidden */
  108471. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108472. MAINUV1: boolean;
  108473. MAINUV2: boolean;
  108474. DIFFUSE: boolean;
  108475. DIFFUSEDIRECTUV: number;
  108476. AMBIENT: boolean;
  108477. AMBIENTDIRECTUV: number;
  108478. OPACITY: boolean;
  108479. OPACITYDIRECTUV: number;
  108480. OPACITYRGB: boolean;
  108481. REFLECTION: boolean;
  108482. EMISSIVE: boolean;
  108483. EMISSIVEDIRECTUV: number;
  108484. SPECULAR: boolean;
  108485. SPECULARDIRECTUV: number;
  108486. BUMP: boolean;
  108487. BUMPDIRECTUV: number;
  108488. PARALLAX: boolean;
  108489. PARALLAXOCCLUSION: boolean;
  108490. SPECULAROVERALPHA: boolean;
  108491. CLIPPLANE: boolean;
  108492. CLIPPLANE2: boolean;
  108493. CLIPPLANE3: boolean;
  108494. CLIPPLANE4: boolean;
  108495. ALPHATEST: boolean;
  108496. DEPTHPREPASS: boolean;
  108497. ALPHAFROMDIFFUSE: boolean;
  108498. POINTSIZE: boolean;
  108499. FOG: boolean;
  108500. SPECULARTERM: boolean;
  108501. DIFFUSEFRESNEL: boolean;
  108502. OPACITYFRESNEL: boolean;
  108503. REFLECTIONFRESNEL: boolean;
  108504. REFRACTIONFRESNEL: boolean;
  108505. EMISSIVEFRESNEL: boolean;
  108506. FRESNEL: boolean;
  108507. NORMAL: boolean;
  108508. UV1: boolean;
  108509. UV2: boolean;
  108510. VERTEXCOLOR: boolean;
  108511. VERTEXALPHA: boolean;
  108512. NUM_BONE_INFLUENCERS: number;
  108513. BonesPerMesh: number;
  108514. BONETEXTURE: boolean;
  108515. INSTANCES: boolean;
  108516. GLOSSINESS: boolean;
  108517. ROUGHNESS: boolean;
  108518. EMISSIVEASILLUMINATION: boolean;
  108519. LINKEMISSIVEWITHDIFFUSE: boolean;
  108520. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108521. LIGHTMAP: boolean;
  108522. LIGHTMAPDIRECTUV: number;
  108523. OBJECTSPACE_NORMALMAP: boolean;
  108524. USELIGHTMAPASSHADOWMAP: boolean;
  108525. REFLECTIONMAP_3D: boolean;
  108526. REFLECTIONMAP_SPHERICAL: boolean;
  108527. REFLECTIONMAP_PLANAR: boolean;
  108528. REFLECTIONMAP_CUBIC: boolean;
  108529. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108530. REFLECTIONMAP_PROJECTION: boolean;
  108531. REFLECTIONMAP_SKYBOX: boolean;
  108532. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108533. REFLECTIONMAP_EXPLICIT: boolean;
  108534. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108535. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108536. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108537. INVERTCUBICMAP: boolean;
  108538. LOGARITHMICDEPTH: boolean;
  108539. REFRACTION: boolean;
  108540. REFRACTIONMAP_3D: boolean;
  108541. REFLECTIONOVERALPHA: boolean;
  108542. TWOSIDEDLIGHTING: boolean;
  108543. SHADOWFLOAT: boolean;
  108544. MORPHTARGETS: boolean;
  108545. MORPHTARGETS_NORMAL: boolean;
  108546. MORPHTARGETS_TANGENT: boolean;
  108547. MORPHTARGETS_UV: boolean;
  108548. NUM_MORPH_INFLUENCERS: number;
  108549. NONUNIFORMSCALING: boolean;
  108550. PREMULTIPLYALPHA: boolean;
  108551. IMAGEPROCESSING: boolean;
  108552. VIGNETTE: boolean;
  108553. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108554. VIGNETTEBLENDMODEOPAQUE: boolean;
  108555. TONEMAPPING: boolean;
  108556. TONEMAPPING_ACES: boolean;
  108557. CONTRAST: boolean;
  108558. COLORCURVES: boolean;
  108559. COLORGRADING: boolean;
  108560. COLORGRADING3D: boolean;
  108561. SAMPLER3DGREENDEPTH: boolean;
  108562. SAMPLER3DBGRMAP: boolean;
  108563. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108564. MULTIVIEW: boolean;
  108565. /**
  108566. * If the reflection texture on this material is in linear color space
  108567. * @hidden
  108568. */
  108569. IS_REFLECTION_LINEAR: boolean;
  108570. /**
  108571. * If the refraction texture on this material is in linear color space
  108572. * @hidden
  108573. */
  108574. IS_REFRACTION_LINEAR: boolean;
  108575. EXPOSURE: boolean;
  108576. constructor();
  108577. setReflectionMode(modeToEnable: string): void;
  108578. }
  108579. /**
  108580. * This is the default material used in Babylon. It is the best trade off between quality
  108581. * and performances.
  108582. * @see http://doc.babylonjs.com/babylon101/materials
  108583. */
  108584. export class StandardMaterial extends PushMaterial {
  108585. private _diffuseTexture;
  108586. /**
  108587. * The basic texture of the material as viewed under a light.
  108588. */
  108589. diffuseTexture: Nullable<BaseTexture>;
  108590. private _ambientTexture;
  108591. /**
  108592. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108593. */
  108594. ambientTexture: Nullable<BaseTexture>;
  108595. private _opacityTexture;
  108596. /**
  108597. * Define the transparency of the material from a texture.
  108598. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108599. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108600. */
  108601. opacityTexture: Nullable<BaseTexture>;
  108602. private _reflectionTexture;
  108603. /**
  108604. * Define the texture used to display the reflection.
  108605. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108606. */
  108607. reflectionTexture: Nullable<BaseTexture>;
  108608. private _emissiveTexture;
  108609. /**
  108610. * Define texture of the material as if self lit.
  108611. * This will be mixed in the final result even in the absence of light.
  108612. */
  108613. emissiveTexture: Nullable<BaseTexture>;
  108614. private _specularTexture;
  108615. /**
  108616. * Define how the color and intensity of the highlight given by the light in the material.
  108617. */
  108618. specularTexture: Nullable<BaseTexture>;
  108619. private _bumpTexture;
  108620. /**
  108621. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108622. * 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.
  108623. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108624. */
  108625. bumpTexture: Nullable<BaseTexture>;
  108626. private _lightmapTexture;
  108627. /**
  108628. * Complex lighting can be computationally expensive to compute at runtime.
  108629. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108630. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108631. */
  108632. lightmapTexture: Nullable<BaseTexture>;
  108633. private _refractionTexture;
  108634. /**
  108635. * Define the texture used to display the refraction.
  108636. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108637. */
  108638. refractionTexture: Nullable<BaseTexture>;
  108639. /**
  108640. * The color of the material lit by the environmental background lighting.
  108641. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108642. */
  108643. ambientColor: Color3;
  108644. /**
  108645. * The basic color of the material as viewed under a light.
  108646. */
  108647. diffuseColor: Color3;
  108648. /**
  108649. * Define how the color and intensity of the highlight given by the light in the material.
  108650. */
  108651. specularColor: Color3;
  108652. /**
  108653. * Define the color of the material as if self lit.
  108654. * This will be mixed in the final result even in the absence of light.
  108655. */
  108656. emissiveColor: Color3;
  108657. /**
  108658. * Defines how sharp are the highlights in the material.
  108659. * The bigger the value the sharper giving a more glossy feeling to the result.
  108660. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108661. */
  108662. specularPower: number;
  108663. private _useAlphaFromDiffuseTexture;
  108664. /**
  108665. * Does the transparency come from the diffuse texture alpha channel.
  108666. */
  108667. useAlphaFromDiffuseTexture: boolean;
  108668. private _useEmissiveAsIllumination;
  108669. /**
  108670. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108671. */
  108672. useEmissiveAsIllumination: boolean;
  108673. private _linkEmissiveWithDiffuse;
  108674. /**
  108675. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108676. * the emissive level when the final color is close to one.
  108677. */
  108678. linkEmissiveWithDiffuse: boolean;
  108679. private _useSpecularOverAlpha;
  108680. /**
  108681. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108682. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108683. */
  108684. useSpecularOverAlpha: boolean;
  108685. private _useReflectionOverAlpha;
  108686. /**
  108687. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108688. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108689. */
  108690. useReflectionOverAlpha: boolean;
  108691. private _disableLighting;
  108692. /**
  108693. * Does lights from the scene impacts this material.
  108694. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108695. */
  108696. disableLighting: boolean;
  108697. private _useObjectSpaceNormalMap;
  108698. /**
  108699. * Allows using an object space normal map (instead of tangent space).
  108700. */
  108701. useObjectSpaceNormalMap: boolean;
  108702. private _useParallax;
  108703. /**
  108704. * Is parallax enabled or not.
  108705. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108706. */
  108707. useParallax: boolean;
  108708. private _useParallaxOcclusion;
  108709. /**
  108710. * Is parallax occlusion enabled or not.
  108711. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108712. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108713. */
  108714. useParallaxOcclusion: boolean;
  108715. /**
  108716. * 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.
  108717. */
  108718. parallaxScaleBias: number;
  108719. private _roughness;
  108720. /**
  108721. * Helps to define how blurry the reflections should appears in the material.
  108722. */
  108723. roughness: number;
  108724. /**
  108725. * In case of refraction, define the value of the index of refraction.
  108726. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108727. */
  108728. indexOfRefraction: number;
  108729. /**
  108730. * Invert the refraction texture alongside the y axis.
  108731. * It can be useful with procedural textures or probe for instance.
  108732. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108733. */
  108734. invertRefractionY: boolean;
  108735. /**
  108736. * Defines the alpha limits in alpha test mode.
  108737. */
  108738. alphaCutOff: number;
  108739. private _useLightmapAsShadowmap;
  108740. /**
  108741. * In case of light mapping, define whether the map contains light or shadow informations.
  108742. */
  108743. useLightmapAsShadowmap: boolean;
  108744. private _diffuseFresnelParameters;
  108745. /**
  108746. * Define the diffuse fresnel parameters of the material.
  108747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108748. */
  108749. diffuseFresnelParameters: FresnelParameters;
  108750. private _opacityFresnelParameters;
  108751. /**
  108752. * Define the opacity fresnel parameters of the material.
  108753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108754. */
  108755. opacityFresnelParameters: FresnelParameters;
  108756. private _reflectionFresnelParameters;
  108757. /**
  108758. * Define the reflection fresnel parameters of the material.
  108759. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108760. */
  108761. reflectionFresnelParameters: FresnelParameters;
  108762. private _refractionFresnelParameters;
  108763. /**
  108764. * Define the refraction fresnel parameters of the material.
  108765. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108766. */
  108767. refractionFresnelParameters: FresnelParameters;
  108768. private _emissiveFresnelParameters;
  108769. /**
  108770. * Define the emissive fresnel parameters of the material.
  108771. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108772. */
  108773. emissiveFresnelParameters: FresnelParameters;
  108774. private _useReflectionFresnelFromSpecular;
  108775. /**
  108776. * If true automatically deducts the fresnels values from the material specularity.
  108777. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108778. */
  108779. useReflectionFresnelFromSpecular: boolean;
  108780. private _useGlossinessFromSpecularMapAlpha;
  108781. /**
  108782. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108783. */
  108784. useGlossinessFromSpecularMapAlpha: boolean;
  108785. private _maxSimultaneousLights;
  108786. /**
  108787. * Defines the maximum number of lights that can be used in the material
  108788. */
  108789. maxSimultaneousLights: number;
  108790. private _invertNormalMapX;
  108791. /**
  108792. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108793. */
  108794. invertNormalMapX: boolean;
  108795. private _invertNormalMapY;
  108796. /**
  108797. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108798. */
  108799. invertNormalMapY: boolean;
  108800. private _twoSidedLighting;
  108801. /**
  108802. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108803. */
  108804. twoSidedLighting: boolean;
  108805. /**
  108806. * Default configuration related to image processing available in the standard Material.
  108807. */
  108808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108809. /**
  108810. * Gets the image processing configuration used either in this material.
  108811. */
  108812. /**
  108813. * Sets the Default image processing configuration used either in the this material.
  108814. *
  108815. * If sets to null, the scene one is in use.
  108816. */
  108817. imageProcessingConfiguration: ImageProcessingConfiguration;
  108818. /**
  108819. * Keep track of the image processing observer to allow dispose and replace.
  108820. */
  108821. private _imageProcessingObserver;
  108822. /**
  108823. * Attaches a new image processing configuration to the Standard Material.
  108824. * @param configuration
  108825. */
  108826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108827. /**
  108828. * Gets wether the color curves effect is enabled.
  108829. */
  108830. /**
  108831. * Sets wether the color curves effect is enabled.
  108832. */
  108833. cameraColorCurvesEnabled: boolean;
  108834. /**
  108835. * Gets wether the color grading effect is enabled.
  108836. */
  108837. /**
  108838. * Gets wether the color grading effect is enabled.
  108839. */
  108840. cameraColorGradingEnabled: boolean;
  108841. /**
  108842. * Gets wether tonemapping is enabled or not.
  108843. */
  108844. /**
  108845. * Sets wether tonemapping is enabled or not
  108846. */
  108847. cameraToneMappingEnabled: boolean;
  108848. /**
  108849. * The camera exposure used on this material.
  108850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108851. * This corresponds to a photographic exposure.
  108852. */
  108853. /**
  108854. * The camera exposure used on this material.
  108855. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108856. * This corresponds to a photographic exposure.
  108857. */
  108858. cameraExposure: number;
  108859. /**
  108860. * Gets The camera contrast used on this material.
  108861. */
  108862. /**
  108863. * Sets The camera contrast used on this material.
  108864. */
  108865. cameraContrast: number;
  108866. /**
  108867. * Gets the Color Grading 2D Lookup Texture.
  108868. */
  108869. /**
  108870. * Sets the Color Grading 2D Lookup Texture.
  108871. */
  108872. cameraColorGradingTexture: Nullable<BaseTexture>;
  108873. /**
  108874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108876. * 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;
  108877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108878. */
  108879. /**
  108880. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108881. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108882. * 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;
  108883. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108884. */
  108885. cameraColorCurves: Nullable<ColorCurves>;
  108886. /**
  108887. * Custom callback helping to override the default shader used in the material.
  108888. */
  108889. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108890. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108891. protected _worldViewProjectionMatrix: Matrix;
  108892. protected _globalAmbientColor: Color3;
  108893. protected _useLogarithmicDepth: boolean;
  108894. protected _rebuildInParallel: boolean;
  108895. /**
  108896. * Instantiates a new standard material.
  108897. * This is the default material used in Babylon. It is the best trade off between quality
  108898. * and performances.
  108899. * @see http://doc.babylonjs.com/babylon101/materials
  108900. * @param name Define the name of the material in the scene
  108901. * @param scene Define the scene the material belong to
  108902. */
  108903. constructor(name: string, scene: Scene);
  108904. /**
  108905. * Gets a boolean indicating that current material needs to register RTT
  108906. */
  108907. readonly hasRenderTargetTextures: boolean;
  108908. /**
  108909. * Gets the current class name of the material e.g. "StandardMaterial"
  108910. * Mainly use in serialization.
  108911. * @returns the class name
  108912. */
  108913. getClassName(): string;
  108914. /**
  108915. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108916. * You can try switching to logarithmic depth.
  108917. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108918. */
  108919. useLogarithmicDepth: boolean;
  108920. /**
  108921. * Specifies if the material will require alpha blending
  108922. * @returns a boolean specifying if alpha blending is needed
  108923. */
  108924. needAlphaBlending(): boolean;
  108925. /**
  108926. * Specifies if this material should be rendered in alpha test mode
  108927. * @returns a boolean specifying if an alpha test is needed.
  108928. */
  108929. needAlphaTesting(): boolean;
  108930. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108931. /**
  108932. * Get the texture used for alpha test purpose.
  108933. * @returns the diffuse texture in case of the standard material.
  108934. */
  108935. getAlphaTestTexture(): Nullable<BaseTexture>;
  108936. /**
  108937. * Get if the submesh is ready to be used and all its information available.
  108938. * Child classes can use it to update shaders
  108939. * @param mesh defines the mesh to check
  108940. * @param subMesh defines which submesh to check
  108941. * @param useInstances specifies that instances should be used
  108942. * @returns a boolean indicating that the submesh is ready or not
  108943. */
  108944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108945. /**
  108946. * Builds the material UBO layouts.
  108947. * Used internally during the effect preparation.
  108948. */
  108949. buildUniformLayout(): void;
  108950. /**
  108951. * Unbinds the material from the mesh
  108952. */
  108953. unbind(): void;
  108954. /**
  108955. * Binds the submesh to this material by preparing the effect and shader to draw
  108956. * @param world defines the world transformation matrix
  108957. * @param mesh defines the mesh containing the submesh
  108958. * @param subMesh defines the submesh to bind the material to
  108959. */
  108960. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108961. /**
  108962. * Get the list of animatables in the material.
  108963. * @returns the list of animatables object used in the material
  108964. */
  108965. getAnimatables(): IAnimatable[];
  108966. /**
  108967. * Gets the active textures from the material
  108968. * @returns an array of textures
  108969. */
  108970. getActiveTextures(): BaseTexture[];
  108971. /**
  108972. * Specifies if the material uses a texture
  108973. * @param texture defines the texture to check against the material
  108974. * @returns a boolean specifying if the material uses the texture
  108975. */
  108976. hasTexture(texture: BaseTexture): boolean;
  108977. /**
  108978. * Disposes the material
  108979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108981. */
  108982. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108983. /**
  108984. * Makes a duplicate of the material, and gives it a new name
  108985. * @param name defines the new name for the duplicated material
  108986. * @returns the cloned material
  108987. */
  108988. clone(name: string): StandardMaterial;
  108989. /**
  108990. * Serializes this material in a JSON representation
  108991. * @returns the serialized material object
  108992. */
  108993. serialize(): any;
  108994. /**
  108995. * Creates a standard material from parsed material data
  108996. * @param source defines the JSON representation of the material
  108997. * @param scene defines the hosting scene
  108998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108999. * @returns a new standard material
  109000. */
  109001. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109002. /**
  109003. * Are diffuse textures enabled in the application.
  109004. */
  109005. static DiffuseTextureEnabled: boolean;
  109006. /**
  109007. * Are ambient textures enabled in the application.
  109008. */
  109009. static AmbientTextureEnabled: boolean;
  109010. /**
  109011. * Are opacity textures enabled in the application.
  109012. */
  109013. static OpacityTextureEnabled: boolean;
  109014. /**
  109015. * Are reflection textures enabled in the application.
  109016. */
  109017. static ReflectionTextureEnabled: boolean;
  109018. /**
  109019. * Are emissive textures enabled in the application.
  109020. */
  109021. static EmissiveTextureEnabled: boolean;
  109022. /**
  109023. * Are specular textures enabled in the application.
  109024. */
  109025. static SpecularTextureEnabled: boolean;
  109026. /**
  109027. * Are bump textures enabled in the application.
  109028. */
  109029. static BumpTextureEnabled: boolean;
  109030. /**
  109031. * Are lightmap textures enabled in the application.
  109032. */
  109033. static LightmapTextureEnabled: boolean;
  109034. /**
  109035. * Are refraction textures enabled in the application.
  109036. */
  109037. static RefractionTextureEnabled: boolean;
  109038. /**
  109039. * Are color grading textures enabled in the application.
  109040. */
  109041. static ColorGradingTextureEnabled: boolean;
  109042. /**
  109043. * Are fresnels enabled in the application.
  109044. */
  109045. static FresnelEnabled: boolean;
  109046. }
  109047. }
  109048. declare module BABYLON {
  109049. /** @hidden */
  109050. export var imageProcessingPixelShader: {
  109051. name: string;
  109052. shader: string;
  109053. };
  109054. }
  109055. declare module BABYLON {
  109056. /**
  109057. * ImageProcessingPostProcess
  109058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109059. */
  109060. export class ImageProcessingPostProcess extends PostProcess {
  109061. /**
  109062. * Default configuration related to image processing available in the PBR Material.
  109063. */
  109064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109065. /**
  109066. * Gets the image processing configuration used either in this material.
  109067. */
  109068. /**
  109069. * Sets the Default image processing configuration used either in the this material.
  109070. *
  109071. * If sets to null, the scene one is in use.
  109072. */
  109073. imageProcessingConfiguration: ImageProcessingConfiguration;
  109074. /**
  109075. * Keep track of the image processing observer to allow dispose and replace.
  109076. */
  109077. private _imageProcessingObserver;
  109078. /**
  109079. * Attaches a new image processing configuration to the PBR Material.
  109080. * @param configuration
  109081. */
  109082. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109083. /**
  109084. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109085. */
  109086. /**
  109087. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109088. */
  109089. colorCurves: Nullable<ColorCurves>;
  109090. /**
  109091. * Gets wether the color curves effect is enabled.
  109092. */
  109093. /**
  109094. * Sets wether the color curves effect is enabled.
  109095. */
  109096. colorCurvesEnabled: boolean;
  109097. /**
  109098. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109099. */
  109100. /**
  109101. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109102. */
  109103. colorGradingTexture: Nullable<BaseTexture>;
  109104. /**
  109105. * Gets wether the color grading effect is enabled.
  109106. */
  109107. /**
  109108. * Gets wether the color grading effect is enabled.
  109109. */
  109110. colorGradingEnabled: boolean;
  109111. /**
  109112. * Gets exposure used in the effect.
  109113. */
  109114. /**
  109115. * Sets exposure used in the effect.
  109116. */
  109117. exposure: number;
  109118. /**
  109119. * Gets wether tonemapping is enabled or not.
  109120. */
  109121. /**
  109122. * Sets wether tonemapping is enabled or not
  109123. */
  109124. toneMappingEnabled: boolean;
  109125. /**
  109126. * Gets the type of tone mapping effect.
  109127. */
  109128. /**
  109129. * Sets the type of tone mapping effect.
  109130. */
  109131. toneMappingType: number;
  109132. /**
  109133. * Gets contrast used in the effect.
  109134. */
  109135. /**
  109136. * Sets contrast used in the effect.
  109137. */
  109138. contrast: number;
  109139. /**
  109140. * Gets Vignette stretch size.
  109141. */
  109142. /**
  109143. * Sets Vignette stretch size.
  109144. */
  109145. vignetteStretch: number;
  109146. /**
  109147. * Gets Vignette centre X Offset.
  109148. */
  109149. /**
  109150. * Sets Vignette centre X Offset.
  109151. */
  109152. vignetteCentreX: number;
  109153. /**
  109154. * Gets Vignette centre Y Offset.
  109155. */
  109156. /**
  109157. * Sets Vignette centre Y Offset.
  109158. */
  109159. vignetteCentreY: number;
  109160. /**
  109161. * Gets Vignette weight or intensity of the vignette effect.
  109162. */
  109163. /**
  109164. * Sets Vignette weight or intensity of the vignette effect.
  109165. */
  109166. vignetteWeight: number;
  109167. /**
  109168. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109169. * if vignetteEnabled is set to true.
  109170. */
  109171. /**
  109172. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109173. * if vignetteEnabled is set to true.
  109174. */
  109175. vignetteColor: Color4;
  109176. /**
  109177. * Gets Camera field of view used by the Vignette effect.
  109178. */
  109179. /**
  109180. * Sets Camera field of view used by the Vignette effect.
  109181. */
  109182. vignetteCameraFov: number;
  109183. /**
  109184. * Gets the vignette blend mode allowing different kind of effect.
  109185. */
  109186. /**
  109187. * Sets the vignette blend mode allowing different kind of effect.
  109188. */
  109189. vignetteBlendMode: number;
  109190. /**
  109191. * Gets wether the vignette effect is enabled.
  109192. */
  109193. /**
  109194. * Sets wether the vignette effect is enabled.
  109195. */
  109196. vignetteEnabled: boolean;
  109197. private _fromLinearSpace;
  109198. /**
  109199. * Gets wether the input of the processing is in Gamma or Linear Space.
  109200. */
  109201. /**
  109202. * Sets wether the input of the processing is in Gamma or Linear Space.
  109203. */
  109204. fromLinearSpace: boolean;
  109205. /**
  109206. * Defines cache preventing GC.
  109207. */
  109208. private _defines;
  109209. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109210. /**
  109211. * "ImageProcessingPostProcess"
  109212. * @returns "ImageProcessingPostProcess"
  109213. */
  109214. getClassName(): string;
  109215. protected _updateParameters(): void;
  109216. dispose(camera?: Camera): void;
  109217. }
  109218. }
  109219. declare module BABYLON {
  109220. /**
  109221. * Class containing static functions to help procedurally build meshes
  109222. */
  109223. export class GroundBuilder {
  109224. /**
  109225. * Creates a ground mesh
  109226. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109227. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109229. * @param name defines the name of the mesh
  109230. * @param options defines the options used to create the mesh
  109231. * @param scene defines the hosting scene
  109232. * @returns the ground mesh
  109233. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109234. */
  109235. static CreateGround(name: string, options: {
  109236. width?: number;
  109237. height?: number;
  109238. subdivisions?: number;
  109239. subdivisionsX?: number;
  109240. subdivisionsY?: number;
  109241. updatable?: boolean;
  109242. }, scene: any): Mesh;
  109243. /**
  109244. * Creates a tiled ground mesh
  109245. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109246. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109247. * * 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
  109248. * * 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
  109249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109250. * @param name defines the name of the mesh
  109251. * @param options defines the options used to create the mesh
  109252. * @param scene defines the hosting scene
  109253. * @returns the tiled ground mesh
  109254. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109255. */
  109256. static CreateTiledGround(name: string, options: {
  109257. xmin: number;
  109258. zmin: number;
  109259. xmax: number;
  109260. zmax: number;
  109261. subdivisions?: {
  109262. w: number;
  109263. h: number;
  109264. };
  109265. precision?: {
  109266. w: number;
  109267. h: number;
  109268. };
  109269. updatable?: boolean;
  109270. }, scene?: Nullable<Scene>): Mesh;
  109271. /**
  109272. * Creates a ground mesh from a height map
  109273. * * The parameter `url` sets the URL of the height map image resource.
  109274. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109275. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109276. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109277. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109278. * * 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.
  109279. * * 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).
  109280. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109282. * @param name defines the name of the mesh
  109283. * @param url defines the url to the height map
  109284. * @param options defines the options used to create the mesh
  109285. * @param scene defines the hosting scene
  109286. * @returns the ground mesh
  109287. * @see https://doc.babylonjs.com/babylon101/height_map
  109288. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109289. */
  109290. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109291. width?: number;
  109292. height?: number;
  109293. subdivisions?: number;
  109294. minHeight?: number;
  109295. maxHeight?: number;
  109296. colorFilter?: Color3;
  109297. alphaFilter?: number;
  109298. updatable?: boolean;
  109299. onReady?: (mesh: GroundMesh) => void;
  109300. }, scene?: Nullable<Scene>): GroundMesh;
  109301. }
  109302. }
  109303. declare module BABYLON {
  109304. /**
  109305. * Class containing static functions to help procedurally build meshes
  109306. */
  109307. export class TorusBuilder {
  109308. /**
  109309. * Creates a torus mesh
  109310. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109311. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109312. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109316. * @param name defines the name of the mesh
  109317. * @param options defines the options used to create the mesh
  109318. * @param scene defines the hosting scene
  109319. * @returns the torus mesh
  109320. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109321. */
  109322. static CreateTorus(name: string, options: {
  109323. diameter?: number;
  109324. thickness?: number;
  109325. tessellation?: number;
  109326. updatable?: boolean;
  109327. sideOrientation?: number;
  109328. frontUVs?: Vector4;
  109329. backUVs?: Vector4;
  109330. }, scene: any): Mesh;
  109331. }
  109332. }
  109333. declare module BABYLON {
  109334. /**
  109335. * Class containing static functions to help procedurally build meshes
  109336. */
  109337. export class CylinderBuilder {
  109338. /**
  109339. * Creates a cylinder or a cone mesh
  109340. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109341. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109342. * * 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.
  109343. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109344. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109345. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109346. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109347. * * 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).
  109348. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109349. * * 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).
  109350. * * 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
  109351. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109352. * * 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
  109353. * * 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.
  109354. * * If `enclose` is false, a ring surface is one element.
  109355. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109356. * * 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
  109357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109360. * @param name defines the name of the mesh
  109361. * @param options defines the options used to create the mesh
  109362. * @param scene defines the hosting scene
  109363. * @returns the cylinder mesh
  109364. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109365. */
  109366. static CreateCylinder(name: string, options: {
  109367. height?: number;
  109368. diameterTop?: number;
  109369. diameterBottom?: number;
  109370. diameter?: number;
  109371. tessellation?: number;
  109372. subdivisions?: number;
  109373. arc?: number;
  109374. faceColors?: Color4[];
  109375. faceUV?: Vector4[];
  109376. updatable?: boolean;
  109377. hasRings?: boolean;
  109378. enclose?: boolean;
  109379. cap?: number;
  109380. sideOrientation?: number;
  109381. frontUVs?: Vector4;
  109382. backUVs?: Vector4;
  109383. }, scene: any): Mesh;
  109384. }
  109385. }
  109386. declare module BABYLON {
  109387. /**
  109388. * Options to modify the vr teleportation behavior.
  109389. */
  109390. export interface VRTeleportationOptions {
  109391. /**
  109392. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109393. */
  109394. floorMeshName?: string;
  109395. /**
  109396. * A list of meshes to be used as the teleportation floor. (default: empty)
  109397. */
  109398. floorMeshes?: Mesh[];
  109399. }
  109400. /**
  109401. * Options to modify the vr experience helper's behavior.
  109402. */
  109403. export interface VRExperienceHelperOptions extends WebVROptions {
  109404. /**
  109405. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109406. */
  109407. createDeviceOrientationCamera?: boolean;
  109408. /**
  109409. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109410. */
  109411. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109412. /**
  109413. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109414. */
  109415. laserToggle?: boolean;
  109416. /**
  109417. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109418. */
  109419. floorMeshes?: Mesh[];
  109420. /**
  109421. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109422. */
  109423. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109424. }
  109425. /**
  109426. * Event containing information after VR has been entered
  109427. */
  109428. export class OnAfterEnteringVRObservableEvent {
  109429. /**
  109430. * If entering vr was successful
  109431. */
  109432. success: boolean;
  109433. }
  109434. /**
  109435. * Helps to quickly add VR support to an existing scene.
  109436. * See http://doc.babylonjs.com/how_to/webvr_helper
  109437. */
  109438. export class VRExperienceHelper {
  109439. /** Options to modify the vr experience helper's behavior. */
  109440. webVROptions: VRExperienceHelperOptions;
  109441. private _scene;
  109442. private _position;
  109443. private _btnVR;
  109444. private _btnVRDisplayed;
  109445. private _webVRsupported;
  109446. private _webVRready;
  109447. private _webVRrequesting;
  109448. private _webVRpresenting;
  109449. private _hasEnteredVR;
  109450. private _fullscreenVRpresenting;
  109451. private _inputElement;
  109452. private _webVRCamera;
  109453. private _vrDeviceOrientationCamera;
  109454. private _deviceOrientationCamera;
  109455. private _existingCamera;
  109456. private _onKeyDown;
  109457. private _onVrDisplayPresentChange;
  109458. private _onVRDisplayChanged;
  109459. private _onVRRequestPresentStart;
  109460. private _onVRRequestPresentComplete;
  109461. /**
  109462. * 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)
  109463. */
  109464. enableGazeEvenWhenNoPointerLock: boolean;
  109465. /**
  109466. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109467. */
  109468. exitVROnDoubleTap: boolean;
  109469. /**
  109470. * Observable raised right before entering VR.
  109471. */
  109472. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109473. /**
  109474. * Observable raised when entering VR has completed.
  109475. */
  109476. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109477. /**
  109478. * Observable raised when exiting VR.
  109479. */
  109480. onExitingVRObservable: Observable<VRExperienceHelper>;
  109481. /**
  109482. * Observable raised when controller mesh is loaded.
  109483. */
  109484. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109485. /** Return this.onEnteringVRObservable
  109486. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109487. */
  109488. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109489. /** Return this.onExitingVRObservable
  109490. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109491. */
  109492. readonly onExitingVR: Observable<VRExperienceHelper>;
  109493. /** Return this.onControllerMeshLoadedObservable
  109494. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109495. */
  109496. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109497. private _rayLength;
  109498. private _useCustomVRButton;
  109499. private _teleportationRequested;
  109500. private _teleportActive;
  109501. private _floorMeshName;
  109502. private _floorMeshesCollection;
  109503. private _rotationAllowed;
  109504. private _teleportBackwardsVector;
  109505. private _teleportationTarget;
  109506. private _isDefaultTeleportationTarget;
  109507. private _postProcessMove;
  109508. private _teleportationFillColor;
  109509. private _teleportationBorderColor;
  109510. private _rotationAngle;
  109511. private _haloCenter;
  109512. private _cameraGazer;
  109513. private _padSensibilityUp;
  109514. private _padSensibilityDown;
  109515. private _leftController;
  109516. private _rightController;
  109517. /**
  109518. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109519. */
  109520. onNewMeshSelected: Observable<AbstractMesh>;
  109521. /**
  109522. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109523. * This observable will provide the mesh and the controller used to select the mesh
  109524. */
  109525. onMeshSelectedWithController: Observable<{
  109526. mesh: AbstractMesh;
  109527. controller: WebVRController;
  109528. }>;
  109529. /**
  109530. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109531. */
  109532. onNewMeshPicked: Observable<PickingInfo>;
  109533. private _circleEase;
  109534. /**
  109535. * Observable raised before camera teleportation
  109536. */
  109537. onBeforeCameraTeleport: Observable<Vector3>;
  109538. /**
  109539. * Observable raised after camera teleportation
  109540. */
  109541. onAfterCameraTeleport: Observable<Vector3>;
  109542. /**
  109543. * Observable raised when current selected mesh gets unselected
  109544. */
  109545. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109546. private _raySelectionPredicate;
  109547. /**
  109548. * To be optionaly changed by user to define custom ray selection
  109549. */
  109550. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109551. /**
  109552. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109553. */
  109554. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109555. /**
  109556. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109557. */
  109558. teleportationEnabled: boolean;
  109559. private _defaultHeight;
  109560. private _teleportationInitialized;
  109561. private _interactionsEnabled;
  109562. private _interactionsRequested;
  109563. private _displayGaze;
  109564. private _displayLaserPointer;
  109565. /**
  109566. * The mesh used to display where the user is going to teleport.
  109567. */
  109568. /**
  109569. * Sets the mesh to be used to display where the user is going to teleport.
  109570. */
  109571. teleportationTarget: Mesh;
  109572. /**
  109573. * 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
  109574. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109575. * See http://doc.babylonjs.com/resources/baking_transformations
  109576. */
  109577. gazeTrackerMesh: Mesh;
  109578. /**
  109579. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109580. */
  109581. updateGazeTrackerScale: boolean;
  109582. /**
  109583. * If the gaze trackers color should be updated when selecting meshes
  109584. */
  109585. updateGazeTrackerColor: boolean;
  109586. /**
  109587. * If the controller laser color should be updated when selecting meshes
  109588. */
  109589. updateControllerLaserColor: boolean;
  109590. /**
  109591. * The gaze tracking mesh corresponding to the left controller
  109592. */
  109593. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109594. /**
  109595. * The gaze tracking mesh corresponding to the right controller
  109596. */
  109597. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109598. /**
  109599. * If the ray of the gaze should be displayed.
  109600. */
  109601. /**
  109602. * Sets if the ray of the gaze should be displayed.
  109603. */
  109604. displayGaze: boolean;
  109605. /**
  109606. * If the ray of the LaserPointer should be displayed.
  109607. */
  109608. /**
  109609. * Sets if the ray of the LaserPointer should be displayed.
  109610. */
  109611. displayLaserPointer: boolean;
  109612. /**
  109613. * The deviceOrientationCamera used as the camera when not in VR.
  109614. */
  109615. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109616. /**
  109617. * Based on the current WebVR support, returns the current VR camera used.
  109618. */
  109619. readonly currentVRCamera: Nullable<Camera>;
  109620. /**
  109621. * The webVRCamera which is used when in VR.
  109622. */
  109623. readonly webVRCamera: WebVRFreeCamera;
  109624. /**
  109625. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109626. */
  109627. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109628. /**
  109629. * The html button that is used to trigger entering into VR.
  109630. */
  109631. readonly vrButton: Nullable<HTMLButtonElement>;
  109632. private readonly _teleportationRequestInitiated;
  109633. /**
  109634. * Defines wether or not Pointer lock should be requested when switching to
  109635. * full screen.
  109636. */
  109637. requestPointerLockOnFullScreen: boolean;
  109638. /**
  109639. * Instantiates a VRExperienceHelper.
  109640. * Helps to quickly add VR support to an existing scene.
  109641. * @param scene The scene the VRExperienceHelper belongs to.
  109642. * @param webVROptions Options to modify the vr experience helper's behavior.
  109643. */
  109644. constructor(scene: Scene,
  109645. /** Options to modify the vr experience helper's behavior. */
  109646. webVROptions?: VRExperienceHelperOptions);
  109647. private _onDefaultMeshLoaded;
  109648. private _onResize;
  109649. private _onFullscreenChange;
  109650. /**
  109651. * Gets a value indicating if we are currently in VR mode.
  109652. */
  109653. readonly isInVRMode: boolean;
  109654. private onVrDisplayPresentChange;
  109655. private onVRDisplayChanged;
  109656. private moveButtonToBottomRight;
  109657. private displayVRButton;
  109658. private updateButtonVisibility;
  109659. private _cachedAngularSensibility;
  109660. /**
  109661. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109662. * Otherwise, will use the fullscreen API.
  109663. */
  109664. enterVR(): void;
  109665. /**
  109666. * Attempt to exit VR, or fullscreen.
  109667. */
  109668. exitVR(): void;
  109669. /**
  109670. * The position of the vr experience helper.
  109671. */
  109672. /**
  109673. * Sets the position of the vr experience helper.
  109674. */
  109675. position: Vector3;
  109676. /**
  109677. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109678. */
  109679. enableInteractions(): void;
  109680. private readonly _noControllerIsActive;
  109681. private beforeRender;
  109682. private _isTeleportationFloor;
  109683. /**
  109684. * Adds a floor mesh to be used for teleportation.
  109685. * @param floorMesh the mesh to be used for teleportation.
  109686. */
  109687. addFloorMesh(floorMesh: Mesh): void;
  109688. /**
  109689. * Removes a floor mesh from being used for teleportation.
  109690. * @param floorMesh the mesh to be removed.
  109691. */
  109692. removeFloorMesh(floorMesh: Mesh): void;
  109693. /**
  109694. * Enables interactions and teleportation using the VR controllers and gaze.
  109695. * @param vrTeleportationOptions options to modify teleportation behavior.
  109696. */
  109697. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109698. private _onNewGamepadConnected;
  109699. private _tryEnableInteractionOnController;
  109700. private _onNewGamepadDisconnected;
  109701. private _enableInteractionOnController;
  109702. private _checkTeleportWithRay;
  109703. private _checkRotate;
  109704. private _checkTeleportBackwards;
  109705. private _enableTeleportationOnController;
  109706. private _createTeleportationCircles;
  109707. private _displayTeleportationTarget;
  109708. private _hideTeleportationTarget;
  109709. private _rotateCamera;
  109710. private _moveTeleportationSelectorTo;
  109711. private _workingVector;
  109712. private _workingQuaternion;
  109713. private _workingMatrix;
  109714. /**
  109715. * Teleports the users feet to the desired location
  109716. * @param location The location where the user's feet should be placed
  109717. */
  109718. teleportCamera(location: Vector3): void;
  109719. private _convertNormalToDirectionOfRay;
  109720. private _castRayAndSelectObject;
  109721. private _notifySelectedMeshUnselected;
  109722. /**
  109723. * Sets the color of the laser ray from the vr controllers.
  109724. * @param color new color for the ray.
  109725. */
  109726. changeLaserColor(color: Color3): void;
  109727. /**
  109728. * Sets the color of the ray from the vr headsets gaze.
  109729. * @param color new color for the ray.
  109730. */
  109731. changeGazeColor(color: Color3): void;
  109732. /**
  109733. * Exits VR and disposes of the vr experience helper
  109734. */
  109735. dispose(): void;
  109736. /**
  109737. * Gets the name of the VRExperienceHelper class
  109738. * @returns "VRExperienceHelper"
  109739. */
  109740. getClassName(): string;
  109741. }
  109742. }
  109743. declare module BABYLON {
  109744. /**
  109745. * States of the webXR experience
  109746. */
  109747. export enum WebXRState {
  109748. /**
  109749. * Transitioning to being in XR mode
  109750. */
  109751. ENTERING_XR = 0,
  109752. /**
  109753. * Transitioning to non XR mode
  109754. */
  109755. EXITING_XR = 1,
  109756. /**
  109757. * In XR mode and presenting
  109758. */
  109759. IN_XR = 2,
  109760. /**
  109761. * Not entered XR mode
  109762. */
  109763. NOT_IN_XR = 3
  109764. }
  109765. /**
  109766. * Abstraction of the XR render target
  109767. */
  109768. export interface WebXRRenderTarget extends IDisposable {
  109769. /**
  109770. * xrpresent context of the canvas which can be used to display/mirror xr content
  109771. */
  109772. canvasContext: WebGLRenderingContext;
  109773. /**
  109774. * xr layer for the canvas
  109775. */
  109776. xrLayer: Nullable<XRWebGLLayer>;
  109777. /**
  109778. * Initializes the xr layer for the session
  109779. * @param xrSession xr session
  109780. * @returns a promise that will resolve once the XR Layer has been created
  109781. */
  109782. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109783. }
  109784. }
  109785. declare module BABYLON {
  109786. /**
  109787. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109788. */
  109789. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109790. private _engine;
  109791. private _canvas;
  109792. /**
  109793. * xrpresent context of the canvas which can be used to display/mirror xr content
  109794. */
  109795. canvasContext: WebGLRenderingContext;
  109796. /**
  109797. * xr layer for the canvas
  109798. */
  109799. xrLayer: Nullable<XRWebGLLayer>;
  109800. /**
  109801. * Initializes the xr layer for the session
  109802. * @param xrSession xr session
  109803. * @returns a promise that will resolve once the XR Layer has been created
  109804. */
  109805. initializeXRLayerAsync(xrSession: any): any;
  109806. /**
  109807. * Initializes the canvas to be added/removed upon entering/exiting xr
  109808. * @param engine the Babylon engine
  109809. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109810. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109811. */
  109812. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  109813. /**
  109814. * Disposes of the object
  109815. */
  109816. dispose(): void;
  109817. private _setManagedOutputCanvas;
  109818. private _addCanvas;
  109819. private _removeCanvas;
  109820. }
  109821. }
  109822. declare module BABYLON {
  109823. /**
  109824. * Manages an XRSession to work with Babylon's engine
  109825. * @see https://doc.babylonjs.com/how_to/webxr
  109826. */
  109827. export class WebXRSessionManager implements IDisposable {
  109828. private scene;
  109829. /**
  109830. * Fires every time a new xrFrame arrives which can be used to update the camera
  109831. */
  109832. onXRFrameObservable: Observable<any>;
  109833. /**
  109834. * Fires when the xr session is ended either by the device or manually done
  109835. */
  109836. onXRSessionEnded: Observable<any>;
  109837. /**
  109838. * Underlying xr session
  109839. */
  109840. session: XRSession;
  109841. /**
  109842. * Type of reference space used when creating the session
  109843. */
  109844. referenceSpace: XRReferenceSpace;
  109845. /**
  109846. * Current XR frame
  109847. */
  109848. currentFrame: Nullable<XRFrame>;
  109849. private _xrNavigator;
  109850. private baseLayer;
  109851. private _rttProvider;
  109852. private _sessionEnded;
  109853. /**
  109854. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109855. * @param scene The scene which the session should be created for
  109856. */
  109857. constructor(scene: Scene);
  109858. /**
  109859. * Initializes the manager
  109860. * After initialization enterXR can be called to start an XR session
  109861. * @returns Promise which resolves after it is initialized
  109862. */
  109863. initializeAsync(): Promise<void>;
  109864. /**
  109865. * Initializes an xr session
  109866. * @param xrSessionMode mode to initialize
  109867. * @param optionalFeatures defines optional values to pass to the session builder
  109868. * @returns a promise which will resolve once the session has been initialized
  109869. */
  109870. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  109871. /**
  109872. * Sets the reference space on the xr session
  109873. * @param referenceSpace space to set
  109874. * @returns a promise that will resolve once the reference space has been set
  109875. */
  109876. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109877. /**
  109878. * Updates the render state of the session
  109879. * @param state state to set
  109880. * @returns a promise that resolves once the render state has been updated
  109881. */
  109882. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109883. /**
  109884. * Starts rendering to the xr layer
  109885. * @returns a promise that will resolve once rendering has started
  109886. */
  109887. startRenderingToXRAsync(): Promise<void>;
  109888. /**
  109889. * Gets the correct render target texture to be rendered this frame for this eye
  109890. * @param eye the eye for which to get the render target
  109891. * @returns the render target for the specified eye
  109892. */
  109893. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109894. /**
  109895. * Stops the xrSession and restores the renderloop
  109896. * @returns Promise which resolves after it exits XR
  109897. */
  109898. exitXRAsync(): Promise<void>;
  109899. /**
  109900. * Checks if a session would be supported for the creation options specified
  109901. * @param sessionMode session mode to check if supported eg. immersive-vr
  109902. * @returns true if supported
  109903. */
  109904. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109905. /**
  109906. * Creates a WebXRRenderTarget object for the XR session
  109907. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109908. * @returns a WebXR render target to which the session can render
  109909. */
  109910. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109911. /**
  109912. * @hidden
  109913. * Converts the render layer of xrSession to a render target
  109914. * @param session session to create render target for
  109915. * @param scene scene the new render target should be created for
  109916. */
  109917. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109918. /**
  109919. * Disposes of the session manager
  109920. */
  109921. dispose(): void;
  109922. }
  109923. }
  109924. declare module BABYLON {
  109925. /**
  109926. * WebXR Camera which holds the views for the xrSession
  109927. * @see https://doc.babylonjs.com/how_to/webxr
  109928. */
  109929. export class WebXRCamera extends FreeCamera {
  109930. private static _TmpMatrix;
  109931. /**
  109932. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109933. * @param name the name of the camera
  109934. * @param scene the scene to add the camera to
  109935. */
  109936. constructor(name: string, scene: Scene);
  109937. private _updateNumberOfRigCameras;
  109938. /** @hidden */
  109939. _updateForDualEyeDebugging(): void;
  109940. /**
  109941. * Updates the cameras position from the current pose information of the XR session
  109942. * @param xrSessionManager the session containing pose information
  109943. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109944. */
  109945. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109946. }
  109947. }
  109948. declare module BABYLON {
  109949. /**
  109950. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109951. * @see https://doc.babylonjs.com/how_to/webxr
  109952. */
  109953. export class WebXRExperienceHelper implements IDisposable {
  109954. private scene;
  109955. /**
  109956. * 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
  109957. */
  109958. container: AbstractMesh;
  109959. /**
  109960. * Camera used to render xr content
  109961. */
  109962. camera: WebXRCamera;
  109963. /**
  109964. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109965. */
  109966. state: WebXRState;
  109967. private _setState;
  109968. private static _TmpVector;
  109969. /**
  109970. * Fires when the state of the experience helper has changed
  109971. */
  109972. onStateChangedObservable: Observable<WebXRState>;
  109973. /** Session manager used to keep track of xr session */
  109974. sessionManager: WebXRSessionManager;
  109975. private _nonVRCamera;
  109976. private _originalSceneAutoClear;
  109977. private _supported;
  109978. /**
  109979. * Creates the experience helper
  109980. * @param scene the scene to attach the experience helper to
  109981. * @returns a promise for the experience helper
  109982. */
  109983. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109984. /**
  109985. * Creates a WebXRExperienceHelper
  109986. * @param scene The scene the helper should be created in
  109987. */
  109988. private constructor();
  109989. /**
  109990. * Exits XR mode and returns the scene to its original state
  109991. * @returns promise that resolves after xr mode has exited
  109992. */
  109993. exitXRAsync(): Promise<void>;
  109994. /**
  109995. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109996. * @param sessionMode options for the XR session
  109997. * @param referenceSpaceType frame of reference of the XR session
  109998. * @param renderTarget the output canvas that will be used to enter XR mode
  109999. * @returns promise that resolves after xr mode has entered
  110000. */
  110001. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110002. /**
  110003. * Updates the global position of the camera by moving the camera's container
  110004. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110005. * @param position The desired global position of the camera
  110006. */
  110007. setPositionOfCameraUsingContainer(position: Vector3): void;
  110008. /**
  110009. * Rotates the xr camera by rotating the camera's container around the camera's position
  110010. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110011. * @param rotation the desired quaternion rotation to apply to the camera
  110012. */
  110013. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110014. /**
  110015. * Disposes of the experience helper
  110016. */
  110017. dispose(): void;
  110018. }
  110019. }
  110020. declare module BABYLON {
  110021. /**
  110022. * Button which can be used to enter a different mode of XR
  110023. */
  110024. export class WebXREnterExitUIButton {
  110025. /** button element */
  110026. element: HTMLElement;
  110027. /** XR initialization options for the button */
  110028. sessionMode: XRSessionMode;
  110029. /** Reference space type */
  110030. referenceSpaceType: XRReferenceSpaceType;
  110031. /**
  110032. * Creates a WebXREnterExitUIButton
  110033. * @param element button element
  110034. * @param sessionMode XR initialization session mode
  110035. * @param referenceSpaceType the type of reference space to be used
  110036. */
  110037. constructor(
  110038. /** button element */
  110039. element: HTMLElement,
  110040. /** XR initialization options for the button */
  110041. sessionMode: XRSessionMode,
  110042. /** Reference space type */
  110043. referenceSpaceType: XRReferenceSpaceType);
  110044. /**
  110045. * Overwritable function which can be used to update the button's visuals when the state changes
  110046. * @param activeButton the current active button in the UI
  110047. */
  110048. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110049. }
  110050. /**
  110051. * Options to create the webXR UI
  110052. */
  110053. export class WebXREnterExitUIOptions {
  110054. /**
  110055. * Context to enter xr with
  110056. */
  110057. renderTarget?: Nullable<WebXRRenderTarget>;
  110058. /**
  110059. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110060. */
  110061. customButtons?: Array<WebXREnterExitUIButton>;
  110062. }
  110063. /**
  110064. * UI to allow the user to enter/exit XR mode
  110065. */
  110066. export class WebXREnterExitUI implements IDisposable {
  110067. private scene;
  110068. private _overlay;
  110069. private _buttons;
  110070. private _activeButton;
  110071. /**
  110072. * Fired every time the active button is changed.
  110073. *
  110074. * When xr is entered via a button that launches xr that button will be the callback parameter
  110075. *
  110076. * When exiting xr the callback parameter will be null)
  110077. */
  110078. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110079. /**
  110080. * Creates UI to allow the user to enter/exit XR mode
  110081. * @param scene the scene to add the ui to
  110082. * @param helper the xr experience helper to enter/exit xr with
  110083. * @param options options to configure the UI
  110084. * @returns the created ui
  110085. */
  110086. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110087. private constructor();
  110088. private _updateButtons;
  110089. /**
  110090. * Disposes of the object
  110091. */
  110092. dispose(): void;
  110093. }
  110094. }
  110095. declare module BABYLON {
  110096. /**
  110097. * Represents an XR input
  110098. */
  110099. export class WebXRController {
  110100. private scene;
  110101. /** The underlying input source for the controller */
  110102. inputSource: XRInputSource;
  110103. private parentContainer;
  110104. /**
  110105. * 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
  110106. */
  110107. grip?: AbstractMesh;
  110108. /**
  110109. * Pointer which can be used to select objects or attach a visible laser to
  110110. */
  110111. pointer: AbstractMesh;
  110112. private _gamepadMode;
  110113. /**
  110114. * If available, this is the gamepad object related to this controller.
  110115. * Using this object it is possible to get click events and trackpad changes of the
  110116. * webxr controller that is currently being used.
  110117. */
  110118. gamepadController?: WebVRController;
  110119. /**
  110120. * Event that fires when the controller is removed/disposed
  110121. */
  110122. onDisposeObservable: Observable<{}>;
  110123. private _tmpMatrix;
  110124. private _tmpQuaternion;
  110125. private _tmpVector;
  110126. /**
  110127. * Creates the controller
  110128. * @see https://doc.babylonjs.com/how_to/webxr
  110129. * @param scene the scene which the controller should be associated to
  110130. * @param inputSource the underlying input source for the controller
  110131. * @param parentContainer parent that the controller meshes should be children of
  110132. */
  110133. constructor(scene: Scene,
  110134. /** The underlying input source for the controller */
  110135. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110136. /**
  110137. * Updates the controller pose based on the given XRFrame
  110138. * @param xrFrame xr frame to update the pose with
  110139. * @param referenceSpace reference space to use
  110140. */
  110141. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110142. /**
  110143. * Gets a world space ray coming from the controller
  110144. * @param result the resulting ray
  110145. */
  110146. getWorldPointerRayToRef(result: Ray): void;
  110147. /**
  110148. * Get the scene associated with this controller
  110149. * @returns the scene object
  110150. */
  110151. getScene(): Scene;
  110152. /**
  110153. * Disposes of the object
  110154. */
  110155. dispose(): void;
  110156. }
  110157. }
  110158. declare module BABYLON {
  110159. /**
  110160. * XR input used to track XR inputs such as controllers/rays
  110161. */
  110162. export class WebXRInput implements IDisposable {
  110163. /**
  110164. * Base experience the input listens to
  110165. */
  110166. baseExperience: WebXRExperienceHelper;
  110167. /**
  110168. * XR controllers being tracked
  110169. */
  110170. controllers: Array<WebXRController>;
  110171. private _frameObserver;
  110172. private _stateObserver;
  110173. /**
  110174. * Event when a controller has been connected/added
  110175. */
  110176. onControllerAddedObservable: Observable<WebXRController>;
  110177. /**
  110178. * Event when a controller has been removed/disconnected
  110179. */
  110180. onControllerRemovedObservable: Observable<WebXRController>;
  110181. /**
  110182. * Initializes the WebXRInput
  110183. * @param baseExperience experience helper which the input should be created for
  110184. */
  110185. constructor(
  110186. /**
  110187. * Base experience the input listens to
  110188. */
  110189. baseExperience: WebXRExperienceHelper);
  110190. private _onInputSourcesChange;
  110191. private _addAndRemoveControllers;
  110192. /**
  110193. * Disposes of the object
  110194. */
  110195. dispose(): void;
  110196. }
  110197. }
  110198. declare module BABYLON {
  110199. /**
  110200. * Enables teleportation
  110201. */
  110202. export class WebXRControllerTeleportation {
  110203. private _teleportationFillColor;
  110204. private _teleportationBorderColor;
  110205. private _tmpRay;
  110206. private _tmpVector;
  110207. /**
  110208. * Creates a WebXRControllerTeleportation
  110209. * @param input input manager to add teleportation to
  110210. * @param floorMeshes floormeshes which can be teleported to
  110211. */
  110212. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110213. }
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * Handles pointer input automatically for the pointer of XR controllers
  110218. */
  110219. export class WebXRControllerPointerSelection {
  110220. private static _idCounter;
  110221. private _tmpRay;
  110222. /**
  110223. * Creates a WebXRControllerPointerSelection
  110224. * @param input input manager to setup pointer selection
  110225. */
  110226. constructor(input: WebXRInput);
  110227. private _convertNormalToDirectionOfRay;
  110228. private _updatePointerDistance;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. /**
  110233. * Class used to represent data loading progression
  110234. */
  110235. export class SceneLoaderProgressEvent {
  110236. /** defines if data length to load can be evaluated */
  110237. readonly lengthComputable: boolean;
  110238. /** defines the loaded data length */
  110239. readonly loaded: number;
  110240. /** defines the data length to load */
  110241. readonly total: number;
  110242. /**
  110243. * Create a new progress event
  110244. * @param lengthComputable defines if data length to load can be evaluated
  110245. * @param loaded defines the loaded data length
  110246. * @param total defines the data length to load
  110247. */
  110248. constructor(
  110249. /** defines if data length to load can be evaluated */
  110250. lengthComputable: boolean,
  110251. /** defines the loaded data length */
  110252. loaded: number,
  110253. /** defines the data length to load */
  110254. total: number);
  110255. /**
  110256. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110257. * @param event defines the source event
  110258. * @returns a new SceneLoaderProgressEvent
  110259. */
  110260. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110261. }
  110262. /**
  110263. * Interface used by SceneLoader plugins to define supported file extensions
  110264. */
  110265. export interface ISceneLoaderPluginExtensions {
  110266. /**
  110267. * Defines the list of supported extensions
  110268. */
  110269. [extension: string]: {
  110270. isBinary: boolean;
  110271. };
  110272. }
  110273. /**
  110274. * Interface used by SceneLoader plugin factory
  110275. */
  110276. export interface ISceneLoaderPluginFactory {
  110277. /**
  110278. * Defines the name of the factory
  110279. */
  110280. name: string;
  110281. /**
  110282. * Function called to create a new plugin
  110283. * @return the new plugin
  110284. */
  110285. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110286. /**
  110287. * The callback that returns true if the data can be directly loaded.
  110288. * @param data string containing the file data
  110289. * @returns if the data can be loaded directly
  110290. */
  110291. canDirectLoad?(data: string): boolean;
  110292. }
  110293. /**
  110294. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110295. */
  110296. export interface ISceneLoaderPluginBase {
  110297. /**
  110298. * The friendly name of this plugin.
  110299. */
  110300. name: string;
  110301. /**
  110302. * The file extensions supported by this plugin.
  110303. */
  110304. extensions: string | ISceneLoaderPluginExtensions;
  110305. /**
  110306. * The callback called when loading from a url.
  110307. * @param scene scene loading this url
  110308. * @param url url to load
  110309. * @param onSuccess callback called when the file successfully loads
  110310. * @param onProgress callback called while file is loading (if the server supports this mode)
  110311. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110312. * @param onError callback called when the file fails to load
  110313. * @returns a file request object
  110314. */
  110315. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110316. /**
  110317. * The callback called when loading from a file object.
  110318. * @param scene scene loading this file
  110319. * @param file defines the file to load
  110320. * @param onSuccess defines the callback to call when data is loaded
  110321. * @param onProgress defines the callback to call during loading process
  110322. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110323. * @param onError defines the callback to call when an error occurs
  110324. * @returns a file request object
  110325. */
  110326. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110327. /**
  110328. * The callback that returns true if the data can be directly loaded.
  110329. * @param data string containing the file data
  110330. * @returns if the data can be loaded directly
  110331. */
  110332. canDirectLoad?(data: string): boolean;
  110333. /**
  110334. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110335. * @param scene scene loading this data
  110336. * @param data string containing the data
  110337. * @returns data to pass to the plugin
  110338. */
  110339. directLoad?(scene: Scene, data: string): any;
  110340. /**
  110341. * The callback that allows custom handling of the root url based on the response url.
  110342. * @param rootUrl the original root url
  110343. * @param responseURL the response url if available
  110344. * @returns the new root url
  110345. */
  110346. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110347. }
  110348. /**
  110349. * Interface used to define a SceneLoader plugin
  110350. */
  110351. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110352. /**
  110353. * Import meshes into a scene.
  110354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110355. * @param scene The scene to import into
  110356. * @param data The data to import
  110357. * @param rootUrl The root url for scene and resources
  110358. * @param meshes The meshes array to import into
  110359. * @param particleSystems The particle systems array to import into
  110360. * @param skeletons The skeletons array to import into
  110361. * @param onError The callback when import fails
  110362. * @returns True if successful or false otherwise
  110363. */
  110364. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110365. /**
  110366. * Load into a scene.
  110367. * @param scene The scene to load into
  110368. * @param data The data to import
  110369. * @param rootUrl The root url for scene and resources
  110370. * @param onError The callback when import fails
  110371. * @returns True if successful or false otherwise
  110372. */
  110373. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110374. /**
  110375. * Load into an asset container.
  110376. * @param scene The scene to load into
  110377. * @param data The data to import
  110378. * @param rootUrl The root url for scene and resources
  110379. * @param onError The callback when import fails
  110380. * @returns The loaded asset container
  110381. */
  110382. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110383. }
  110384. /**
  110385. * Interface used to define an async SceneLoader plugin
  110386. */
  110387. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110388. /**
  110389. * Import meshes into a scene.
  110390. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110391. * @param scene The scene to import into
  110392. * @param data The data to import
  110393. * @param rootUrl The root url for scene and resources
  110394. * @param onProgress The callback when the load progresses
  110395. * @param fileName Defines the name of the file to load
  110396. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110397. */
  110398. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110399. meshes: AbstractMesh[];
  110400. particleSystems: IParticleSystem[];
  110401. skeletons: Skeleton[];
  110402. animationGroups: AnimationGroup[];
  110403. }>;
  110404. /**
  110405. * Load into a scene.
  110406. * @param scene The scene to load into
  110407. * @param data The data to import
  110408. * @param rootUrl The root url for scene and resources
  110409. * @param onProgress The callback when the load progresses
  110410. * @param fileName Defines the name of the file to load
  110411. * @returns Nothing
  110412. */
  110413. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110414. /**
  110415. * Load into an asset container.
  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 onProgress The callback when the load progresses
  110420. * @param fileName Defines the name of the file to load
  110421. * @returns The loaded asset container
  110422. */
  110423. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110424. }
  110425. /**
  110426. * Class used to load scene from various file formats using registered plugins
  110427. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110428. */
  110429. export class SceneLoader {
  110430. /**
  110431. * No logging while loading
  110432. */
  110433. static readonly NO_LOGGING: number;
  110434. /**
  110435. * Minimal logging while loading
  110436. */
  110437. static readonly MINIMAL_LOGGING: number;
  110438. /**
  110439. * Summary logging while loading
  110440. */
  110441. static readonly SUMMARY_LOGGING: number;
  110442. /**
  110443. * Detailled logging while loading
  110444. */
  110445. static readonly DETAILED_LOGGING: number;
  110446. /**
  110447. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110448. */
  110449. static ForceFullSceneLoadingForIncremental: boolean;
  110450. /**
  110451. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110452. */
  110453. static ShowLoadingScreen: boolean;
  110454. /**
  110455. * Defines the current logging level (while loading the scene)
  110456. * @ignorenaming
  110457. */
  110458. static loggingLevel: number;
  110459. /**
  110460. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110461. */
  110462. static CleanBoneMatrixWeights: boolean;
  110463. /**
  110464. * Event raised when a plugin is used to load a scene
  110465. */
  110466. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110467. private static _registeredPlugins;
  110468. private static _getDefaultPlugin;
  110469. private static _getPluginForExtension;
  110470. private static _getPluginForDirectLoad;
  110471. private static _getPluginForFilename;
  110472. private static _getDirectLoad;
  110473. private static _loadData;
  110474. private static _getFileInfo;
  110475. /**
  110476. * Gets a plugin that can load the given extension
  110477. * @param extension defines the extension to load
  110478. * @returns a plugin or null if none works
  110479. */
  110480. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110481. /**
  110482. * Gets a boolean indicating that the given extension can be loaded
  110483. * @param extension defines the extension to load
  110484. * @returns true if the extension is supported
  110485. */
  110486. static IsPluginForExtensionAvailable(extension: string): boolean;
  110487. /**
  110488. * Adds a new plugin to the list of registered plugins
  110489. * @param plugin defines the plugin to add
  110490. */
  110491. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110492. /**
  110493. * Import meshes into a scene
  110494. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110495. * @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)
  110496. * @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)
  110497. * @param scene the instance of BABYLON.Scene to append to
  110498. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110499. * @param onProgress a callback with a progress event for each file being loaded
  110500. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110501. * @param pluginExtension the extension used to determine the plugin
  110502. * @returns The loaded plugin
  110503. */
  110504. 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>;
  110505. /**
  110506. * Import meshes into a scene
  110507. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110508. * @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)
  110509. * @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)
  110510. * @param scene the instance of BABYLON.Scene to append to
  110511. * @param onProgress a callback with a progress event for each file being loaded
  110512. * @param pluginExtension the extension used to determine the plugin
  110513. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110514. */
  110515. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110516. meshes: AbstractMesh[];
  110517. particleSystems: IParticleSystem[];
  110518. skeletons: Skeleton[];
  110519. animationGroups: AnimationGroup[];
  110520. }>;
  110521. /**
  110522. * Load a scene
  110523. * @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)
  110524. * @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)
  110525. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110526. * @param onSuccess a callback with the scene when import succeeds
  110527. * @param onProgress a callback with a progress event for each file being loaded
  110528. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110529. * @param pluginExtension the extension used to determine the plugin
  110530. * @returns The loaded plugin
  110531. */
  110532. 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>;
  110533. /**
  110534. * Load a scene
  110535. * @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)
  110536. * @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)
  110537. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110538. * @param onProgress a callback with a progress event for each file being loaded
  110539. * @param pluginExtension the extension used to determine the plugin
  110540. * @returns The loaded scene
  110541. */
  110542. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110543. /**
  110544. * Append a scene
  110545. * @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)
  110546. * @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)
  110547. * @param scene is the instance of BABYLON.Scene to append to
  110548. * @param onSuccess a callback with the scene when import succeeds
  110549. * @param onProgress a callback with a progress event for each file being loaded
  110550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110551. * @param pluginExtension the extension used to determine the plugin
  110552. * @returns The loaded plugin
  110553. */
  110554. 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>;
  110555. /**
  110556. * Append a scene
  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 is 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 given scene
  110563. */
  110564. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110565. /**
  110566. * Load a scene into an asset container
  110567. * @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)
  110568. * @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)
  110569. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110570. * @param onSuccess a callback with the scene when import succeeds
  110571. * @param onProgress a callback with a progress event for each file being loaded
  110572. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110573. * @param pluginExtension the extension used to determine the plugin
  110574. * @returns The loaded plugin
  110575. */
  110576. 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>;
  110577. /**
  110578. * Load a scene into an asset container
  110579. * @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)
  110580. * @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)
  110581. * @param scene is the instance of Scene to append to
  110582. * @param onProgress a callback with a progress event for each file being loaded
  110583. * @param pluginExtension the extension used to determine the plugin
  110584. * @returns The loaded asset container
  110585. */
  110586. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110587. }
  110588. }
  110589. declare module BABYLON {
  110590. /**
  110591. * Generic Controller
  110592. */
  110593. export class GenericController extends WebVRController {
  110594. /**
  110595. * Base Url for the controller model.
  110596. */
  110597. static readonly MODEL_BASE_URL: string;
  110598. /**
  110599. * File name for the controller model.
  110600. */
  110601. static readonly MODEL_FILENAME: string;
  110602. /**
  110603. * Creates a new GenericController from a gamepad
  110604. * @param vrGamepad the gamepad that the controller should be created from
  110605. */
  110606. constructor(vrGamepad: any);
  110607. /**
  110608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110609. * @param scene scene in which to add meshes
  110610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110611. */
  110612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110613. /**
  110614. * Called once for each button that changed state since the last frame
  110615. * @param buttonIdx Which button index changed
  110616. * @param state New state of the button
  110617. * @param changes Which properties on the state changed since last frame
  110618. */
  110619. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110620. }
  110621. }
  110622. declare module BABYLON {
  110623. /**
  110624. * Defines the WindowsMotionController object that the state of the windows motion controller
  110625. */
  110626. export class WindowsMotionController extends WebVRController {
  110627. /**
  110628. * The base url used to load the left and right controller models
  110629. */
  110630. static MODEL_BASE_URL: string;
  110631. /**
  110632. * The name of the left controller model file
  110633. */
  110634. static MODEL_LEFT_FILENAME: string;
  110635. /**
  110636. * The name of the right controller model file
  110637. */
  110638. static MODEL_RIGHT_FILENAME: string;
  110639. /**
  110640. * The controller name prefix for this controller type
  110641. */
  110642. static readonly GAMEPAD_ID_PREFIX: string;
  110643. /**
  110644. * The controller id pattern for this controller type
  110645. */
  110646. private static readonly GAMEPAD_ID_PATTERN;
  110647. private _loadedMeshInfo;
  110648. private readonly _mapping;
  110649. /**
  110650. * Fired when the trackpad on this controller is clicked
  110651. */
  110652. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110653. /**
  110654. * Fired when the trackpad on this controller is modified
  110655. */
  110656. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110657. /**
  110658. * The current x and y values of this controller's trackpad
  110659. */
  110660. trackpad: StickValues;
  110661. /**
  110662. * Creates a new WindowsMotionController from a gamepad
  110663. * @param vrGamepad the gamepad that the controller should be created from
  110664. */
  110665. constructor(vrGamepad: any);
  110666. /**
  110667. * Fired when the trigger on this controller is modified
  110668. */
  110669. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110670. /**
  110671. * Fired when the menu button on this controller is modified
  110672. */
  110673. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110674. /**
  110675. * Fired when the grip button on this controller is modified
  110676. */
  110677. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110678. /**
  110679. * Fired when the thumbstick button on this controller is modified
  110680. */
  110681. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110682. /**
  110683. * Fired when the touchpad button on this controller is modified
  110684. */
  110685. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110686. /**
  110687. * Fired when the touchpad values on this controller are modified
  110688. */
  110689. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110690. private _updateTrackpad;
  110691. /**
  110692. * Called once per frame by the engine.
  110693. */
  110694. update(): void;
  110695. /**
  110696. * Called once for each button that changed state since the last frame
  110697. * @param buttonIdx Which button index changed
  110698. * @param state New state of the button
  110699. * @param changes Which properties on the state changed since last frame
  110700. */
  110701. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110702. /**
  110703. * Moves the buttons on the controller mesh based on their current state
  110704. * @param buttonName the name of the button to move
  110705. * @param buttonValue the value of the button which determines the buttons new position
  110706. */
  110707. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110708. /**
  110709. * Moves the axis on the controller mesh based on its current state
  110710. * @param axis the index of the axis
  110711. * @param axisValue the value of the axis which determines the meshes new position
  110712. * @hidden
  110713. */
  110714. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110715. /**
  110716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110717. * @param scene scene in which to add meshes
  110718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110719. */
  110720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110721. /**
  110722. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110723. * can be transformed by button presses and axes values, based on this._mapping.
  110724. *
  110725. * @param scene scene in which the meshes exist
  110726. * @param meshes list of meshes that make up the controller model to process
  110727. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110728. */
  110729. private processModel;
  110730. private createMeshInfo;
  110731. /**
  110732. * Gets the ray of the controller in the direction the controller is pointing
  110733. * @param length the length the resulting ray should be
  110734. * @returns a ray in the direction the controller is pointing
  110735. */
  110736. getForwardRay(length?: number): Ray;
  110737. /**
  110738. * Disposes of the controller
  110739. */
  110740. dispose(): void;
  110741. }
  110742. }
  110743. declare module BABYLON {
  110744. /**
  110745. * Oculus Touch Controller
  110746. */
  110747. export class OculusTouchController extends WebVRController {
  110748. /**
  110749. * Base Url for the controller model.
  110750. */
  110751. static MODEL_BASE_URL: string;
  110752. /**
  110753. * File name for the left controller model.
  110754. */
  110755. static MODEL_LEFT_FILENAME: string;
  110756. /**
  110757. * File name for the right controller model.
  110758. */
  110759. static MODEL_RIGHT_FILENAME: string;
  110760. /**
  110761. * Base Url for the Quest controller model.
  110762. */
  110763. static QUEST_MODEL_BASE_URL: string;
  110764. /**
  110765. * @hidden
  110766. * If the controllers are running on a device that needs the updated Quest controller models
  110767. */
  110768. static _IsQuest: boolean;
  110769. /**
  110770. * Fired when the secondary trigger on this controller is modified
  110771. */
  110772. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110773. /**
  110774. * Fired when the thumb rest on this controller is modified
  110775. */
  110776. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110777. /**
  110778. * Creates a new OculusTouchController from a gamepad
  110779. * @param vrGamepad the gamepad that the controller should be created from
  110780. */
  110781. constructor(vrGamepad: any);
  110782. /**
  110783. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110784. * @param scene scene in which to add meshes
  110785. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110786. */
  110787. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110788. /**
  110789. * Fired when the A button on this controller is modified
  110790. */
  110791. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110792. /**
  110793. * Fired when the B button on this controller is modified
  110794. */
  110795. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110796. /**
  110797. * Fired when the X button on this controller is modified
  110798. */
  110799. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110800. /**
  110801. * Fired when the Y button on this controller is modified
  110802. */
  110803. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110804. /**
  110805. * Called once for each button that changed state since the last frame
  110806. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110807. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110808. * 2) secondary trigger (same)
  110809. * 3) A (right) X (left), touch, pressed = value
  110810. * 4) B / Y
  110811. * 5) thumb rest
  110812. * @param buttonIdx Which button index changed
  110813. * @param state New state of the button
  110814. * @param changes Which properties on the state changed since last frame
  110815. */
  110816. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110817. }
  110818. }
  110819. declare module BABYLON {
  110820. /**
  110821. * Vive Controller
  110822. */
  110823. export class ViveController extends WebVRController {
  110824. /**
  110825. * Base Url for the controller model.
  110826. */
  110827. static MODEL_BASE_URL: string;
  110828. /**
  110829. * File name for the controller model.
  110830. */
  110831. static MODEL_FILENAME: string;
  110832. /**
  110833. * Creates a new ViveController from a gamepad
  110834. * @param vrGamepad the gamepad that the controller should be created from
  110835. */
  110836. constructor(vrGamepad: any);
  110837. /**
  110838. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110839. * @param scene scene in which to add meshes
  110840. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110841. */
  110842. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110843. /**
  110844. * Fired when the left button on this controller is modified
  110845. */
  110846. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110847. /**
  110848. * Fired when the right button on this controller is modified
  110849. */
  110850. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110851. /**
  110852. * Fired when the menu button on this controller is modified
  110853. */
  110854. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110855. /**
  110856. * Called once for each button that changed state since the last frame
  110857. * Vive mapping:
  110858. * 0: touchpad
  110859. * 1: trigger
  110860. * 2: left AND right buttons
  110861. * 3: menu button
  110862. * @param buttonIdx Which button index changed
  110863. * @param state New state of the button
  110864. * @param changes Which properties on the state changed since last frame
  110865. */
  110866. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110867. }
  110868. }
  110869. declare module BABYLON {
  110870. /**
  110871. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110872. */
  110873. export class WebXRControllerModelLoader {
  110874. /**
  110875. * Creates the WebXRControllerModelLoader
  110876. * @param input xr input that creates the controllers
  110877. */
  110878. constructor(input: WebXRInput);
  110879. }
  110880. }
  110881. declare module BABYLON {
  110882. /**
  110883. * Contains an array of blocks representing the octree
  110884. */
  110885. export interface IOctreeContainer<T> {
  110886. /**
  110887. * Blocks within the octree
  110888. */
  110889. blocks: Array<OctreeBlock<T>>;
  110890. }
  110891. /**
  110892. * Class used to store a cell in an octree
  110893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110894. */
  110895. export class OctreeBlock<T> {
  110896. /**
  110897. * Gets the content of the current block
  110898. */
  110899. entries: T[];
  110900. /**
  110901. * Gets the list of block children
  110902. */
  110903. blocks: Array<OctreeBlock<T>>;
  110904. private _depth;
  110905. private _maxDepth;
  110906. private _capacity;
  110907. private _minPoint;
  110908. private _maxPoint;
  110909. private _boundingVectors;
  110910. private _creationFunc;
  110911. /**
  110912. * Creates a new block
  110913. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110914. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110915. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110916. * @param depth defines the current depth of this block in the octree
  110917. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110918. * @param creationFunc defines a callback to call when an element is added to the block
  110919. */
  110920. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110921. /**
  110922. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110923. */
  110924. readonly capacity: number;
  110925. /**
  110926. * Gets the minimum vector (in world space) of the block's bounding box
  110927. */
  110928. readonly minPoint: Vector3;
  110929. /**
  110930. * Gets the maximum vector (in world space) of the block's bounding box
  110931. */
  110932. readonly maxPoint: Vector3;
  110933. /**
  110934. * Add a new element to this block
  110935. * @param entry defines the element to add
  110936. */
  110937. addEntry(entry: T): void;
  110938. /**
  110939. * Remove an element from this block
  110940. * @param entry defines the element to remove
  110941. */
  110942. removeEntry(entry: T): void;
  110943. /**
  110944. * Add an array of elements to this block
  110945. * @param entries defines the array of elements to add
  110946. */
  110947. addEntries(entries: T[]): void;
  110948. /**
  110949. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110950. * @param frustumPlanes defines the frustum planes to test
  110951. * @param selection defines the array to store current content if selection is positive
  110952. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110953. */
  110954. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110955. /**
  110956. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110957. * @param sphereCenter defines the bounding sphere center
  110958. * @param sphereRadius defines the bounding sphere radius
  110959. * @param selection defines the array to store current content if selection is positive
  110960. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110961. */
  110962. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110963. /**
  110964. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110965. * @param ray defines the ray to test with
  110966. * @param selection defines the array to store current content if selection is positive
  110967. */
  110968. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110969. /**
  110970. * Subdivide the content into child blocks (this block will then be empty)
  110971. */
  110972. createInnerBlocks(): void;
  110973. /**
  110974. * @hidden
  110975. */
  110976. 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;
  110977. }
  110978. }
  110979. declare module BABYLON {
  110980. /**
  110981. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110982. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110983. */
  110984. export class Octree<T> {
  110985. /** 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.) */
  110986. maxDepth: number;
  110987. /**
  110988. * Blocks within the octree containing objects
  110989. */
  110990. blocks: Array<OctreeBlock<T>>;
  110991. /**
  110992. * Content stored in the octree
  110993. */
  110994. dynamicContent: T[];
  110995. private _maxBlockCapacity;
  110996. private _selectionContent;
  110997. private _creationFunc;
  110998. /**
  110999. * Creates a octree
  111000. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111001. * @param creationFunc function to be used to instatiate the octree
  111002. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111003. * @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.)
  111004. */
  111005. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111006. /** 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.) */
  111007. maxDepth?: number);
  111008. /**
  111009. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111010. * @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);
  111011. * @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);
  111012. * @param entries meshes to be added to the octree blocks
  111013. */
  111014. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111015. /**
  111016. * Adds a mesh to the octree
  111017. * @param entry Mesh to add to the octree
  111018. */
  111019. addMesh(entry: T): void;
  111020. /**
  111021. * Remove an element from the octree
  111022. * @param entry defines the element to remove
  111023. */
  111024. removeMesh(entry: T): void;
  111025. /**
  111026. * Selects an array of meshes within the frustum
  111027. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111028. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111029. * @returns array of meshes within the frustum
  111030. */
  111031. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111032. /**
  111033. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111034. * @param sphereCenter defines the bounding sphere center
  111035. * @param sphereRadius defines the bounding sphere radius
  111036. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111037. * @returns an array of objects that intersect the sphere
  111038. */
  111039. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111040. /**
  111041. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111042. * @param ray defines the ray to test with
  111043. * @returns array of intersected objects
  111044. */
  111045. intersectsRay(ray: Ray): SmartArray<T>;
  111046. /**
  111047. * Adds a mesh into the octree block if it intersects the block
  111048. */
  111049. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111050. /**
  111051. * Adds a submesh into the octree block if it intersects the block
  111052. */
  111053. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111054. }
  111055. }
  111056. declare module BABYLON {
  111057. interface Scene {
  111058. /**
  111059. * @hidden
  111060. * Backing Filed
  111061. */
  111062. _selectionOctree: Octree<AbstractMesh>;
  111063. /**
  111064. * Gets the octree used to boost mesh selection (picking)
  111065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111066. */
  111067. selectionOctree: Octree<AbstractMesh>;
  111068. /**
  111069. * Creates or updates the octree used to boost selection (picking)
  111070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111071. * @param maxCapacity defines the maximum capacity per leaf
  111072. * @param maxDepth defines the maximum depth of the octree
  111073. * @returns an octree of AbstractMesh
  111074. */
  111075. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111076. }
  111077. interface AbstractMesh {
  111078. /**
  111079. * @hidden
  111080. * Backing Field
  111081. */
  111082. _submeshesOctree: Octree<SubMesh>;
  111083. /**
  111084. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111085. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111086. * @param maxCapacity defines the maximum size of each block (64 by default)
  111087. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111088. * @returns the new octree
  111089. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111091. */
  111092. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111093. }
  111094. /**
  111095. * Defines the octree scene component responsible to manage any octrees
  111096. * in a given scene.
  111097. */
  111098. export class OctreeSceneComponent {
  111099. /**
  111100. * The component name help to identify the component in the list of scene components.
  111101. */
  111102. readonly name: string;
  111103. /**
  111104. * The scene the component belongs to.
  111105. */
  111106. scene: Scene;
  111107. /**
  111108. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111109. */
  111110. readonly checksIsEnabled: boolean;
  111111. /**
  111112. * Creates a new instance of the component for the given scene
  111113. * @param scene Defines the scene to register the component in
  111114. */
  111115. constructor(scene: Scene);
  111116. /**
  111117. * Registers the component in a given scene
  111118. */
  111119. register(): void;
  111120. /**
  111121. * Return the list of active meshes
  111122. * @returns the list of active meshes
  111123. */
  111124. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111125. /**
  111126. * Return the list of active sub meshes
  111127. * @param mesh The mesh to get the candidates sub meshes from
  111128. * @returns the list of active sub meshes
  111129. */
  111130. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111131. private _tempRay;
  111132. /**
  111133. * Return the list of sub meshes intersecting with a given local ray
  111134. * @param mesh defines the mesh to find the submesh for
  111135. * @param localRay defines the ray in local space
  111136. * @returns the list of intersecting sub meshes
  111137. */
  111138. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111139. /**
  111140. * Return the list of sub meshes colliding with a collider
  111141. * @param mesh defines the mesh to find the submesh for
  111142. * @param collider defines the collider to evaluate the collision against
  111143. * @returns the list of colliding sub meshes
  111144. */
  111145. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111146. /**
  111147. * Rebuilds the elements related to this component in case of
  111148. * context lost for instance.
  111149. */
  111150. rebuild(): void;
  111151. /**
  111152. * Disposes the component and the associated ressources.
  111153. */
  111154. dispose(): void;
  111155. }
  111156. }
  111157. declare module BABYLON {
  111158. /**
  111159. * Renders a layer on top of an existing scene
  111160. */
  111161. export class UtilityLayerRenderer implements IDisposable {
  111162. /** the original scene that will be rendered on top of */
  111163. originalScene: Scene;
  111164. private _pointerCaptures;
  111165. private _lastPointerEvents;
  111166. private static _DefaultUtilityLayer;
  111167. private static _DefaultKeepDepthUtilityLayer;
  111168. private _sharedGizmoLight;
  111169. private _renderCamera;
  111170. /**
  111171. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111172. * @returns the camera that is used when rendering the utility layer
  111173. */
  111174. getRenderCamera(): Nullable<Camera>;
  111175. /**
  111176. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111177. * @param cam the camera that should be used when rendering the utility layer
  111178. */
  111179. setRenderCamera(cam: Nullable<Camera>): void;
  111180. /**
  111181. * @hidden
  111182. * Light which used by gizmos to get light shading
  111183. */
  111184. _getSharedGizmoLight(): HemisphericLight;
  111185. /**
  111186. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111187. */
  111188. pickUtilitySceneFirst: boolean;
  111189. /**
  111190. * 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)
  111191. */
  111192. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111193. /**
  111194. * 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)
  111195. */
  111196. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111197. /**
  111198. * The scene that is rendered on top of the original scene
  111199. */
  111200. utilityLayerScene: Scene;
  111201. /**
  111202. * If the utility layer should automatically be rendered on top of existing scene
  111203. */
  111204. shouldRender: boolean;
  111205. /**
  111206. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111207. */
  111208. onlyCheckPointerDownEvents: boolean;
  111209. /**
  111210. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111211. */
  111212. processAllEvents: boolean;
  111213. /**
  111214. * Observable raised when the pointer move from the utility layer scene to the main scene
  111215. */
  111216. onPointerOutObservable: Observable<number>;
  111217. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111218. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111219. private _afterRenderObserver;
  111220. private _sceneDisposeObserver;
  111221. private _originalPointerObserver;
  111222. /**
  111223. * Instantiates a UtilityLayerRenderer
  111224. * @param originalScene the original scene that will be rendered on top of
  111225. * @param handleEvents boolean indicating if the utility layer should handle events
  111226. */
  111227. constructor(
  111228. /** the original scene that will be rendered on top of */
  111229. originalScene: Scene, handleEvents?: boolean);
  111230. private _notifyObservers;
  111231. /**
  111232. * Renders the utility layers scene on top of the original scene
  111233. */
  111234. render(): void;
  111235. /**
  111236. * Disposes of the renderer
  111237. */
  111238. dispose(): void;
  111239. private _updateCamera;
  111240. }
  111241. }
  111242. declare module BABYLON {
  111243. /**
  111244. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111245. */
  111246. export class Gizmo implements IDisposable {
  111247. /** The utility layer the gizmo will be added to */
  111248. gizmoLayer: UtilityLayerRenderer;
  111249. /**
  111250. * The root mesh of the gizmo
  111251. */
  111252. _rootMesh: Mesh;
  111253. private _attachedMesh;
  111254. /**
  111255. * Ratio for the scale of the gizmo (Default: 1)
  111256. */
  111257. scaleRatio: number;
  111258. /**
  111259. * If a custom mesh has been set (Default: false)
  111260. */
  111261. protected _customMeshSet: boolean;
  111262. /**
  111263. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111264. * * When set, interactions will be enabled
  111265. */
  111266. attachedMesh: Nullable<AbstractMesh>;
  111267. /**
  111268. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111269. * @param mesh The mesh to replace the default mesh of the gizmo
  111270. */
  111271. setCustomMesh(mesh: Mesh): void;
  111272. /**
  111273. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111274. */
  111275. updateGizmoRotationToMatchAttachedMesh: boolean;
  111276. /**
  111277. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111278. */
  111279. updateGizmoPositionToMatchAttachedMesh: boolean;
  111280. /**
  111281. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111282. */
  111283. updateScale: boolean;
  111284. protected _interactionsEnabled: boolean;
  111285. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111286. private _beforeRenderObserver;
  111287. private _tempVector;
  111288. /**
  111289. * Creates a gizmo
  111290. * @param gizmoLayer The utility layer the gizmo will be added to
  111291. */
  111292. constructor(
  111293. /** The utility layer the gizmo will be added to */
  111294. gizmoLayer?: UtilityLayerRenderer);
  111295. /**
  111296. * Updates the gizmo to match the attached mesh's position/rotation
  111297. */
  111298. protected _update(): void;
  111299. /**
  111300. * Disposes of the gizmo
  111301. */
  111302. dispose(): void;
  111303. }
  111304. }
  111305. declare module BABYLON {
  111306. /**
  111307. * Single plane drag gizmo
  111308. */
  111309. export class PlaneDragGizmo extends Gizmo {
  111310. /**
  111311. * Drag behavior responsible for the gizmos dragging interactions
  111312. */
  111313. dragBehavior: PointerDragBehavior;
  111314. private _pointerObserver;
  111315. /**
  111316. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111317. */
  111318. snapDistance: number;
  111319. /**
  111320. * Event that fires each time the gizmo snaps to a new location.
  111321. * * snapDistance is the the change in distance
  111322. */
  111323. onSnapObservable: Observable<{
  111324. snapDistance: number;
  111325. }>;
  111326. private _plane;
  111327. private _coloredMaterial;
  111328. private _hoverMaterial;
  111329. private _isEnabled;
  111330. private _parent;
  111331. /** @hidden */
  111332. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111333. /** @hidden */
  111334. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111335. /**
  111336. * Creates a PlaneDragGizmo
  111337. * @param gizmoLayer The utility layer the gizmo will be added to
  111338. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111339. * @param color The color of the gizmo
  111340. */
  111341. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111342. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111343. /**
  111344. * If the gizmo is enabled
  111345. */
  111346. isEnabled: boolean;
  111347. /**
  111348. * Disposes of the gizmo
  111349. */
  111350. dispose(): void;
  111351. }
  111352. }
  111353. declare module BABYLON {
  111354. /**
  111355. * Gizmo that enables dragging a mesh along 3 axis
  111356. */
  111357. export class PositionGizmo extends Gizmo {
  111358. /**
  111359. * Internal gizmo used for interactions on the x axis
  111360. */
  111361. xGizmo: AxisDragGizmo;
  111362. /**
  111363. * Internal gizmo used for interactions on the y axis
  111364. */
  111365. yGizmo: AxisDragGizmo;
  111366. /**
  111367. * Internal gizmo used for interactions on the z axis
  111368. */
  111369. zGizmo: AxisDragGizmo;
  111370. /**
  111371. * Internal gizmo used for interactions on the yz plane
  111372. */
  111373. xPlaneGizmo: PlaneDragGizmo;
  111374. /**
  111375. * Internal gizmo used for interactions on the xz plane
  111376. */
  111377. yPlaneGizmo: PlaneDragGizmo;
  111378. /**
  111379. * Internal gizmo used for interactions on the xy plane
  111380. */
  111381. zPlaneGizmo: PlaneDragGizmo;
  111382. /**
  111383. * private variables
  111384. */
  111385. private _meshAttached;
  111386. private _updateGizmoRotationToMatchAttachedMesh;
  111387. private _snapDistance;
  111388. private _scaleRatio;
  111389. /** Fires an event when any of it's sub gizmos are dragged */
  111390. onDragStartObservable: Observable<unknown>;
  111391. /** Fires an event when any of it's sub gizmos are released from dragging */
  111392. onDragEndObservable: Observable<unknown>;
  111393. /**
  111394. * If set to true, planar drag is enabled
  111395. */
  111396. private _planarGizmoEnabled;
  111397. attachedMesh: Nullable<AbstractMesh>;
  111398. /**
  111399. * Creates a PositionGizmo
  111400. * @param gizmoLayer The utility layer the gizmo will be added to
  111401. */
  111402. constructor(gizmoLayer?: UtilityLayerRenderer);
  111403. /**
  111404. * If the planar drag gizmo is enabled
  111405. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111406. */
  111407. planarGizmoEnabled: boolean;
  111408. updateGizmoRotationToMatchAttachedMesh: boolean;
  111409. /**
  111410. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111411. */
  111412. snapDistance: number;
  111413. /**
  111414. * Ratio for the scale of the gizmo (Default: 1)
  111415. */
  111416. scaleRatio: number;
  111417. /**
  111418. * Disposes of the gizmo
  111419. */
  111420. dispose(): void;
  111421. /**
  111422. * CustomMeshes are not supported by this gizmo
  111423. * @param mesh The mesh to replace the default mesh of the gizmo
  111424. */
  111425. setCustomMesh(mesh: Mesh): void;
  111426. }
  111427. }
  111428. declare module BABYLON {
  111429. /**
  111430. * Single axis drag gizmo
  111431. */
  111432. export class AxisDragGizmo extends Gizmo {
  111433. /**
  111434. * Drag behavior responsible for the gizmos dragging interactions
  111435. */
  111436. dragBehavior: PointerDragBehavior;
  111437. private _pointerObserver;
  111438. /**
  111439. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111440. */
  111441. snapDistance: number;
  111442. /**
  111443. * Event that fires each time the gizmo snaps to a new location.
  111444. * * snapDistance is the the change in distance
  111445. */
  111446. onSnapObservable: Observable<{
  111447. snapDistance: number;
  111448. }>;
  111449. private _isEnabled;
  111450. private _parent;
  111451. private _arrow;
  111452. private _coloredMaterial;
  111453. private _hoverMaterial;
  111454. /** @hidden */
  111455. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111456. /** @hidden */
  111457. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111458. /**
  111459. * Creates an AxisDragGizmo
  111460. * @param gizmoLayer The utility layer the gizmo will be added to
  111461. * @param dragAxis The axis which the gizmo will be able to drag on
  111462. * @param color The color of the gizmo
  111463. */
  111464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111466. /**
  111467. * If the gizmo is enabled
  111468. */
  111469. isEnabled: boolean;
  111470. /**
  111471. * Disposes of the gizmo
  111472. */
  111473. dispose(): void;
  111474. }
  111475. }
  111476. declare module BABYLON.Debug {
  111477. /**
  111478. * The Axes viewer will show 3 axes in a specific point in space
  111479. */
  111480. export class AxesViewer {
  111481. private _xAxis;
  111482. private _yAxis;
  111483. private _zAxis;
  111484. private _scaleLinesFactor;
  111485. private _instanced;
  111486. /**
  111487. * Gets the hosting scene
  111488. */
  111489. scene: Scene;
  111490. /**
  111491. * Gets or sets a number used to scale line length
  111492. */
  111493. scaleLines: number;
  111494. /** Gets the node hierarchy used to render x-axis */
  111495. readonly xAxis: TransformNode;
  111496. /** Gets the node hierarchy used to render y-axis */
  111497. readonly yAxis: TransformNode;
  111498. /** Gets the node hierarchy used to render z-axis */
  111499. readonly zAxis: TransformNode;
  111500. /**
  111501. * Creates a new AxesViewer
  111502. * @param scene defines the hosting scene
  111503. * @param scaleLines defines a number used to scale line length (1 by default)
  111504. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111505. * @param xAxis defines the node hierarchy used to render the x-axis
  111506. * @param yAxis defines the node hierarchy used to render the y-axis
  111507. * @param zAxis defines the node hierarchy used to render the z-axis
  111508. */
  111509. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111510. /**
  111511. * Force the viewer to update
  111512. * @param position defines the position of the viewer
  111513. * @param xaxis defines the x axis of the viewer
  111514. * @param yaxis defines the y axis of the viewer
  111515. * @param zaxis defines the z axis of the viewer
  111516. */
  111517. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111518. /**
  111519. * Creates an instance of this axes viewer.
  111520. * @returns a new axes viewer with instanced meshes
  111521. */
  111522. createInstance(): AxesViewer;
  111523. /** Releases resources */
  111524. dispose(): void;
  111525. private static _SetRenderingGroupId;
  111526. }
  111527. }
  111528. declare module BABYLON.Debug {
  111529. /**
  111530. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111531. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111532. */
  111533. export class BoneAxesViewer extends AxesViewer {
  111534. /**
  111535. * Gets or sets the target mesh where to display the axes viewer
  111536. */
  111537. mesh: Nullable<Mesh>;
  111538. /**
  111539. * Gets or sets the target bone where to display the axes viewer
  111540. */
  111541. bone: Nullable<Bone>;
  111542. /** Gets current position */
  111543. pos: Vector3;
  111544. /** Gets direction of X axis */
  111545. xaxis: Vector3;
  111546. /** Gets direction of Y axis */
  111547. yaxis: Vector3;
  111548. /** Gets direction of Z axis */
  111549. zaxis: Vector3;
  111550. /**
  111551. * Creates a new BoneAxesViewer
  111552. * @param scene defines the hosting scene
  111553. * @param bone defines the target bone
  111554. * @param mesh defines the target mesh
  111555. * @param scaleLines defines a scaling factor for line length (1 by default)
  111556. */
  111557. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111558. /**
  111559. * Force the viewer to update
  111560. */
  111561. update(): void;
  111562. /** Releases resources */
  111563. dispose(): void;
  111564. }
  111565. }
  111566. declare module BABYLON {
  111567. /**
  111568. * Interface used to define scene explorer extensibility option
  111569. */
  111570. export interface IExplorerExtensibilityOption {
  111571. /**
  111572. * Define the option label
  111573. */
  111574. label: string;
  111575. /**
  111576. * Defines the action to execute on click
  111577. */
  111578. action: (entity: any) => void;
  111579. }
  111580. /**
  111581. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111582. */
  111583. export interface IExplorerExtensibilityGroup {
  111584. /**
  111585. * Defines a predicate to test if a given type mut be extended
  111586. */
  111587. predicate: (entity: any) => boolean;
  111588. /**
  111589. * Gets the list of options added to a type
  111590. */
  111591. entries: IExplorerExtensibilityOption[];
  111592. }
  111593. /**
  111594. * Interface used to define the options to use to create the Inspector
  111595. */
  111596. export interface IInspectorOptions {
  111597. /**
  111598. * Display in overlay mode (default: false)
  111599. */
  111600. overlay?: boolean;
  111601. /**
  111602. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111603. */
  111604. globalRoot?: HTMLElement;
  111605. /**
  111606. * Display the Scene explorer
  111607. */
  111608. showExplorer?: boolean;
  111609. /**
  111610. * Display the property inspector
  111611. */
  111612. showInspector?: boolean;
  111613. /**
  111614. * Display in embed mode (both panes on the right)
  111615. */
  111616. embedMode?: boolean;
  111617. /**
  111618. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111619. */
  111620. handleResize?: boolean;
  111621. /**
  111622. * Allow the panes to popup (default: true)
  111623. */
  111624. enablePopup?: boolean;
  111625. /**
  111626. * Allow the panes to be closed by users (default: true)
  111627. */
  111628. enableClose?: boolean;
  111629. /**
  111630. * Optional list of extensibility entries
  111631. */
  111632. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111633. /**
  111634. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111635. */
  111636. inspectorURL?: string;
  111637. }
  111638. interface Scene {
  111639. /**
  111640. * @hidden
  111641. * Backing field
  111642. */
  111643. _debugLayer: DebugLayer;
  111644. /**
  111645. * Gets the debug layer (aka Inspector) associated with the scene
  111646. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111647. */
  111648. debugLayer: DebugLayer;
  111649. }
  111650. /**
  111651. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111652. * what is happening in your scene
  111653. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111654. */
  111655. export class DebugLayer {
  111656. /**
  111657. * Define the url to get the inspector script from.
  111658. * By default it uses the babylonjs CDN.
  111659. * @ignoreNaming
  111660. */
  111661. static InspectorURL: string;
  111662. private _scene;
  111663. private BJSINSPECTOR;
  111664. private _onPropertyChangedObservable?;
  111665. /**
  111666. * Observable triggered when a property is changed through the inspector.
  111667. */
  111668. readonly onPropertyChangedObservable: any;
  111669. /**
  111670. * Instantiates a new debug layer.
  111671. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111672. * what is happening in your scene
  111673. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111674. * @param scene Defines the scene to inspect
  111675. */
  111676. constructor(scene: Scene);
  111677. /** Creates the inspector window. */
  111678. private _createInspector;
  111679. /**
  111680. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111681. * @param entity defines the entity to select
  111682. * @param lineContainerTitle defines the specific block to highlight
  111683. */
  111684. select(entity: any, lineContainerTitle?: string): void;
  111685. /** Get the inspector from bundle or global */
  111686. private _getGlobalInspector;
  111687. /**
  111688. * Get if the inspector is visible or not.
  111689. * @returns true if visible otherwise, false
  111690. */
  111691. isVisible(): boolean;
  111692. /**
  111693. * Hide the inspector and close its window.
  111694. */
  111695. hide(): void;
  111696. /**
  111697. * Launch the debugLayer.
  111698. * @param config Define the configuration of the inspector
  111699. * @return a promise fulfilled when the debug layer is visible
  111700. */
  111701. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111702. }
  111703. }
  111704. declare module BABYLON {
  111705. /**
  111706. * Class containing static functions to help procedurally build meshes
  111707. */
  111708. export class BoxBuilder {
  111709. /**
  111710. * Creates a box mesh
  111711. * * The parameter `size` sets the size (float) of each box side (default 1)
  111712. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111713. * * 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)
  111714. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111718. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111719. * @param name defines the name of the mesh
  111720. * @param options defines the options used to create the mesh
  111721. * @param scene defines the hosting scene
  111722. * @returns the box mesh
  111723. */
  111724. static CreateBox(name: string, options: {
  111725. size?: number;
  111726. width?: number;
  111727. height?: number;
  111728. depth?: number;
  111729. faceUV?: Vector4[];
  111730. faceColors?: Color4[];
  111731. sideOrientation?: number;
  111732. frontUVs?: Vector4;
  111733. backUVs?: Vector4;
  111734. wrap?: boolean;
  111735. topBaseAt?: number;
  111736. bottomBaseAt?: number;
  111737. updatable?: boolean;
  111738. }, scene?: Nullable<Scene>): Mesh;
  111739. }
  111740. }
  111741. declare module BABYLON {
  111742. /**
  111743. * Class containing static functions to help procedurally build meshes
  111744. */
  111745. export class SphereBuilder {
  111746. /**
  111747. * Creates a sphere mesh
  111748. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111749. * * 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`)
  111750. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111751. * * 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
  111752. * * 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)
  111753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111756. * @param name defines the name of the mesh
  111757. * @param options defines the options used to create the mesh
  111758. * @param scene defines the hosting scene
  111759. * @returns the sphere mesh
  111760. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111761. */
  111762. static CreateSphere(name: string, options: {
  111763. segments?: number;
  111764. diameter?: number;
  111765. diameterX?: number;
  111766. diameterY?: number;
  111767. diameterZ?: number;
  111768. arc?: number;
  111769. slice?: number;
  111770. sideOrientation?: number;
  111771. frontUVs?: Vector4;
  111772. backUVs?: Vector4;
  111773. updatable?: boolean;
  111774. }, scene?: Nullable<Scene>): Mesh;
  111775. }
  111776. }
  111777. declare module BABYLON.Debug {
  111778. /**
  111779. * Used to show the physics impostor around the specific mesh
  111780. */
  111781. export class PhysicsViewer {
  111782. /** @hidden */
  111783. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111784. /** @hidden */
  111785. protected _meshes: Array<Nullable<AbstractMesh>>;
  111786. /** @hidden */
  111787. protected _scene: Nullable<Scene>;
  111788. /** @hidden */
  111789. protected _numMeshes: number;
  111790. /** @hidden */
  111791. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111792. private _renderFunction;
  111793. private _utilityLayer;
  111794. private _debugBoxMesh;
  111795. private _debugSphereMesh;
  111796. private _debugCylinderMesh;
  111797. private _debugMaterial;
  111798. private _debugMeshMeshes;
  111799. /**
  111800. * Creates a new PhysicsViewer
  111801. * @param scene defines the hosting scene
  111802. */
  111803. constructor(scene: Scene);
  111804. /** @hidden */
  111805. protected _updateDebugMeshes(): void;
  111806. /**
  111807. * Renders a specified physic impostor
  111808. * @param impostor defines the impostor to render
  111809. * @param targetMesh defines the mesh represented by the impostor
  111810. * @returns the new debug mesh used to render the impostor
  111811. */
  111812. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111813. /**
  111814. * Hides a specified physic impostor
  111815. * @param impostor defines the impostor to hide
  111816. */
  111817. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111818. private _getDebugMaterial;
  111819. private _getDebugBoxMesh;
  111820. private _getDebugSphereMesh;
  111821. private _getDebugCylinderMesh;
  111822. private _getDebugMeshMesh;
  111823. private _getDebugMesh;
  111824. /** Releases all resources */
  111825. dispose(): void;
  111826. }
  111827. }
  111828. declare module BABYLON {
  111829. /**
  111830. * Class containing static functions to help procedurally build meshes
  111831. */
  111832. export class LinesBuilder {
  111833. /**
  111834. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111835. * * 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
  111836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111837. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111838. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111839. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111841. * * 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
  111842. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111844. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111845. * @param name defines the name of the new line system
  111846. * @param options defines the options used to create the line system
  111847. * @param scene defines the hosting scene
  111848. * @returns a new line system mesh
  111849. */
  111850. static CreateLineSystem(name: string, options: {
  111851. lines: Vector3[][];
  111852. updatable?: boolean;
  111853. instance?: Nullable<LinesMesh>;
  111854. colors?: Nullable<Color4[][]>;
  111855. useVertexAlpha?: boolean;
  111856. }, scene: Nullable<Scene>): LinesMesh;
  111857. /**
  111858. * Creates a line mesh
  111859. * 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
  111860. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111861. * * The parameter `points` is an array successive Vector3
  111862. * * 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
  111863. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111864. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111865. * * When updating an instance, remember that only point positions can change, not the number of points
  111866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111868. * @param name defines the name of the new line system
  111869. * @param options defines the options used to create the line system
  111870. * @param scene defines the hosting scene
  111871. * @returns a new line mesh
  111872. */
  111873. static CreateLines(name: string, options: {
  111874. points: Vector3[];
  111875. updatable?: boolean;
  111876. instance?: Nullable<LinesMesh>;
  111877. colors?: Color4[];
  111878. useVertexAlpha?: boolean;
  111879. }, scene?: Nullable<Scene>): LinesMesh;
  111880. /**
  111881. * Creates a dashed line mesh
  111882. * * 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
  111883. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111884. * * The parameter `points` is an array successive Vector3
  111885. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111886. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111887. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111888. * * 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
  111889. * * When updating an instance, remember that only point positions can change, not the number of points
  111890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111891. * @param name defines the name of the mesh
  111892. * @param options defines the options used to create the mesh
  111893. * @param scene defines the hosting scene
  111894. * @returns the dashed line mesh
  111895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111896. */
  111897. static CreateDashedLines(name: string, options: {
  111898. points: Vector3[];
  111899. dashSize?: number;
  111900. gapSize?: number;
  111901. dashNb?: number;
  111902. updatable?: boolean;
  111903. instance?: LinesMesh;
  111904. }, scene?: Nullable<Scene>): LinesMesh;
  111905. }
  111906. }
  111907. declare module BABYLON {
  111908. /**
  111909. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111910. * in order to better appreciate the issue one might have.
  111911. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111912. */
  111913. export class RayHelper {
  111914. /**
  111915. * Defines the ray we are currently tryin to visualize.
  111916. */
  111917. ray: Nullable<Ray>;
  111918. private _renderPoints;
  111919. private _renderLine;
  111920. private _renderFunction;
  111921. private _scene;
  111922. private _updateToMeshFunction;
  111923. private _attachedToMesh;
  111924. private _meshSpaceDirection;
  111925. private _meshSpaceOrigin;
  111926. /**
  111927. * Helper function to create a colored helper in a scene in one line.
  111928. * @param ray Defines the ray we are currently tryin to visualize
  111929. * @param scene Defines the scene the ray is used in
  111930. * @param color Defines the color we want to see the ray in
  111931. * @returns The newly created ray helper.
  111932. */
  111933. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111934. /**
  111935. * Instantiate a new ray helper.
  111936. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111937. * in order to better appreciate the issue one might have.
  111938. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111939. * @param ray Defines the ray we are currently tryin to visualize
  111940. */
  111941. constructor(ray: Ray);
  111942. /**
  111943. * Shows the ray we are willing to debug.
  111944. * @param scene Defines the scene the ray needs to be rendered in
  111945. * @param color Defines the color the ray needs to be rendered in
  111946. */
  111947. show(scene: Scene, color?: Color3): void;
  111948. /**
  111949. * Hides the ray we are debugging.
  111950. */
  111951. hide(): void;
  111952. private _render;
  111953. /**
  111954. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111955. * @param mesh Defines the mesh we want the helper attached to
  111956. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111957. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111958. * @param length Defines the length of the ray
  111959. */
  111960. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111961. /**
  111962. * Detach the ray helper from the mesh it has previously been attached to.
  111963. */
  111964. detachFromMesh(): void;
  111965. private _updateToMesh;
  111966. /**
  111967. * Dispose the helper and release its associated resources.
  111968. */
  111969. dispose(): void;
  111970. }
  111971. }
  111972. declare module BABYLON.Debug {
  111973. /**
  111974. * Class used to render a debug view of a given skeleton
  111975. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111976. */
  111977. export class SkeletonViewer {
  111978. /** defines the skeleton to render */
  111979. skeleton: Skeleton;
  111980. /** defines the mesh attached to the skeleton */
  111981. mesh: AbstractMesh;
  111982. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111983. autoUpdateBonesMatrices: boolean;
  111984. /** defines the rendering group id to use with the viewer */
  111985. renderingGroupId: number;
  111986. /** Gets or sets the color used to render the skeleton */
  111987. color: Color3;
  111988. private _scene;
  111989. private _debugLines;
  111990. private _debugMesh;
  111991. private _isEnabled;
  111992. private _renderFunction;
  111993. private _utilityLayer;
  111994. /**
  111995. * Returns the mesh used to render the bones
  111996. */
  111997. readonly debugMesh: Nullable<LinesMesh>;
  111998. /**
  111999. * Creates a new SkeletonViewer
  112000. * @param skeleton defines the skeleton to render
  112001. * @param mesh defines the mesh attached to the skeleton
  112002. * @param scene defines the hosting scene
  112003. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112004. * @param renderingGroupId defines the rendering group id to use with the viewer
  112005. */
  112006. constructor(
  112007. /** defines the skeleton to render */
  112008. skeleton: Skeleton,
  112009. /** defines the mesh attached to the skeleton */
  112010. mesh: AbstractMesh, scene: Scene,
  112011. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112012. autoUpdateBonesMatrices?: boolean,
  112013. /** defines the rendering group id to use with the viewer */
  112014. renderingGroupId?: number);
  112015. /** Gets or sets a boolean indicating if the viewer is enabled */
  112016. isEnabled: boolean;
  112017. private _getBonePosition;
  112018. private _getLinesForBonesWithLength;
  112019. private _getLinesForBonesNoLength;
  112020. /** Update the viewer to sync with current skeleton state */
  112021. update(): void;
  112022. /** Release associated resources */
  112023. dispose(): void;
  112024. }
  112025. }
  112026. declare module BABYLON {
  112027. /**
  112028. * Options to create the null engine
  112029. */
  112030. export class NullEngineOptions {
  112031. /**
  112032. * Render width (Default: 512)
  112033. */
  112034. renderWidth: number;
  112035. /**
  112036. * Render height (Default: 256)
  112037. */
  112038. renderHeight: number;
  112039. /**
  112040. * Texture size (Default: 512)
  112041. */
  112042. textureSize: number;
  112043. /**
  112044. * If delta time between frames should be constant
  112045. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112046. */
  112047. deterministicLockstep: boolean;
  112048. /**
  112049. * Maximum about of steps between frames (Default: 4)
  112050. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112051. */
  112052. lockstepMaxSteps: number;
  112053. }
  112054. /**
  112055. * The null engine class provides support for headless version of babylon.js.
  112056. * This can be used in server side scenario or for testing purposes
  112057. */
  112058. export class NullEngine extends Engine {
  112059. private _options;
  112060. /**
  112061. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112062. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112063. * @returns true if engine is in deterministic lock step mode
  112064. */
  112065. isDeterministicLockStep(): boolean;
  112066. /**
  112067. * Gets the max steps when engine is running in deterministic lock step
  112068. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112069. * @returns the max steps
  112070. */
  112071. getLockstepMaxSteps(): number;
  112072. /**
  112073. * Gets the current hardware scaling level.
  112074. * By default the hardware scaling level is computed from the window device ratio.
  112075. * 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.
  112076. * @returns a number indicating the current hardware scaling level
  112077. */
  112078. getHardwareScalingLevel(): number;
  112079. constructor(options?: NullEngineOptions);
  112080. /**
  112081. * Creates a vertex buffer
  112082. * @param vertices the data for the vertex buffer
  112083. * @returns the new WebGL static buffer
  112084. */
  112085. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112086. /**
  112087. * Creates a new index buffer
  112088. * @param indices defines the content of the index buffer
  112089. * @param updatable defines if the index buffer must be updatable
  112090. * @returns a new webGL buffer
  112091. */
  112092. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112093. /**
  112094. * Clear the current render buffer or the current render target (if any is set up)
  112095. * @param color defines the color to use
  112096. * @param backBuffer defines if the back buffer must be cleared
  112097. * @param depth defines if the depth buffer must be cleared
  112098. * @param stencil defines if the stencil buffer must be cleared
  112099. */
  112100. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112101. /**
  112102. * Gets the current render width
  112103. * @param useScreen defines if screen size must be used (or the current render target if any)
  112104. * @returns a number defining the current render width
  112105. */
  112106. getRenderWidth(useScreen?: boolean): number;
  112107. /**
  112108. * Gets the current render height
  112109. * @param useScreen defines if screen size must be used (or the current render target if any)
  112110. * @returns a number defining the current render height
  112111. */
  112112. getRenderHeight(useScreen?: boolean): number;
  112113. /**
  112114. * Set the WebGL's viewport
  112115. * @param viewport defines the viewport element to be used
  112116. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112117. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112118. */
  112119. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112120. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112121. /**
  112122. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112123. * @param pipelineContext defines the pipeline context to use
  112124. * @param uniformsNames defines the list of uniform names
  112125. * @returns an array of webGL uniform locations
  112126. */
  112127. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112128. /**
  112129. * Gets the lsit of active attributes for a given webGL program
  112130. * @param pipelineContext defines the pipeline context to use
  112131. * @param attributesNames defines the list of attribute names to get
  112132. * @returns an array of indices indicating the offset of each attribute
  112133. */
  112134. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112135. /**
  112136. * Binds an effect to the webGL context
  112137. * @param effect defines the effect to bind
  112138. */
  112139. bindSamplers(effect: Effect): void;
  112140. /**
  112141. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112142. * @param effect defines the effect to activate
  112143. */
  112144. enableEffect(effect: Effect): void;
  112145. /**
  112146. * Set various states to the webGL context
  112147. * @param culling defines backface culling state
  112148. * @param zOffset defines the value to apply to zOffset (0 by default)
  112149. * @param force defines if states must be applied even if cache is up to date
  112150. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112151. */
  112152. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112153. /**
  112154. * Set the value of an uniform to an array of int32
  112155. * @param uniform defines the webGL uniform location where to store the value
  112156. * @param array defines the array of int32 to store
  112157. */
  112158. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112159. /**
  112160. * Set the value of an uniform to an array of int32 (stored as vec2)
  112161. * @param uniform defines the webGL uniform location where to store the value
  112162. * @param array defines the array of int32 to store
  112163. */
  112164. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112165. /**
  112166. * Set the value of an uniform to an array of int32 (stored as vec3)
  112167. * @param uniform defines the webGL uniform location where to store the value
  112168. * @param array defines the array of int32 to store
  112169. */
  112170. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112171. /**
  112172. * Set the value of an uniform to an array of int32 (stored as vec4)
  112173. * @param uniform defines the webGL uniform location where to store the value
  112174. * @param array defines the array of int32 to store
  112175. */
  112176. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112177. /**
  112178. * Set the value of an uniform to an array of float32
  112179. * @param uniform defines the webGL uniform location where to store the value
  112180. * @param array defines the array of float32 to store
  112181. */
  112182. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112183. /**
  112184. * Set the value of an uniform to an array of float32 (stored as vec2)
  112185. * @param uniform defines the webGL uniform location where to store the value
  112186. * @param array defines the array of float32 to store
  112187. */
  112188. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112189. /**
  112190. * Set the value of an uniform to an array of float32 (stored as vec3)
  112191. * @param uniform defines the webGL uniform location where to store the value
  112192. * @param array defines the array of float32 to store
  112193. */
  112194. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112195. /**
  112196. * Set the value of an uniform to an array of float32 (stored as vec4)
  112197. * @param uniform defines the webGL uniform location where to store the value
  112198. * @param array defines the array of float32 to store
  112199. */
  112200. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112201. /**
  112202. * Set the value of an uniform to an array of number
  112203. * @param uniform defines the webGL uniform location where to store the value
  112204. * @param array defines the array of number to store
  112205. */
  112206. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112207. /**
  112208. * Set the value of an uniform to an array of number (stored as vec2)
  112209. * @param uniform defines the webGL uniform location where to store the value
  112210. * @param array defines the array of number to store
  112211. */
  112212. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112213. /**
  112214. * Set the value of an uniform to an array of number (stored as vec3)
  112215. * @param uniform defines the webGL uniform location where to store the value
  112216. * @param array defines the array of number to store
  112217. */
  112218. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112219. /**
  112220. * Set the value of an uniform to an array of number (stored as vec4)
  112221. * @param uniform defines the webGL uniform location where to store the value
  112222. * @param array defines the array of number to store
  112223. */
  112224. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112225. /**
  112226. * Set the value of an uniform to an array of float32 (stored as matrices)
  112227. * @param uniform defines the webGL uniform location where to store the value
  112228. * @param matrices defines the array of float32 to store
  112229. */
  112230. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112231. /**
  112232. * Set the value of an uniform to a matrix (3x3)
  112233. * @param uniform defines the webGL uniform location where to store the value
  112234. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112235. */
  112236. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112237. /**
  112238. * Set the value of an uniform to a matrix (2x2)
  112239. * @param uniform defines the webGL uniform location where to store the value
  112240. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112241. */
  112242. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112243. /**
  112244. * Set the value of an uniform to a number (float)
  112245. * @param uniform defines the webGL uniform location where to store the value
  112246. * @param value defines the float number to store
  112247. */
  112248. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112249. /**
  112250. * Set the value of an uniform to a vec2
  112251. * @param uniform defines the webGL uniform location where to store the value
  112252. * @param x defines the 1st component of the value
  112253. * @param y defines the 2nd component of the value
  112254. */
  112255. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112256. /**
  112257. * Set the value of an uniform to a vec3
  112258. * @param uniform defines the webGL uniform location where to store the value
  112259. * @param x defines the 1st component of the value
  112260. * @param y defines the 2nd component of the value
  112261. * @param z defines the 3rd component of the value
  112262. */
  112263. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112264. /**
  112265. * Set the value of an uniform to a boolean
  112266. * @param uniform defines the webGL uniform location where to store the value
  112267. * @param bool defines the boolean to store
  112268. */
  112269. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112270. /**
  112271. * Set the value of an uniform to a vec4
  112272. * @param uniform defines the webGL uniform location where to store the value
  112273. * @param x defines the 1st component of the value
  112274. * @param y defines the 2nd component of the value
  112275. * @param z defines the 3rd component of the value
  112276. * @param w defines the 4th component of the value
  112277. */
  112278. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112279. /**
  112280. * Sets the current alpha mode
  112281. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112282. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112283. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112284. */
  112285. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112286. /**
  112287. * Bind webGl buffers directly to the webGL context
  112288. * @param vertexBuffers defines the vertex buffer to bind
  112289. * @param indexBuffer defines the index buffer to bind
  112290. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112291. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112292. * @param effect defines the effect associated with the vertex buffer
  112293. */
  112294. bindBuffers(vertexBuffers: {
  112295. [key: string]: VertexBuffer;
  112296. }, indexBuffer: DataBuffer, effect: Effect): void;
  112297. /**
  112298. * Force the entire cache to be cleared
  112299. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112300. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112301. */
  112302. wipeCaches(bruteForce?: boolean): void;
  112303. /**
  112304. * Send a draw order
  112305. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112306. * @param indexStart defines the starting index
  112307. * @param indexCount defines the number of index to draw
  112308. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112309. */
  112310. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112311. /**
  112312. * Draw a list of indexed primitives
  112313. * @param fillMode defines the primitive to use
  112314. * @param indexStart defines the starting index
  112315. * @param indexCount defines the number of index to draw
  112316. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112317. */
  112318. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112319. /**
  112320. * Draw a list of unindexed primitives
  112321. * @param fillMode defines the primitive to use
  112322. * @param verticesStart defines the index of first vertex to draw
  112323. * @param verticesCount defines the count of vertices to draw
  112324. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112325. */
  112326. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112327. /** @hidden */
  112328. _createTexture(): WebGLTexture;
  112329. /** @hidden */
  112330. _releaseTexture(texture: InternalTexture): void;
  112331. /**
  112332. * Usually called from Texture.ts.
  112333. * Passed information to create a WebGLTexture
  112334. * @param urlArg defines a value which contains one of the following:
  112335. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112336. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112337. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112338. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112339. * @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)
  112340. * @param scene needed for loading to the correct scene
  112341. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112342. * @param onLoad optional callback to be called upon successful completion
  112343. * @param onError optional callback to be called upon failure
  112344. * @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
  112345. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112346. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112347. * @param forcedExtension defines the extension to use to pick the right loader
  112348. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112349. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112350. */
  112351. 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;
  112352. /**
  112353. * Creates a new render target texture
  112354. * @param size defines the size of the texture
  112355. * @param options defines the options used to create the texture
  112356. * @returns a new render target texture stored in an InternalTexture
  112357. */
  112358. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112359. /**
  112360. * Update the sampling mode of a given texture
  112361. * @param samplingMode defines the required sampling mode
  112362. * @param texture defines the texture to update
  112363. */
  112364. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112365. /**
  112366. * Binds the frame buffer to the specified texture.
  112367. * @param texture The texture to render to or null for the default canvas
  112368. * @param faceIndex The face of the texture to render to in case of cube texture
  112369. * @param requiredWidth The width of the target to render to
  112370. * @param requiredHeight The height of the target to render to
  112371. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112372. * @param depthStencilTexture The depth stencil texture to use to render
  112373. * @param lodLevel defines le lod level to bind to the frame buffer
  112374. */
  112375. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112376. /**
  112377. * Unbind the current render target texture from the webGL context
  112378. * @param texture defines the render target texture to unbind
  112379. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112380. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112381. */
  112382. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112383. /**
  112384. * Creates a dynamic vertex buffer
  112385. * @param vertices the data for the dynamic vertex buffer
  112386. * @returns the new WebGL dynamic buffer
  112387. */
  112388. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112389. /**
  112390. * Update the content of a dynamic texture
  112391. * @param texture defines the texture to update
  112392. * @param canvas defines the canvas containing the source
  112393. * @param invertY defines if data must be stored with Y axis inverted
  112394. * @param premulAlpha defines if alpha is stored as premultiplied
  112395. * @param format defines the format of the data
  112396. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112397. */
  112398. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112399. /**
  112400. * Gets a boolean indicating if all created effects are ready
  112401. * @returns true if all effects are ready
  112402. */
  112403. areAllEffectsReady(): boolean;
  112404. /**
  112405. * @hidden
  112406. * Get the current error code of the webGL context
  112407. * @returns the error code
  112408. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112409. */
  112410. getError(): number;
  112411. /** @hidden */
  112412. _getUnpackAlignement(): number;
  112413. /** @hidden */
  112414. _unpackFlipY(value: boolean): void;
  112415. /**
  112416. * Update a dynamic index buffer
  112417. * @param indexBuffer defines the target index buffer
  112418. * @param indices defines the data to update
  112419. * @param offset defines the offset in the target index buffer where update should start
  112420. */
  112421. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112422. /**
  112423. * Updates a dynamic vertex buffer.
  112424. * @param vertexBuffer the vertex buffer to update
  112425. * @param vertices the data used to update the vertex buffer
  112426. * @param byteOffset the byte offset of the data (optional)
  112427. * @param byteLength the byte length of the data (optional)
  112428. */
  112429. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112430. /** @hidden */
  112431. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112432. /** @hidden */
  112433. _bindTexture(channel: number, texture: InternalTexture): void;
  112434. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112435. /**
  112436. * 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
  112437. */
  112438. releaseEffects(): void;
  112439. displayLoadingUI(): void;
  112440. hideLoadingUI(): void;
  112441. /** @hidden */
  112442. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112443. /** @hidden */
  112444. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112445. /** @hidden */
  112446. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112447. /** @hidden */
  112448. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112449. }
  112450. }
  112451. declare module BABYLON {
  112452. /** @hidden */
  112453. export class _OcclusionDataStorage {
  112454. /** @hidden */
  112455. occlusionInternalRetryCounter: number;
  112456. /** @hidden */
  112457. isOcclusionQueryInProgress: boolean;
  112458. /** @hidden */
  112459. isOccluded: boolean;
  112460. /** @hidden */
  112461. occlusionRetryCount: number;
  112462. /** @hidden */
  112463. occlusionType: number;
  112464. /** @hidden */
  112465. occlusionQueryAlgorithmType: number;
  112466. }
  112467. interface Engine {
  112468. /**
  112469. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112470. * @return the new query
  112471. */
  112472. createQuery(): WebGLQuery;
  112473. /**
  112474. * Delete and release a webGL query
  112475. * @param query defines the query to delete
  112476. * @return the current engine
  112477. */
  112478. deleteQuery(query: WebGLQuery): Engine;
  112479. /**
  112480. * Check if a given query has resolved and got its value
  112481. * @param query defines the query to check
  112482. * @returns true if the query got its value
  112483. */
  112484. isQueryResultAvailable(query: WebGLQuery): boolean;
  112485. /**
  112486. * Gets the value of a given query
  112487. * @param query defines the query to check
  112488. * @returns the value of the query
  112489. */
  112490. getQueryResult(query: WebGLQuery): number;
  112491. /**
  112492. * Initiates an occlusion query
  112493. * @param algorithmType defines the algorithm to use
  112494. * @param query defines the query to use
  112495. * @returns the current engine
  112496. * @see http://doc.babylonjs.com/features/occlusionquery
  112497. */
  112498. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112499. /**
  112500. * Ends an occlusion query
  112501. * @see http://doc.babylonjs.com/features/occlusionquery
  112502. * @param algorithmType defines the algorithm to use
  112503. * @returns the current engine
  112504. */
  112505. endOcclusionQuery(algorithmType: number): Engine;
  112506. /**
  112507. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112508. * Please note that only one query can be issued at a time
  112509. * @returns a time token used to track the time span
  112510. */
  112511. startTimeQuery(): Nullable<_TimeToken>;
  112512. /**
  112513. * Ends a time query
  112514. * @param token defines the token used to measure the time span
  112515. * @returns the time spent (in ns)
  112516. */
  112517. endTimeQuery(token: _TimeToken): int;
  112518. /** @hidden */
  112519. _currentNonTimestampToken: Nullable<_TimeToken>;
  112520. /** @hidden */
  112521. _createTimeQuery(): WebGLQuery;
  112522. /** @hidden */
  112523. _deleteTimeQuery(query: WebGLQuery): void;
  112524. /** @hidden */
  112525. _getGlAlgorithmType(algorithmType: number): number;
  112526. /** @hidden */
  112527. _getTimeQueryResult(query: WebGLQuery): any;
  112528. /** @hidden */
  112529. _getTimeQueryAvailability(query: WebGLQuery): any;
  112530. }
  112531. interface AbstractMesh {
  112532. /**
  112533. * Backing filed
  112534. * @hidden
  112535. */
  112536. __occlusionDataStorage: _OcclusionDataStorage;
  112537. /**
  112538. * Access property
  112539. * @hidden
  112540. */
  112541. _occlusionDataStorage: _OcclusionDataStorage;
  112542. /**
  112543. * 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.
  112544. * The default value is -1 which means don't break the query and wait till the result
  112545. * @see http://doc.babylonjs.com/features/occlusionquery
  112546. */
  112547. occlusionRetryCount: number;
  112548. /**
  112549. * 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:
  112550. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112551. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112552. * * 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.
  112553. * @see http://doc.babylonjs.com/features/occlusionquery
  112554. */
  112555. occlusionType: number;
  112556. /**
  112557. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112558. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112559. * * 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.
  112560. * @see http://doc.babylonjs.com/features/occlusionquery
  112561. */
  112562. occlusionQueryAlgorithmType: number;
  112563. /**
  112564. * 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
  112565. * @see http://doc.babylonjs.com/features/occlusionquery
  112566. */
  112567. isOccluded: boolean;
  112568. /**
  112569. * Flag to check the progress status of the query
  112570. * @see http://doc.babylonjs.com/features/occlusionquery
  112571. */
  112572. isOcclusionQueryInProgress: boolean;
  112573. }
  112574. }
  112575. declare module BABYLON {
  112576. /** @hidden */
  112577. export var _forceTransformFeedbackToBundle: boolean;
  112578. interface Engine {
  112579. /**
  112580. * Creates a webGL transform feedback object
  112581. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112582. * @returns the webGL transform feedback object
  112583. */
  112584. createTransformFeedback(): WebGLTransformFeedback;
  112585. /**
  112586. * Delete a webGL transform feedback object
  112587. * @param value defines the webGL transform feedback object to delete
  112588. */
  112589. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112590. /**
  112591. * Bind a webGL transform feedback object to the webgl context
  112592. * @param value defines the webGL transform feedback object to bind
  112593. */
  112594. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112595. /**
  112596. * Begins a transform feedback operation
  112597. * @param usePoints defines if points or triangles must be used
  112598. */
  112599. beginTransformFeedback(usePoints: boolean): void;
  112600. /**
  112601. * Ends a transform feedback operation
  112602. */
  112603. endTransformFeedback(): void;
  112604. /**
  112605. * Specify the varyings to use with transform feedback
  112606. * @param program defines the associated webGL program
  112607. * @param value defines the list of strings representing the varying names
  112608. */
  112609. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112610. /**
  112611. * Bind a webGL buffer for a transform feedback operation
  112612. * @param value defines the webGL buffer to bind
  112613. */
  112614. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112615. }
  112616. }
  112617. declare module BABYLON {
  112618. /**
  112619. * Creation options of the multi render target texture.
  112620. */
  112621. export interface IMultiRenderTargetOptions {
  112622. /**
  112623. * Define if the texture needs to create mip maps after render.
  112624. */
  112625. generateMipMaps?: boolean;
  112626. /**
  112627. * Define the types of all the draw buffers we want to create
  112628. */
  112629. types?: number[];
  112630. /**
  112631. * Define the sampling modes of all the draw buffers we want to create
  112632. */
  112633. samplingModes?: number[];
  112634. /**
  112635. * Define if a depth buffer is required
  112636. */
  112637. generateDepthBuffer?: boolean;
  112638. /**
  112639. * Define if a stencil buffer is required
  112640. */
  112641. generateStencilBuffer?: boolean;
  112642. /**
  112643. * Define if a depth texture is required instead of a depth buffer
  112644. */
  112645. generateDepthTexture?: boolean;
  112646. /**
  112647. * Define the number of desired draw buffers
  112648. */
  112649. textureCount?: number;
  112650. /**
  112651. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112652. */
  112653. doNotChangeAspectRatio?: boolean;
  112654. /**
  112655. * Define the default type of the buffers we are creating
  112656. */
  112657. defaultType?: number;
  112658. }
  112659. /**
  112660. * A multi render target, like a render target provides the ability to render to a texture.
  112661. * Unlike the render target, it can render to several draw buffers in one draw.
  112662. * This is specially interesting in deferred rendering or for any effects requiring more than
  112663. * just one color from a single pass.
  112664. */
  112665. export class MultiRenderTarget extends RenderTargetTexture {
  112666. private _internalTextures;
  112667. private _textures;
  112668. private _multiRenderTargetOptions;
  112669. /**
  112670. * Get if draw buffers are currently supported by the used hardware and browser.
  112671. */
  112672. readonly isSupported: boolean;
  112673. /**
  112674. * Get the list of textures generated by the multi render target.
  112675. */
  112676. readonly textures: Texture[];
  112677. /**
  112678. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112679. */
  112680. readonly depthTexture: Texture;
  112681. /**
  112682. * Set the wrapping mode on U of all the textures we are rendering to.
  112683. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112684. */
  112685. wrapU: number;
  112686. /**
  112687. * Set the wrapping mode on V of all the textures we are rendering to.
  112688. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112689. */
  112690. wrapV: number;
  112691. /**
  112692. * Instantiate a new multi render target texture.
  112693. * A multi render target, like a render target provides the ability to render to a texture.
  112694. * Unlike the render target, it can render to several draw buffers in one draw.
  112695. * This is specially interesting in deferred rendering or for any effects requiring more than
  112696. * just one color from a single pass.
  112697. * @param name Define the name of the texture
  112698. * @param size Define the size of the buffers to render to
  112699. * @param count Define the number of target we are rendering into
  112700. * @param scene Define the scene the texture belongs to
  112701. * @param options Define the options used to create the multi render target
  112702. */
  112703. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112704. /** @hidden */
  112705. _rebuild(): void;
  112706. private _createInternalTextures;
  112707. private _createTextures;
  112708. /**
  112709. * Define the number of samples used if MSAA is enabled.
  112710. */
  112711. samples: number;
  112712. /**
  112713. * Resize all the textures in the multi render target.
  112714. * Be carrefull as it will recreate all the data in the new texture.
  112715. * @param size Define the new size
  112716. */
  112717. resize(size: any): void;
  112718. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112719. /**
  112720. * Dispose the render targets and their associated resources
  112721. */
  112722. dispose(): void;
  112723. /**
  112724. * Release all the underlying texture used as draw buffers.
  112725. */
  112726. releaseInternalTextures(): void;
  112727. }
  112728. }
  112729. declare module BABYLON {
  112730. interface ThinEngine {
  112731. /**
  112732. * Unbind a list of render target textures from the webGL context
  112733. * This is used only when drawBuffer extension or webGL2 are active
  112734. * @param textures defines the render target textures to unbind
  112735. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112736. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112737. */
  112738. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112739. /**
  112740. * Create a multi render target texture
  112741. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112742. * @param size defines the size of the texture
  112743. * @param options defines the creation options
  112744. * @returns the cube texture as an InternalTexture
  112745. */
  112746. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112747. /**
  112748. * Update the sample count for a given multiple render target texture
  112749. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112750. * @param textures defines the textures to update
  112751. * @param samples defines the sample count to set
  112752. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112753. */
  112754. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112755. }
  112756. }
  112757. declare module BABYLON {
  112758. /**
  112759. * Class used to define an additional view for the engine
  112760. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112761. */
  112762. export class EngineView {
  112763. /** Defines the canvas where to render the view */
  112764. target: HTMLCanvasElement;
  112765. /** Defines an optional camera used to render the view (will use active camera else) */
  112766. camera?: Camera;
  112767. }
  112768. interface Engine {
  112769. /**
  112770. * Gets or sets the HTML element to use for attaching events
  112771. */
  112772. inputElement: Nullable<HTMLElement>;
  112773. /**
  112774. * Gets the current engine view
  112775. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112776. */
  112777. activeView: Nullable<EngineView>;
  112778. /** Gets or sets the list of views */
  112779. views: EngineView[];
  112780. /**
  112781. * Register a new child canvas
  112782. * @param canvas defines the canvas to register
  112783. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  112784. * @returns the associated view
  112785. */
  112786. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  112787. /**
  112788. * Remove a registered child canvas
  112789. * @param canvas defines the canvas to remove
  112790. * @returns the current engine
  112791. */
  112792. unRegisterView(canvas: HTMLCanvasElement): Engine;
  112793. }
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112798. */
  112799. export interface CubeMapInfo {
  112800. /**
  112801. * The pixel array for the front face.
  112802. * This is stored in format, left to right, up to down format.
  112803. */
  112804. front: Nullable<ArrayBufferView>;
  112805. /**
  112806. * The pixel array for the back face.
  112807. * This is stored in format, left to right, up to down format.
  112808. */
  112809. back: Nullable<ArrayBufferView>;
  112810. /**
  112811. * The pixel array for the left face.
  112812. * This is stored in format, left to right, up to down format.
  112813. */
  112814. left: Nullable<ArrayBufferView>;
  112815. /**
  112816. * The pixel array for the right face.
  112817. * This is stored in format, left to right, up to down format.
  112818. */
  112819. right: Nullable<ArrayBufferView>;
  112820. /**
  112821. * The pixel array for the up face.
  112822. * This is stored in format, left to right, up to down format.
  112823. */
  112824. up: Nullable<ArrayBufferView>;
  112825. /**
  112826. * The pixel array for the down face.
  112827. * This is stored in format, left to right, up to down format.
  112828. */
  112829. down: Nullable<ArrayBufferView>;
  112830. /**
  112831. * The size of the cubemap stored.
  112832. *
  112833. * Each faces will be size * size pixels.
  112834. */
  112835. size: number;
  112836. /**
  112837. * The format of the texture.
  112838. *
  112839. * RGBA, RGB.
  112840. */
  112841. format: number;
  112842. /**
  112843. * The type of the texture data.
  112844. *
  112845. * UNSIGNED_INT, FLOAT.
  112846. */
  112847. type: number;
  112848. /**
  112849. * Specifies whether the texture is in gamma space.
  112850. */
  112851. gammaSpace: boolean;
  112852. }
  112853. /**
  112854. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112855. */
  112856. export class PanoramaToCubeMapTools {
  112857. private static FACE_FRONT;
  112858. private static FACE_BACK;
  112859. private static FACE_RIGHT;
  112860. private static FACE_LEFT;
  112861. private static FACE_DOWN;
  112862. private static FACE_UP;
  112863. /**
  112864. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112865. *
  112866. * @param float32Array The source data.
  112867. * @param inputWidth The width of the input panorama.
  112868. * @param inputHeight The height of the input panorama.
  112869. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112870. * @return The cubemap data
  112871. */
  112872. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112873. private static CreateCubemapTexture;
  112874. private static CalcProjectionSpherical;
  112875. }
  112876. }
  112877. declare module BABYLON {
  112878. /**
  112879. * Helper class dealing with the extraction of spherical polynomial dataArray
  112880. * from a cube map.
  112881. */
  112882. export class CubeMapToSphericalPolynomialTools {
  112883. private static FileFaces;
  112884. /**
  112885. * Converts a texture to the according Spherical Polynomial data.
  112886. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112887. *
  112888. * @param texture The texture to extract the information from.
  112889. * @return The Spherical Polynomial data.
  112890. */
  112891. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112892. /**
  112893. * Converts a cubemap to the according Spherical Polynomial data.
  112894. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112895. *
  112896. * @param cubeInfo The Cube map to extract the information from.
  112897. * @return The Spherical Polynomial data.
  112898. */
  112899. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112900. }
  112901. }
  112902. declare module BABYLON {
  112903. interface BaseTexture {
  112904. /**
  112905. * Get the polynomial representation of the texture data.
  112906. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112907. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112908. */
  112909. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112910. }
  112911. }
  112912. declare module BABYLON {
  112913. /** @hidden */
  112914. export var rgbdEncodePixelShader: {
  112915. name: string;
  112916. shader: string;
  112917. };
  112918. }
  112919. declare module BABYLON {
  112920. /** @hidden */
  112921. export var rgbdDecodePixelShader: {
  112922. name: string;
  112923. shader: string;
  112924. };
  112925. }
  112926. declare module BABYLON {
  112927. /**
  112928. * Raw texture data and descriptor sufficient for WebGL texture upload
  112929. */
  112930. export interface EnvironmentTextureInfo {
  112931. /**
  112932. * Version of the environment map
  112933. */
  112934. version: number;
  112935. /**
  112936. * Width of image
  112937. */
  112938. width: number;
  112939. /**
  112940. * Irradiance information stored in the file.
  112941. */
  112942. irradiance: any;
  112943. /**
  112944. * Specular information stored in the file.
  112945. */
  112946. specular: any;
  112947. }
  112948. /**
  112949. * Defines One Image in the file. It requires only the position in the file
  112950. * as well as the length.
  112951. */
  112952. interface BufferImageData {
  112953. /**
  112954. * Length of the image data.
  112955. */
  112956. length: number;
  112957. /**
  112958. * Position of the data from the null terminator delimiting the end of the JSON.
  112959. */
  112960. position: number;
  112961. }
  112962. /**
  112963. * Defines the specular data enclosed in the file.
  112964. * This corresponds to the version 1 of the data.
  112965. */
  112966. export interface EnvironmentTextureSpecularInfoV1 {
  112967. /**
  112968. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112969. */
  112970. specularDataPosition?: number;
  112971. /**
  112972. * This contains all the images data needed to reconstruct the cubemap.
  112973. */
  112974. mipmaps: Array<BufferImageData>;
  112975. /**
  112976. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112977. */
  112978. lodGenerationScale: number;
  112979. }
  112980. /**
  112981. * Sets of helpers addressing the serialization and deserialization of environment texture
  112982. * stored in a BabylonJS env file.
  112983. * Those files are usually stored as .env files.
  112984. */
  112985. export class EnvironmentTextureTools {
  112986. /**
  112987. * Magic number identifying the env file.
  112988. */
  112989. private static _MagicBytes;
  112990. /**
  112991. * Gets the environment info from an env file.
  112992. * @param data The array buffer containing the .env bytes.
  112993. * @returns the environment file info (the json header) if successfully parsed.
  112994. */
  112995. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112996. /**
  112997. * Creates an environment texture from a loaded cube texture.
  112998. * @param texture defines the cube texture to convert in env file
  112999. * @return a promise containing the environment data if succesfull.
  113000. */
  113001. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113002. /**
  113003. * Creates a JSON representation of the spherical data.
  113004. * @param texture defines the texture containing the polynomials
  113005. * @return the JSON representation of the spherical info
  113006. */
  113007. private static _CreateEnvTextureIrradiance;
  113008. /**
  113009. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113010. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113011. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113012. * @return the views described by info providing access to the underlying buffer
  113013. */
  113014. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113015. /**
  113016. * Uploads the texture info contained in the env file to the GPU.
  113017. * @param texture defines the internal texture to upload to
  113018. * @param arrayBuffer defines the buffer cotaining the data to load
  113019. * @param info defines the texture info retrieved through the GetEnvInfo method
  113020. * @returns a promise
  113021. */
  113022. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113023. private static _OnImageReadyAsync;
  113024. /**
  113025. * Uploads the levels of image data to the GPU.
  113026. * @param texture defines the internal texture to upload to
  113027. * @param imageData defines the array buffer views of image data [mipmap][face]
  113028. * @returns a promise
  113029. */
  113030. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113031. /**
  113032. * Uploads spherical polynomials information to the texture.
  113033. * @param texture defines the texture we are trying to upload the information to
  113034. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113035. */
  113036. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113037. /** @hidden */
  113038. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113039. }
  113040. }
  113041. declare module BABYLON {
  113042. /**
  113043. * Contains position and normal vectors for a vertex
  113044. */
  113045. export class PositionNormalVertex {
  113046. /** the position of the vertex (defaut: 0,0,0) */
  113047. position: Vector3;
  113048. /** the normal of the vertex (defaut: 0,1,0) */
  113049. normal: Vector3;
  113050. /**
  113051. * Creates a PositionNormalVertex
  113052. * @param position the position of the vertex (defaut: 0,0,0)
  113053. * @param normal the normal of the vertex (defaut: 0,1,0)
  113054. */
  113055. constructor(
  113056. /** the position of the vertex (defaut: 0,0,0) */
  113057. position?: Vector3,
  113058. /** the normal of the vertex (defaut: 0,1,0) */
  113059. normal?: Vector3);
  113060. /**
  113061. * Clones the PositionNormalVertex
  113062. * @returns the cloned PositionNormalVertex
  113063. */
  113064. clone(): PositionNormalVertex;
  113065. }
  113066. /**
  113067. * Contains position, normal and uv vectors for a vertex
  113068. */
  113069. export class PositionNormalTextureVertex {
  113070. /** the position of the vertex (defaut: 0,0,0) */
  113071. position: Vector3;
  113072. /** the normal of the vertex (defaut: 0,1,0) */
  113073. normal: Vector3;
  113074. /** the uv of the vertex (default: 0,0) */
  113075. uv: Vector2;
  113076. /**
  113077. * Creates a PositionNormalTextureVertex
  113078. * @param position the position of the vertex (defaut: 0,0,0)
  113079. * @param normal the normal of the vertex (defaut: 0,1,0)
  113080. * @param uv the uv of the vertex (default: 0,0)
  113081. */
  113082. constructor(
  113083. /** the position of the vertex (defaut: 0,0,0) */
  113084. position?: Vector3,
  113085. /** the normal of the vertex (defaut: 0,1,0) */
  113086. normal?: Vector3,
  113087. /** the uv of the vertex (default: 0,0) */
  113088. uv?: Vector2);
  113089. /**
  113090. * Clones the PositionNormalTextureVertex
  113091. * @returns the cloned PositionNormalTextureVertex
  113092. */
  113093. clone(): PositionNormalTextureVertex;
  113094. }
  113095. }
  113096. declare module BABYLON {
  113097. /** @hidden */
  113098. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113099. private _genericAttributeLocation;
  113100. private _varyingLocationCount;
  113101. private _varyingLocationMap;
  113102. private _replacements;
  113103. private _textureCount;
  113104. private _uniforms;
  113105. lineProcessor(line: string): string;
  113106. attributeProcessor(attribute: string): string;
  113107. varyingProcessor(varying: string, isFragment: boolean): string;
  113108. uniformProcessor(uniform: string): string;
  113109. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113110. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113111. }
  113112. }
  113113. declare module BABYLON {
  113114. /**
  113115. * Container for accessors for natively-stored mesh data buffers.
  113116. */
  113117. class NativeDataBuffer extends DataBuffer {
  113118. /**
  113119. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113120. */
  113121. nativeIndexBuffer?: any;
  113122. /**
  113123. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113124. */
  113125. nativeVertexBuffer?: any;
  113126. }
  113127. /** @hidden */
  113128. class NativeTexture extends InternalTexture {
  113129. getInternalTexture(): InternalTexture;
  113130. getViewCount(): number;
  113131. }
  113132. /** @hidden */
  113133. export class NativeEngine extends Engine {
  113134. private readonly _native;
  113135. getHardwareScalingLevel(): number;
  113136. constructor();
  113137. /**
  113138. * Can be used to override the current requestAnimationFrame requester.
  113139. * @hidden
  113140. */
  113141. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113142. /**
  113143. * Override default engine behavior.
  113144. * @param color
  113145. * @param backBuffer
  113146. * @param depth
  113147. * @param stencil
  113148. */
  113149. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113150. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113151. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113152. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113153. recordVertexArrayObject(vertexBuffers: {
  113154. [key: string]: VertexBuffer;
  113155. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113156. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113157. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113158. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113159. /**
  113160. * Draw a list of indexed primitives
  113161. * @param fillMode defines the primitive to use
  113162. * @param indexStart defines the starting index
  113163. * @param indexCount defines the number of index to draw
  113164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113165. */
  113166. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113167. /**
  113168. * Draw a list of unindexed primitives
  113169. * @param fillMode defines the primitive to use
  113170. * @param verticesStart defines the index of first vertex to draw
  113171. * @param verticesCount defines the count of vertices to draw
  113172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113173. */
  113174. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113175. createPipelineContext(): IPipelineContext;
  113176. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113177. /** @hidden */
  113178. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113179. /** @hidden */
  113180. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113181. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113182. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113183. protected _setProgram(program: WebGLProgram): void;
  113184. _releaseEffect(effect: Effect): void;
  113185. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113186. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113187. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113188. bindSamplers(effect: Effect): void;
  113189. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113190. getRenderWidth(useScreen?: boolean): number;
  113191. getRenderHeight(useScreen?: boolean): number;
  113192. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113193. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113194. /**
  113195. * Set the z offset to apply to current rendering
  113196. * @param value defines the offset to apply
  113197. */
  113198. setZOffset(value: number): void;
  113199. /**
  113200. * Gets the current value of the zOffset
  113201. * @returns the current zOffset state
  113202. */
  113203. getZOffset(): number;
  113204. /**
  113205. * Enable or disable depth buffering
  113206. * @param enable defines the state to set
  113207. */
  113208. setDepthBuffer(enable: boolean): void;
  113209. /**
  113210. * Gets a boolean indicating if depth writing is enabled
  113211. * @returns the current depth writing state
  113212. */
  113213. getDepthWrite(): boolean;
  113214. /**
  113215. * Enable or disable depth writing
  113216. * @param enable defines the state to set
  113217. */
  113218. setDepthWrite(enable: boolean): void;
  113219. /**
  113220. * Enable or disable color writing
  113221. * @param enable defines the state to set
  113222. */
  113223. setColorWrite(enable: boolean): void;
  113224. /**
  113225. * Gets a boolean indicating if color writing is enabled
  113226. * @returns the current color writing state
  113227. */
  113228. getColorWrite(): boolean;
  113229. /**
  113230. * Sets alpha constants used by some alpha blending modes
  113231. * @param r defines the red component
  113232. * @param g defines the green component
  113233. * @param b defines the blue component
  113234. * @param a defines the alpha component
  113235. */
  113236. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113237. /**
  113238. * Sets the current alpha mode
  113239. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113240. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113241. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113242. */
  113243. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113244. /**
  113245. * Gets the current alpha mode
  113246. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113247. * @returns the current alpha mode
  113248. */
  113249. getAlphaMode(): number;
  113250. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113251. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113252. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113253. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113254. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113255. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113256. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113257. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113258. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113259. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113260. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113261. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113262. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113263. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113264. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113265. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113266. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113267. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113268. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113269. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113270. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113271. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113272. wipeCaches(bruteForce?: boolean): void;
  113273. _createTexture(): WebGLTexture;
  113274. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113275. /**
  113276. * Usually called from BABYLON.Texture.ts.
  113277. * Passed information to create a WebGLTexture
  113278. * @param urlArg defines a value which contains one of the following:
  113279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113283. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113284. * @param scene needed for loading to the correct scene
  113285. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113286. * @param onLoad optional callback to be called upon successful completion
  113287. * @param onError optional callback to be called upon failure
  113288. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113291. * @param forcedExtension defines the extension to use to pick the right loader
  113292. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113293. */
  113294. 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;
  113295. /**
  113296. * Creates a cube texture
  113297. * @param rootUrl defines the url where the files to load is located
  113298. * @param scene defines the current scene
  113299. * @param files defines the list of files to load (1 per face)
  113300. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113301. * @param onLoad defines an optional callback raised when the texture is loaded
  113302. * @param onError defines an optional callback raised if there is an issue to load the texture
  113303. * @param format defines the format of the data
  113304. * @param forcedExtension defines the extension to use to pick the right loader
  113305. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113306. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113307. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113308. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113309. * @returns the cube texture as an InternalTexture
  113310. */
  113311. 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;
  113312. private _getSamplingFilter;
  113313. private static _GetNativeTextureFormat;
  113314. createRenderTargetTexture(size: number | {
  113315. width: number;
  113316. height: number;
  113317. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113318. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113319. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113321. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113322. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113323. /**
  113324. * Updates a dynamic vertex buffer.
  113325. * @param vertexBuffer the vertex buffer to update
  113326. * @param data the data used to update the vertex buffer
  113327. * @param byteOffset the byte offset of the data (optional)
  113328. * @param byteLength the byte length of the data (optional)
  113329. */
  113330. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113331. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113332. private _updateAnisotropicLevel;
  113333. private _getAddressMode;
  113334. /** @hidden */
  113335. _bindTexture(channel: number, texture: InternalTexture): void;
  113336. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113337. releaseEffects(): void;
  113338. /** @hidden */
  113339. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113340. /** @hidden */
  113341. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113342. /** @hidden */
  113343. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113344. /** @hidden */
  113345. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113346. }
  113347. }
  113348. declare module BABYLON {
  113349. /**
  113350. * Gather the list of clipboard event types as constants.
  113351. */
  113352. export class ClipboardEventTypes {
  113353. /**
  113354. * The clipboard event is fired when a copy command is active (pressed).
  113355. */
  113356. static readonly COPY: number;
  113357. /**
  113358. * The clipboard event is fired when a cut command is active (pressed).
  113359. */
  113360. static readonly CUT: number;
  113361. /**
  113362. * The clipboard event is fired when a paste command is active (pressed).
  113363. */
  113364. static readonly PASTE: number;
  113365. }
  113366. /**
  113367. * This class is used to store clipboard related info for the onClipboardObservable event.
  113368. */
  113369. export class ClipboardInfo {
  113370. /**
  113371. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113372. */
  113373. type: number;
  113374. /**
  113375. * Defines the related dom event
  113376. */
  113377. event: ClipboardEvent;
  113378. /**
  113379. *Creates an instance of ClipboardInfo.
  113380. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113381. * @param event Defines the related dom event
  113382. */
  113383. constructor(
  113384. /**
  113385. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113386. */
  113387. type: number,
  113388. /**
  113389. * Defines the related dom event
  113390. */
  113391. event: ClipboardEvent);
  113392. /**
  113393. * Get the clipboard event's type from the keycode.
  113394. * @param keyCode Defines the keyCode for the current keyboard event.
  113395. * @return {number}
  113396. */
  113397. static GetTypeFromCharacter(keyCode: number): number;
  113398. }
  113399. }
  113400. declare module BABYLON {
  113401. /**
  113402. * Google Daydream controller
  113403. */
  113404. export class DaydreamController extends WebVRController {
  113405. /**
  113406. * Base Url for the controller model.
  113407. */
  113408. static MODEL_BASE_URL: string;
  113409. /**
  113410. * File name for the controller model.
  113411. */
  113412. static MODEL_FILENAME: string;
  113413. /**
  113414. * Gamepad Id prefix used to identify Daydream Controller.
  113415. */
  113416. static readonly GAMEPAD_ID_PREFIX: string;
  113417. /**
  113418. * Creates a new DaydreamController from a gamepad
  113419. * @param vrGamepad the gamepad that the controller should be created from
  113420. */
  113421. constructor(vrGamepad: any);
  113422. /**
  113423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113424. * @param scene scene in which to add meshes
  113425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113426. */
  113427. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113428. /**
  113429. * Called once for each button that changed state since the last frame
  113430. * @param buttonIdx Which button index changed
  113431. * @param state New state of the button
  113432. * @param changes Which properties on the state changed since last frame
  113433. */
  113434. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113435. }
  113436. }
  113437. declare module BABYLON {
  113438. /**
  113439. * Gear VR Controller
  113440. */
  113441. export class GearVRController extends WebVRController {
  113442. /**
  113443. * Base Url for the controller model.
  113444. */
  113445. static MODEL_BASE_URL: string;
  113446. /**
  113447. * File name for the controller model.
  113448. */
  113449. static MODEL_FILENAME: string;
  113450. /**
  113451. * Gamepad Id prefix used to identify this controller.
  113452. */
  113453. static readonly GAMEPAD_ID_PREFIX: string;
  113454. private readonly _buttonIndexToObservableNameMap;
  113455. /**
  113456. * Creates a new GearVRController from a gamepad
  113457. * @param vrGamepad the gamepad that the controller should be created from
  113458. */
  113459. constructor(vrGamepad: any);
  113460. /**
  113461. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113462. * @param scene scene in which to add meshes
  113463. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113464. */
  113465. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113466. /**
  113467. * Called once for each button that changed state since the last frame
  113468. * @param buttonIdx Which button index changed
  113469. * @param state New state of the button
  113470. * @param changes Which properties on the state changed since last frame
  113471. */
  113472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113473. }
  113474. }
  113475. declare module BABYLON {
  113476. /**
  113477. * Class containing static functions to help procedurally build meshes
  113478. */
  113479. export class PolyhedronBuilder {
  113480. /**
  113481. * Creates a polyhedron mesh
  113482. * * 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
  113483. * * The parameter `size` (positive float, default 1) sets the polygon size
  113484. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113485. * * 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`
  113486. * * 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
  113487. * * 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)`)
  113488. * * 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
  113489. * * 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
  113490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113493. * @param name defines the name of the mesh
  113494. * @param options defines the options used to create the mesh
  113495. * @param scene defines the hosting scene
  113496. * @returns the polyhedron mesh
  113497. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113498. */
  113499. static CreatePolyhedron(name: string, options: {
  113500. type?: number;
  113501. size?: number;
  113502. sizeX?: number;
  113503. sizeY?: number;
  113504. sizeZ?: number;
  113505. custom?: any;
  113506. faceUV?: Vector4[];
  113507. faceColors?: Color4[];
  113508. flat?: boolean;
  113509. updatable?: boolean;
  113510. sideOrientation?: number;
  113511. frontUVs?: Vector4;
  113512. backUVs?: Vector4;
  113513. }, scene?: Nullable<Scene>): Mesh;
  113514. }
  113515. }
  113516. declare module BABYLON {
  113517. /**
  113518. * Gizmo that enables scaling a mesh along 3 axis
  113519. */
  113520. export class ScaleGizmo extends Gizmo {
  113521. /**
  113522. * Internal gizmo used for interactions on the x axis
  113523. */
  113524. xGizmo: AxisScaleGizmo;
  113525. /**
  113526. * Internal gizmo used for interactions on the y axis
  113527. */
  113528. yGizmo: AxisScaleGizmo;
  113529. /**
  113530. * Internal gizmo used for interactions on the z axis
  113531. */
  113532. zGizmo: AxisScaleGizmo;
  113533. /**
  113534. * Internal gizmo used to scale all axis equally
  113535. */
  113536. uniformScaleGizmo: AxisScaleGizmo;
  113537. private _meshAttached;
  113538. private _updateGizmoRotationToMatchAttachedMesh;
  113539. private _snapDistance;
  113540. private _scaleRatio;
  113541. private _uniformScalingMesh;
  113542. private _octahedron;
  113543. /** Fires an event when any of it's sub gizmos are dragged */
  113544. onDragStartObservable: Observable<unknown>;
  113545. /** Fires an event when any of it's sub gizmos are released from dragging */
  113546. onDragEndObservable: Observable<unknown>;
  113547. attachedMesh: Nullable<AbstractMesh>;
  113548. /**
  113549. * Creates a ScaleGizmo
  113550. * @param gizmoLayer The utility layer the gizmo will be added to
  113551. */
  113552. constructor(gizmoLayer?: UtilityLayerRenderer);
  113553. updateGizmoRotationToMatchAttachedMesh: boolean;
  113554. /**
  113555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113556. */
  113557. snapDistance: number;
  113558. /**
  113559. * Ratio for the scale of the gizmo (Default: 1)
  113560. */
  113561. scaleRatio: number;
  113562. /**
  113563. * Disposes of the gizmo
  113564. */
  113565. dispose(): void;
  113566. }
  113567. }
  113568. declare module BABYLON {
  113569. /**
  113570. * Single axis scale gizmo
  113571. */
  113572. export class AxisScaleGizmo extends Gizmo {
  113573. /**
  113574. * Drag behavior responsible for the gizmos dragging interactions
  113575. */
  113576. dragBehavior: PointerDragBehavior;
  113577. private _pointerObserver;
  113578. /**
  113579. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113580. */
  113581. snapDistance: number;
  113582. /**
  113583. * Event that fires each time the gizmo snaps to a new location.
  113584. * * snapDistance is the the change in distance
  113585. */
  113586. onSnapObservable: Observable<{
  113587. snapDistance: number;
  113588. }>;
  113589. /**
  113590. * If the scaling operation should be done on all axis (default: false)
  113591. */
  113592. uniformScaling: boolean;
  113593. private _isEnabled;
  113594. private _parent;
  113595. private _arrow;
  113596. private _coloredMaterial;
  113597. private _hoverMaterial;
  113598. /**
  113599. * Creates an AxisScaleGizmo
  113600. * @param gizmoLayer The utility layer the gizmo will be added to
  113601. * @param dragAxis The axis which the gizmo will be able to scale on
  113602. * @param color The color of the gizmo
  113603. */
  113604. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113606. /**
  113607. * If the gizmo is enabled
  113608. */
  113609. isEnabled: boolean;
  113610. /**
  113611. * Disposes of the gizmo
  113612. */
  113613. dispose(): void;
  113614. /**
  113615. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113616. * @param mesh The mesh to replace the default mesh of the gizmo
  113617. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113618. */
  113619. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113620. }
  113621. }
  113622. declare module BABYLON {
  113623. /**
  113624. * Bounding box gizmo
  113625. */
  113626. export class BoundingBoxGizmo extends Gizmo {
  113627. private _lineBoundingBox;
  113628. private _rotateSpheresParent;
  113629. private _scaleBoxesParent;
  113630. private _boundingDimensions;
  113631. private _renderObserver;
  113632. private _pointerObserver;
  113633. private _scaleDragSpeed;
  113634. private _tmpQuaternion;
  113635. private _tmpVector;
  113636. private _tmpRotationMatrix;
  113637. /**
  113638. * 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)
  113639. */
  113640. ignoreChildren: boolean;
  113641. /**
  113642. * 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)
  113643. */
  113644. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113645. /**
  113646. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113647. */
  113648. rotationSphereSize: number;
  113649. /**
  113650. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113651. */
  113652. scaleBoxSize: number;
  113653. /**
  113654. * 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)
  113655. */
  113656. fixedDragMeshScreenSize: boolean;
  113657. /**
  113658. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113659. */
  113660. fixedDragMeshScreenSizeDistanceFactor: number;
  113661. /**
  113662. * Fired when a rotation sphere or scale box is dragged
  113663. */
  113664. onDragStartObservable: Observable<{}>;
  113665. /**
  113666. * Fired when a scale box is dragged
  113667. */
  113668. onScaleBoxDragObservable: Observable<{}>;
  113669. /**
  113670. * Fired when a scale box drag is ended
  113671. */
  113672. onScaleBoxDragEndObservable: Observable<{}>;
  113673. /**
  113674. * Fired when a rotation sphere is dragged
  113675. */
  113676. onRotationSphereDragObservable: Observable<{}>;
  113677. /**
  113678. * Fired when a rotation sphere drag is ended
  113679. */
  113680. onRotationSphereDragEndObservable: Observable<{}>;
  113681. /**
  113682. * 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)
  113683. */
  113684. scalePivot: Nullable<Vector3>;
  113685. /**
  113686. * Mesh used as a pivot to rotate the attached mesh
  113687. */
  113688. private _anchorMesh;
  113689. private _existingMeshScale;
  113690. private _dragMesh;
  113691. private pointerDragBehavior;
  113692. private coloredMaterial;
  113693. private hoverColoredMaterial;
  113694. /**
  113695. * Sets the color of the bounding box gizmo
  113696. * @param color the color to set
  113697. */
  113698. setColor(color: Color3): void;
  113699. /**
  113700. * Creates an BoundingBoxGizmo
  113701. * @param gizmoLayer The utility layer the gizmo will be added to
  113702. * @param color The color of the gizmo
  113703. */
  113704. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113706. private _selectNode;
  113707. /**
  113708. * Updates the bounding box information for the Gizmo
  113709. */
  113710. updateBoundingBox(): void;
  113711. private _updateRotationSpheres;
  113712. private _updateScaleBoxes;
  113713. /**
  113714. * Enables rotation on the specified axis and disables rotation on the others
  113715. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113716. */
  113717. setEnabledRotationAxis(axis: string): void;
  113718. /**
  113719. * Enables/disables scaling
  113720. * @param enable if scaling should be enabled
  113721. */
  113722. setEnabledScaling(enable: boolean): void;
  113723. private _updateDummy;
  113724. /**
  113725. * Enables a pointer drag behavior on the bounding box of the gizmo
  113726. */
  113727. enableDragBehavior(): void;
  113728. /**
  113729. * Disposes of the gizmo
  113730. */
  113731. dispose(): void;
  113732. /**
  113733. * 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)
  113734. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113735. * @returns the bounding box mesh with the passed in mesh as a child
  113736. */
  113737. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113738. /**
  113739. * CustomMeshes are not supported by this gizmo
  113740. * @param mesh The mesh to replace the default mesh of the gizmo
  113741. */
  113742. setCustomMesh(mesh: Mesh): void;
  113743. }
  113744. }
  113745. declare module BABYLON {
  113746. /**
  113747. * Single plane rotation gizmo
  113748. */
  113749. export class PlaneRotationGizmo extends Gizmo {
  113750. /**
  113751. * Drag behavior responsible for the gizmos dragging interactions
  113752. */
  113753. dragBehavior: PointerDragBehavior;
  113754. private _pointerObserver;
  113755. /**
  113756. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113757. */
  113758. snapDistance: number;
  113759. /**
  113760. * Event that fires each time the gizmo snaps to a new location.
  113761. * * snapDistance is the the change in distance
  113762. */
  113763. onSnapObservable: Observable<{
  113764. snapDistance: number;
  113765. }>;
  113766. private _isEnabled;
  113767. private _parent;
  113768. /**
  113769. * Creates a PlaneRotationGizmo
  113770. * @param gizmoLayer The utility layer the gizmo will be added to
  113771. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113772. * @param color The color of the gizmo
  113773. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113774. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113775. */
  113776. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113777. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113778. /**
  113779. * If the gizmo is enabled
  113780. */
  113781. isEnabled: boolean;
  113782. /**
  113783. * Disposes of the gizmo
  113784. */
  113785. dispose(): void;
  113786. }
  113787. }
  113788. declare module BABYLON {
  113789. /**
  113790. * Gizmo that enables rotating a mesh along 3 axis
  113791. */
  113792. export class RotationGizmo extends Gizmo {
  113793. /**
  113794. * Internal gizmo used for interactions on the x axis
  113795. */
  113796. xGizmo: PlaneRotationGizmo;
  113797. /**
  113798. * Internal gizmo used for interactions on the y axis
  113799. */
  113800. yGizmo: PlaneRotationGizmo;
  113801. /**
  113802. * Internal gizmo used for interactions on the z axis
  113803. */
  113804. zGizmo: PlaneRotationGizmo;
  113805. /** Fires an event when any of it's sub gizmos are dragged */
  113806. onDragStartObservable: Observable<unknown>;
  113807. /** Fires an event when any of it's sub gizmos are released from dragging */
  113808. onDragEndObservable: Observable<unknown>;
  113809. private _meshAttached;
  113810. attachedMesh: Nullable<AbstractMesh>;
  113811. /**
  113812. * Creates a RotationGizmo
  113813. * @param gizmoLayer The utility layer the gizmo will be added to
  113814. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113815. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113816. */
  113817. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113818. updateGizmoRotationToMatchAttachedMesh: boolean;
  113819. /**
  113820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113821. */
  113822. snapDistance: number;
  113823. /**
  113824. * Ratio for the scale of the gizmo (Default: 1)
  113825. */
  113826. scaleRatio: number;
  113827. /**
  113828. * Disposes of the gizmo
  113829. */
  113830. dispose(): void;
  113831. /**
  113832. * CustomMeshes are not supported by this gizmo
  113833. * @param mesh The mesh to replace the default mesh of the gizmo
  113834. */
  113835. setCustomMesh(mesh: Mesh): void;
  113836. }
  113837. }
  113838. declare module BABYLON {
  113839. /**
  113840. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113841. */
  113842. export class GizmoManager implements IDisposable {
  113843. private scene;
  113844. /**
  113845. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113846. */
  113847. gizmos: {
  113848. positionGizmo: Nullable<PositionGizmo>;
  113849. rotationGizmo: Nullable<RotationGizmo>;
  113850. scaleGizmo: Nullable<ScaleGizmo>;
  113851. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113852. };
  113853. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113854. clearGizmoOnEmptyPointerEvent: boolean;
  113855. /** Fires an event when the manager is attached to a mesh */
  113856. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113857. private _gizmosEnabled;
  113858. private _pointerObserver;
  113859. private _attachedMesh;
  113860. private _boundingBoxColor;
  113861. private _defaultUtilityLayer;
  113862. private _defaultKeepDepthUtilityLayer;
  113863. /**
  113864. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113865. */
  113866. boundingBoxDragBehavior: SixDofDragBehavior;
  113867. /**
  113868. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113869. */
  113870. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113871. /**
  113872. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113873. */
  113874. usePointerToAttachGizmos: boolean;
  113875. /**
  113876. * Utility layer that the bounding box gizmo belongs to
  113877. */
  113878. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113879. /**
  113880. * Utility layer that all gizmos besides bounding box belong to
  113881. */
  113882. readonly utilityLayer: UtilityLayerRenderer;
  113883. /**
  113884. * Instatiates a gizmo manager
  113885. * @param scene the scene to overlay the gizmos on top of
  113886. */
  113887. constructor(scene: Scene);
  113888. /**
  113889. * Attaches a set of gizmos to the specified mesh
  113890. * @param mesh The mesh the gizmo's should be attached to
  113891. */
  113892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113893. /**
  113894. * If the position gizmo is enabled
  113895. */
  113896. positionGizmoEnabled: boolean;
  113897. /**
  113898. * If the rotation gizmo is enabled
  113899. */
  113900. rotationGizmoEnabled: boolean;
  113901. /**
  113902. * If the scale gizmo is enabled
  113903. */
  113904. scaleGizmoEnabled: boolean;
  113905. /**
  113906. * If the boundingBox gizmo is enabled
  113907. */
  113908. boundingBoxGizmoEnabled: boolean;
  113909. /**
  113910. * Disposes of the gizmo manager
  113911. */
  113912. dispose(): void;
  113913. }
  113914. }
  113915. declare module BABYLON {
  113916. /**
  113917. * A directional light is defined by a direction (what a surprise!).
  113918. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113919. * 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.
  113920. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113921. */
  113922. export class DirectionalLight extends ShadowLight {
  113923. private _shadowFrustumSize;
  113924. /**
  113925. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113926. */
  113927. /**
  113928. * Specifies a fix frustum size for the shadow generation.
  113929. */
  113930. shadowFrustumSize: number;
  113931. private _shadowOrthoScale;
  113932. /**
  113933. * Gets the shadow projection scale against the optimal computed one.
  113934. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113935. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113936. */
  113937. /**
  113938. * Sets the shadow projection scale against the optimal computed one.
  113939. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113940. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113941. */
  113942. shadowOrthoScale: number;
  113943. /**
  113944. * Automatically compute the projection matrix to best fit (including all the casters)
  113945. * on each frame.
  113946. */
  113947. autoUpdateExtends: boolean;
  113948. private _orthoLeft;
  113949. private _orthoRight;
  113950. private _orthoTop;
  113951. private _orthoBottom;
  113952. /**
  113953. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113954. * The directional light is emitted from everywhere in the given direction.
  113955. * It can cast shadows.
  113956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113957. * @param name The friendly name of the light
  113958. * @param direction The direction of the light
  113959. * @param scene The scene the light belongs to
  113960. */
  113961. constructor(name: string, direction: Vector3, scene: Scene);
  113962. /**
  113963. * Returns the string "DirectionalLight".
  113964. * @return The class name
  113965. */
  113966. getClassName(): string;
  113967. /**
  113968. * Returns the integer 1.
  113969. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113970. */
  113971. getTypeID(): number;
  113972. /**
  113973. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113974. * Returns the DirectionalLight Shadow projection matrix.
  113975. */
  113976. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113977. /**
  113978. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113979. * Returns the DirectionalLight Shadow projection matrix.
  113980. */
  113981. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113982. /**
  113983. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113984. * Returns the DirectionalLight Shadow projection matrix.
  113985. */
  113986. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113987. protected _buildUniformLayout(): void;
  113988. /**
  113989. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113990. * @param effect The effect to update
  113991. * @param lightIndex The index of the light in the effect to update
  113992. * @returns The directional light
  113993. */
  113994. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113995. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113996. /**
  113997. * Gets the minZ used for shadow according to both the scene and the light.
  113998. *
  113999. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114000. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114001. * @param activeCamera The camera we are returning the min for
  114002. * @returns the depth min z
  114003. */
  114004. getDepthMinZ(activeCamera: Camera): number;
  114005. /**
  114006. * Gets the maxZ used for shadow according to both the scene and the light.
  114007. *
  114008. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114009. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114010. * @param activeCamera The camera we are returning the max for
  114011. * @returns the depth max z
  114012. */
  114013. getDepthMaxZ(activeCamera: Camera): number;
  114014. /**
  114015. * Prepares the list of defines specific to the light type.
  114016. * @param defines the list of defines
  114017. * @param lightIndex defines the index of the light for the effect
  114018. */
  114019. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114020. }
  114021. }
  114022. declare module BABYLON {
  114023. /**
  114024. * Class containing static functions to help procedurally build meshes
  114025. */
  114026. export class HemisphereBuilder {
  114027. /**
  114028. * Creates a hemisphere mesh
  114029. * @param name defines the name of the mesh
  114030. * @param options defines the options used to create the mesh
  114031. * @param scene defines the hosting scene
  114032. * @returns the hemisphere mesh
  114033. */
  114034. static CreateHemisphere(name: string, options: {
  114035. segments?: number;
  114036. diameter?: number;
  114037. sideOrientation?: number;
  114038. }, scene: any): Mesh;
  114039. }
  114040. }
  114041. declare module BABYLON {
  114042. /**
  114043. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114044. * These values define a cone of light starting from the position, emitting toward the direction.
  114045. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114046. * and the exponent defines the speed of the decay of the light with distance (reach).
  114047. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114048. */
  114049. export class SpotLight extends ShadowLight {
  114050. private _angle;
  114051. private _innerAngle;
  114052. private _cosHalfAngle;
  114053. private _lightAngleScale;
  114054. private _lightAngleOffset;
  114055. /**
  114056. * Gets the cone angle of the spot light in Radians.
  114057. */
  114058. /**
  114059. * Sets the cone angle of the spot light in Radians.
  114060. */
  114061. angle: number;
  114062. /**
  114063. * Only used in gltf falloff mode, this defines the angle where
  114064. * the directional falloff will start before cutting at angle which could be seen
  114065. * as outer angle.
  114066. */
  114067. /**
  114068. * Only used in gltf falloff mode, this defines the angle where
  114069. * the directional falloff will start before cutting at angle which could be seen
  114070. * as outer angle.
  114071. */
  114072. innerAngle: number;
  114073. private _shadowAngleScale;
  114074. /**
  114075. * Allows scaling the angle of the light for shadow generation only.
  114076. */
  114077. /**
  114078. * Allows scaling the angle of the light for shadow generation only.
  114079. */
  114080. shadowAngleScale: number;
  114081. /**
  114082. * The light decay speed with the distance from the emission spot.
  114083. */
  114084. exponent: number;
  114085. private _projectionTextureMatrix;
  114086. /**
  114087. * Allows reading the projecton texture
  114088. */
  114089. readonly projectionTextureMatrix: Matrix;
  114090. protected _projectionTextureLightNear: number;
  114091. /**
  114092. * Gets the near clip of the Spotlight for texture projection.
  114093. */
  114094. /**
  114095. * Sets the near clip of the Spotlight for texture projection.
  114096. */
  114097. projectionTextureLightNear: number;
  114098. protected _projectionTextureLightFar: number;
  114099. /**
  114100. * Gets the far clip of the Spotlight for texture projection.
  114101. */
  114102. /**
  114103. * Sets the far clip of the Spotlight for texture projection.
  114104. */
  114105. projectionTextureLightFar: number;
  114106. protected _projectionTextureUpDirection: Vector3;
  114107. /**
  114108. * Gets the Up vector of the Spotlight for texture projection.
  114109. */
  114110. /**
  114111. * Sets the Up vector of the Spotlight for texture projection.
  114112. */
  114113. projectionTextureUpDirection: Vector3;
  114114. private _projectionTexture;
  114115. /**
  114116. * Gets the projection texture of the light.
  114117. */
  114118. /**
  114119. * Sets the projection texture of the light.
  114120. */
  114121. projectionTexture: Nullable<BaseTexture>;
  114122. private _projectionTextureViewLightDirty;
  114123. private _projectionTextureProjectionLightDirty;
  114124. private _projectionTextureDirty;
  114125. private _projectionTextureViewTargetVector;
  114126. private _projectionTextureViewLightMatrix;
  114127. private _projectionTextureProjectionLightMatrix;
  114128. private _projectionTextureScalingMatrix;
  114129. /**
  114130. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114131. * It can cast shadows.
  114132. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114133. * @param name The light friendly name
  114134. * @param position The position of the spot light in the scene
  114135. * @param direction The direction of the light in the scene
  114136. * @param angle The cone angle of the light in Radians
  114137. * @param exponent The light decay speed with the distance from the emission spot
  114138. * @param scene The scene the lights belongs to
  114139. */
  114140. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114141. /**
  114142. * Returns the string "SpotLight".
  114143. * @returns the class name
  114144. */
  114145. getClassName(): string;
  114146. /**
  114147. * Returns the integer 2.
  114148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114149. */
  114150. getTypeID(): number;
  114151. /**
  114152. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114153. */
  114154. protected _setDirection(value: Vector3): void;
  114155. /**
  114156. * Overrides the position setter to recompute the projection texture view light Matrix.
  114157. */
  114158. protected _setPosition(value: Vector3): void;
  114159. /**
  114160. * 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.
  114161. * Returns the SpotLight.
  114162. */
  114163. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114164. protected _computeProjectionTextureViewLightMatrix(): void;
  114165. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114166. /**
  114167. * Main function for light texture projection matrix computing.
  114168. */
  114169. protected _computeProjectionTextureMatrix(): void;
  114170. protected _buildUniformLayout(): void;
  114171. private _computeAngleValues;
  114172. /**
  114173. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114174. * @param effect The effect to update
  114175. * @param lightIndex The index of the light in the effect to update
  114176. * @returns The spot light
  114177. */
  114178. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114179. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114180. /**
  114181. * Disposes the light and the associated resources.
  114182. */
  114183. dispose(): void;
  114184. /**
  114185. * Prepares the list of defines specific to the light type.
  114186. * @param defines the list of defines
  114187. * @param lightIndex defines the index of the light for the effect
  114188. */
  114189. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114190. }
  114191. }
  114192. declare module BABYLON {
  114193. /**
  114194. * Gizmo that enables viewing a light
  114195. */
  114196. export class LightGizmo extends Gizmo {
  114197. private _lightMesh;
  114198. private _material;
  114199. private cachedPosition;
  114200. private cachedForward;
  114201. /**
  114202. * Creates a LightGizmo
  114203. * @param gizmoLayer The utility layer the gizmo will be added to
  114204. */
  114205. constructor(gizmoLayer?: UtilityLayerRenderer);
  114206. private _light;
  114207. /**
  114208. * The light that the gizmo is attached to
  114209. */
  114210. light: Nullable<Light>;
  114211. /**
  114212. * Gets the material used to render the light gizmo
  114213. */
  114214. readonly material: StandardMaterial;
  114215. /**
  114216. * @hidden
  114217. * Updates the gizmo to match the attached mesh's position/rotation
  114218. */
  114219. protected _update(): void;
  114220. private static _Scale;
  114221. /**
  114222. * Creates the lines for a light mesh
  114223. */
  114224. private static _createLightLines;
  114225. /**
  114226. * Disposes of the light gizmo
  114227. */
  114228. dispose(): void;
  114229. private static _CreateHemisphericLightMesh;
  114230. private static _CreatePointLightMesh;
  114231. private static _CreateSpotLightMesh;
  114232. private static _CreateDirectionalLightMesh;
  114233. }
  114234. }
  114235. declare module BABYLON {
  114236. /** @hidden */
  114237. export var backgroundFragmentDeclaration: {
  114238. name: string;
  114239. shader: string;
  114240. };
  114241. }
  114242. declare module BABYLON {
  114243. /** @hidden */
  114244. export var backgroundUboDeclaration: {
  114245. name: string;
  114246. shader: string;
  114247. };
  114248. }
  114249. declare module BABYLON {
  114250. /** @hidden */
  114251. export var backgroundPixelShader: {
  114252. name: string;
  114253. shader: string;
  114254. };
  114255. }
  114256. declare module BABYLON {
  114257. /** @hidden */
  114258. export var backgroundVertexDeclaration: {
  114259. name: string;
  114260. shader: string;
  114261. };
  114262. }
  114263. declare module BABYLON {
  114264. /** @hidden */
  114265. export var backgroundVertexShader: {
  114266. name: string;
  114267. shader: string;
  114268. };
  114269. }
  114270. declare module BABYLON {
  114271. /**
  114272. * Background material used to create an efficient environement around your scene.
  114273. */
  114274. export class BackgroundMaterial extends PushMaterial {
  114275. /**
  114276. * Standard reflectance value at parallel view angle.
  114277. */
  114278. static StandardReflectance0: number;
  114279. /**
  114280. * Standard reflectance value at grazing angle.
  114281. */
  114282. static StandardReflectance90: number;
  114283. protected _primaryColor: Color3;
  114284. /**
  114285. * Key light Color (multiply against the environement texture)
  114286. */
  114287. primaryColor: Color3;
  114288. protected __perceptualColor: Nullable<Color3>;
  114289. /**
  114290. * Experimental Internal Use Only.
  114291. *
  114292. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114293. * This acts as a helper to set the primary color to a more "human friendly" value.
  114294. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114295. * output color as close as possible from the chosen value.
  114296. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114297. * part of lighting setup.)
  114298. */
  114299. _perceptualColor: Nullable<Color3>;
  114300. protected _primaryColorShadowLevel: float;
  114301. /**
  114302. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114303. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114304. */
  114305. primaryColorShadowLevel: float;
  114306. protected _primaryColorHighlightLevel: float;
  114307. /**
  114308. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114309. * The primary color is used at the level chosen to define what the white area would look.
  114310. */
  114311. primaryColorHighlightLevel: float;
  114312. protected _reflectionTexture: Nullable<BaseTexture>;
  114313. /**
  114314. * Reflection Texture used in the material.
  114315. * Should be author in a specific way for the best result (refer to the documentation).
  114316. */
  114317. reflectionTexture: Nullable<BaseTexture>;
  114318. protected _reflectionBlur: float;
  114319. /**
  114320. * Reflection Texture level of blur.
  114321. *
  114322. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114323. * texture twice.
  114324. */
  114325. reflectionBlur: float;
  114326. protected _diffuseTexture: Nullable<BaseTexture>;
  114327. /**
  114328. * Diffuse Texture used in the material.
  114329. * Should be author in a specific way for the best result (refer to the documentation).
  114330. */
  114331. diffuseTexture: Nullable<BaseTexture>;
  114332. protected _shadowLights: Nullable<IShadowLight[]>;
  114333. /**
  114334. * Specify the list of lights casting shadow on the material.
  114335. * All scene shadow lights will be included if null.
  114336. */
  114337. shadowLights: Nullable<IShadowLight[]>;
  114338. protected _shadowLevel: float;
  114339. /**
  114340. * Helps adjusting the shadow to a softer level if required.
  114341. * 0 means black shadows and 1 means no shadows.
  114342. */
  114343. shadowLevel: float;
  114344. protected _sceneCenter: Vector3;
  114345. /**
  114346. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114347. * It is usually zero but might be interesting to modify according to your setup.
  114348. */
  114349. sceneCenter: Vector3;
  114350. protected _opacityFresnel: boolean;
  114351. /**
  114352. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114353. * This helps ensuring a nice transition when the camera goes under the ground.
  114354. */
  114355. opacityFresnel: boolean;
  114356. protected _reflectionFresnel: boolean;
  114357. /**
  114358. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114359. * This helps adding a mirror texture on the ground.
  114360. */
  114361. reflectionFresnel: boolean;
  114362. protected _reflectionFalloffDistance: number;
  114363. /**
  114364. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114365. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114366. */
  114367. reflectionFalloffDistance: number;
  114368. protected _reflectionAmount: number;
  114369. /**
  114370. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114371. */
  114372. reflectionAmount: number;
  114373. protected _reflectionReflectance0: number;
  114374. /**
  114375. * This specifies the weight of the reflection at grazing angle.
  114376. */
  114377. reflectionReflectance0: number;
  114378. protected _reflectionReflectance90: number;
  114379. /**
  114380. * This specifies the weight of the reflection at a perpendicular point of view.
  114381. */
  114382. reflectionReflectance90: number;
  114383. /**
  114384. * Sets the reflection reflectance fresnel values according to the default standard
  114385. * empirically know to work well :-)
  114386. */
  114387. reflectionStandardFresnelWeight: number;
  114388. protected _useRGBColor: boolean;
  114389. /**
  114390. * Helps to directly use the maps channels instead of their level.
  114391. */
  114392. useRGBColor: boolean;
  114393. protected _enableNoise: boolean;
  114394. /**
  114395. * This helps reducing the banding effect that could occur on the background.
  114396. */
  114397. enableNoise: boolean;
  114398. /**
  114399. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114400. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114401. * Recommended to be keep at 1.0 except for special cases.
  114402. */
  114403. fovMultiplier: number;
  114404. private _fovMultiplier;
  114405. /**
  114406. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114407. */
  114408. useEquirectangularFOV: boolean;
  114409. private _maxSimultaneousLights;
  114410. /**
  114411. * Number of Simultaneous lights allowed on the material.
  114412. */
  114413. maxSimultaneousLights: int;
  114414. /**
  114415. * Default configuration related to image processing available in the Background Material.
  114416. */
  114417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114418. /**
  114419. * Keep track of the image processing observer to allow dispose and replace.
  114420. */
  114421. private _imageProcessingObserver;
  114422. /**
  114423. * Attaches a new image processing configuration to the PBR Material.
  114424. * @param configuration (if null the scene configuration will be use)
  114425. */
  114426. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114427. /**
  114428. * Gets the image processing configuration used either in this material.
  114429. */
  114430. /**
  114431. * Sets the Default image processing configuration used either in the this material.
  114432. *
  114433. * If sets to null, the scene one is in use.
  114434. */
  114435. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114436. /**
  114437. * Gets wether the color curves effect is enabled.
  114438. */
  114439. /**
  114440. * Sets wether the color curves effect is enabled.
  114441. */
  114442. cameraColorCurvesEnabled: boolean;
  114443. /**
  114444. * Gets wether the color grading effect is enabled.
  114445. */
  114446. /**
  114447. * Gets wether the color grading effect is enabled.
  114448. */
  114449. cameraColorGradingEnabled: boolean;
  114450. /**
  114451. * Gets wether tonemapping is enabled or not.
  114452. */
  114453. /**
  114454. * Sets wether tonemapping is enabled or not
  114455. */
  114456. cameraToneMappingEnabled: boolean;
  114457. /**
  114458. * The camera exposure used on this material.
  114459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114460. * This corresponds to a photographic exposure.
  114461. */
  114462. /**
  114463. * The camera exposure used on this material.
  114464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114465. * This corresponds to a photographic exposure.
  114466. */
  114467. cameraExposure: float;
  114468. /**
  114469. * Gets The camera contrast used on this material.
  114470. */
  114471. /**
  114472. * Sets The camera contrast used on this material.
  114473. */
  114474. cameraContrast: float;
  114475. /**
  114476. * Gets the Color Grading 2D Lookup Texture.
  114477. */
  114478. /**
  114479. * Sets the Color Grading 2D Lookup Texture.
  114480. */
  114481. cameraColorGradingTexture: Nullable<BaseTexture>;
  114482. /**
  114483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114485. * 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;
  114486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114487. */
  114488. /**
  114489. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114490. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114491. * 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;
  114492. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114493. */
  114494. cameraColorCurves: Nullable<ColorCurves>;
  114495. /**
  114496. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114497. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114498. */
  114499. switchToBGR: boolean;
  114500. private _renderTargets;
  114501. private _reflectionControls;
  114502. private _white;
  114503. private _primaryShadowColor;
  114504. private _primaryHighlightColor;
  114505. /**
  114506. * Instantiates a Background Material in the given scene
  114507. * @param name The friendly name of the material
  114508. * @param scene The scene to add the material to
  114509. */
  114510. constructor(name: string, scene: Scene);
  114511. /**
  114512. * Gets a boolean indicating that current material needs to register RTT
  114513. */
  114514. readonly hasRenderTargetTextures: boolean;
  114515. /**
  114516. * The entire material has been created in order to prevent overdraw.
  114517. * @returns false
  114518. */
  114519. needAlphaTesting(): boolean;
  114520. /**
  114521. * The entire material has been created in order to prevent overdraw.
  114522. * @returns true if blending is enable
  114523. */
  114524. needAlphaBlending(): boolean;
  114525. /**
  114526. * Checks wether the material is ready to be rendered for a given mesh.
  114527. * @param mesh The mesh to render
  114528. * @param subMesh The submesh to check against
  114529. * @param useInstances Specify wether or not the material is used with instances
  114530. * @returns true if all the dependencies are ready (Textures, Effects...)
  114531. */
  114532. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114533. /**
  114534. * Compute the primary color according to the chosen perceptual color.
  114535. */
  114536. private _computePrimaryColorFromPerceptualColor;
  114537. /**
  114538. * Compute the highlights and shadow colors according to their chosen levels.
  114539. */
  114540. private _computePrimaryColors;
  114541. /**
  114542. * Build the uniform buffer used in the material.
  114543. */
  114544. buildUniformLayout(): void;
  114545. /**
  114546. * Unbind the material.
  114547. */
  114548. unbind(): void;
  114549. /**
  114550. * Bind only the world matrix to the material.
  114551. * @param world The world matrix to bind.
  114552. */
  114553. bindOnlyWorldMatrix(world: Matrix): void;
  114554. /**
  114555. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114556. * @param world The world matrix to bind.
  114557. * @param subMesh The submesh to bind for.
  114558. */
  114559. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114560. /**
  114561. * Checks to see if a texture is used in the material.
  114562. * @param texture - Base texture to use.
  114563. * @returns - Boolean specifying if a texture is used in the material.
  114564. */
  114565. hasTexture(texture: BaseTexture): boolean;
  114566. /**
  114567. * Dispose the material.
  114568. * @param forceDisposeEffect Force disposal of the associated effect.
  114569. * @param forceDisposeTextures Force disposal of the associated textures.
  114570. */
  114571. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114572. /**
  114573. * Clones the material.
  114574. * @param name The cloned name.
  114575. * @returns The cloned material.
  114576. */
  114577. clone(name: string): BackgroundMaterial;
  114578. /**
  114579. * Serializes the current material to its JSON representation.
  114580. * @returns The JSON representation.
  114581. */
  114582. serialize(): any;
  114583. /**
  114584. * Gets the class name of the material
  114585. * @returns "BackgroundMaterial"
  114586. */
  114587. getClassName(): string;
  114588. /**
  114589. * Parse a JSON input to create back a background material.
  114590. * @param source The JSON data to parse
  114591. * @param scene The scene to create the parsed material in
  114592. * @param rootUrl The root url of the assets the material depends upon
  114593. * @returns the instantiated BackgroundMaterial.
  114594. */
  114595. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114596. }
  114597. }
  114598. declare module BABYLON {
  114599. /**
  114600. * Represents the different options available during the creation of
  114601. * a Environment helper.
  114602. *
  114603. * This can control the default ground, skybox and image processing setup of your scene.
  114604. */
  114605. export interface IEnvironmentHelperOptions {
  114606. /**
  114607. * Specifies wether or not to create a ground.
  114608. * True by default.
  114609. */
  114610. createGround: boolean;
  114611. /**
  114612. * Specifies the ground size.
  114613. * 15 by default.
  114614. */
  114615. groundSize: number;
  114616. /**
  114617. * The texture used on the ground for the main color.
  114618. * Comes from the BabylonJS CDN by default.
  114619. *
  114620. * Remarks: Can be either a texture or a url.
  114621. */
  114622. groundTexture: string | BaseTexture;
  114623. /**
  114624. * The color mixed in the ground texture by default.
  114625. * BabylonJS clearColor by default.
  114626. */
  114627. groundColor: Color3;
  114628. /**
  114629. * Specifies the ground opacity.
  114630. * 1 by default.
  114631. */
  114632. groundOpacity: number;
  114633. /**
  114634. * Enables the ground to receive shadows.
  114635. * True by default.
  114636. */
  114637. enableGroundShadow: boolean;
  114638. /**
  114639. * Helps preventing the shadow to be fully black on the ground.
  114640. * 0.5 by default.
  114641. */
  114642. groundShadowLevel: number;
  114643. /**
  114644. * Creates a mirror texture attach to the ground.
  114645. * false by default.
  114646. */
  114647. enableGroundMirror: boolean;
  114648. /**
  114649. * Specifies the ground mirror size ratio.
  114650. * 0.3 by default as the default kernel is 64.
  114651. */
  114652. groundMirrorSizeRatio: number;
  114653. /**
  114654. * Specifies the ground mirror blur kernel size.
  114655. * 64 by default.
  114656. */
  114657. groundMirrorBlurKernel: number;
  114658. /**
  114659. * Specifies the ground mirror visibility amount.
  114660. * 1 by default
  114661. */
  114662. groundMirrorAmount: number;
  114663. /**
  114664. * Specifies the ground mirror reflectance weight.
  114665. * This uses the standard weight of the background material to setup the fresnel effect
  114666. * of the mirror.
  114667. * 1 by default.
  114668. */
  114669. groundMirrorFresnelWeight: number;
  114670. /**
  114671. * Specifies the ground mirror Falloff distance.
  114672. * This can helps reducing the size of the reflection.
  114673. * 0 by Default.
  114674. */
  114675. groundMirrorFallOffDistance: number;
  114676. /**
  114677. * Specifies the ground mirror texture type.
  114678. * Unsigned Int by Default.
  114679. */
  114680. groundMirrorTextureType: number;
  114681. /**
  114682. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114683. * the shown objects.
  114684. */
  114685. groundYBias: number;
  114686. /**
  114687. * Specifies wether or not to create a skybox.
  114688. * True by default.
  114689. */
  114690. createSkybox: boolean;
  114691. /**
  114692. * Specifies the skybox size.
  114693. * 20 by default.
  114694. */
  114695. skyboxSize: number;
  114696. /**
  114697. * The texture used on the skybox for the main color.
  114698. * Comes from the BabylonJS CDN by default.
  114699. *
  114700. * Remarks: Can be either a texture or a url.
  114701. */
  114702. skyboxTexture: string | BaseTexture;
  114703. /**
  114704. * The color mixed in the skybox texture by default.
  114705. * BabylonJS clearColor by default.
  114706. */
  114707. skyboxColor: Color3;
  114708. /**
  114709. * The background rotation around the Y axis of the scene.
  114710. * This helps aligning the key lights of your scene with the background.
  114711. * 0 by default.
  114712. */
  114713. backgroundYRotation: number;
  114714. /**
  114715. * Compute automatically the size of the elements to best fit with the scene.
  114716. */
  114717. sizeAuto: boolean;
  114718. /**
  114719. * Default position of the rootMesh if autoSize is not true.
  114720. */
  114721. rootPosition: Vector3;
  114722. /**
  114723. * Sets up the image processing in the scene.
  114724. * true by default.
  114725. */
  114726. setupImageProcessing: boolean;
  114727. /**
  114728. * The texture used as your environment texture in the scene.
  114729. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114730. *
  114731. * Remarks: Can be either a texture or a url.
  114732. */
  114733. environmentTexture: string | BaseTexture;
  114734. /**
  114735. * The value of the exposure to apply to the scene.
  114736. * 0.6 by default if setupImageProcessing is true.
  114737. */
  114738. cameraExposure: number;
  114739. /**
  114740. * The value of the contrast to apply to the scene.
  114741. * 1.6 by default if setupImageProcessing is true.
  114742. */
  114743. cameraContrast: number;
  114744. /**
  114745. * Specifies wether or not tonemapping should be enabled in the scene.
  114746. * true by default if setupImageProcessing is true.
  114747. */
  114748. toneMappingEnabled: boolean;
  114749. }
  114750. /**
  114751. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114752. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114753. * It also helps with the default setup of your imageProcessing configuration.
  114754. */
  114755. export class EnvironmentHelper {
  114756. /**
  114757. * Default ground texture URL.
  114758. */
  114759. private static _groundTextureCDNUrl;
  114760. /**
  114761. * Default skybox texture URL.
  114762. */
  114763. private static _skyboxTextureCDNUrl;
  114764. /**
  114765. * Default environment texture URL.
  114766. */
  114767. private static _environmentTextureCDNUrl;
  114768. /**
  114769. * Creates the default options for the helper.
  114770. */
  114771. private static _getDefaultOptions;
  114772. private _rootMesh;
  114773. /**
  114774. * Gets the root mesh created by the helper.
  114775. */
  114776. readonly rootMesh: Mesh;
  114777. private _skybox;
  114778. /**
  114779. * Gets the skybox created by the helper.
  114780. */
  114781. readonly skybox: Nullable<Mesh>;
  114782. private _skyboxTexture;
  114783. /**
  114784. * Gets the skybox texture created by the helper.
  114785. */
  114786. readonly skyboxTexture: Nullable<BaseTexture>;
  114787. private _skyboxMaterial;
  114788. /**
  114789. * Gets the skybox material created by the helper.
  114790. */
  114791. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114792. private _ground;
  114793. /**
  114794. * Gets the ground mesh created by the helper.
  114795. */
  114796. readonly ground: Nullable<Mesh>;
  114797. private _groundTexture;
  114798. /**
  114799. * Gets the ground texture created by the helper.
  114800. */
  114801. readonly groundTexture: Nullable<BaseTexture>;
  114802. private _groundMirror;
  114803. /**
  114804. * Gets the ground mirror created by the helper.
  114805. */
  114806. readonly groundMirror: Nullable<MirrorTexture>;
  114807. /**
  114808. * Gets the ground mirror render list to helps pushing the meshes
  114809. * you wish in the ground reflection.
  114810. */
  114811. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114812. private _groundMaterial;
  114813. /**
  114814. * Gets the ground material created by the helper.
  114815. */
  114816. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114817. /**
  114818. * Stores the creation options.
  114819. */
  114820. private readonly _scene;
  114821. private _options;
  114822. /**
  114823. * This observable will be notified with any error during the creation of the environment,
  114824. * mainly texture creation errors.
  114825. */
  114826. onErrorObservable: Observable<{
  114827. message?: string;
  114828. exception?: any;
  114829. }>;
  114830. /**
  114831. * constructor
  114832. * @param options Defines the options we want to customize the helper
  114833. * @param scene The scene to add the material to
  114834. */
  114835. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114836. /**
  114837. * Updates the background according to the new options
  114838. * @param options
  114839. */
  114840. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114841. /**
  114842. * Sets the primary color of all the available elements.
  114843. * @param color the main color to affect to the ground and the background
  114844. */
  114845. setMainColor(color: Color3): void;
  114846. /**
  114847. * Setup the image processing according to the specified options.
  114848. */
  114849. private _setupImageProcessing;
  114850. /**
  114851. * Setup the environment texture according to the specified options.
  114852. */
  114853. private _setupEnvironmentTexture;
  114854. /**
  114855. * Setup the background according to the specified options.
  114856. */
  114857. private _setupBackground;
  114858. /**
  114859. * Get the scene sizes according to the setup.
  114860. */
  114861. private _getSceneSize;
  114862. /**
  114863. * Setup the ground according to the specified options.
  114864. */
  114865. private _setupGround;
  114866. /**
  114867. * Setup the ground material according to the specified options.
  114868. */
  114869. private _setupGroundMaterial;
  114870. /**
  114871. * Setup the ground diffuse texture according to the specified options.
  114872. */
  114873. private _setupGroundDiffuseTexture;
  114874. /**
  114875. * Setup the ground mirror texture according to the specified options.
  114876. */
  114877. private _setupGroundMirrorTexture;
  114878. /**
  114879. * Setup the ground to receive the mirror texture.
  114880. */
  114881. private _setupMirrorInGroundMaterial;
  114882. /**
  114883. * Setup the skybox according to the specified options.
  114884. */
  114885. private _setupSkybox;
  114886. /**
  114887. * Setup the skybox material according to the specified options.
  114888. */
  114889. private _setupSkyboxMaterial;
  114890. /**
  114891. * Setup the skybox reflection texture according to the specified options.
  114892. */
  114893. private _setupSkyboxReflectionTexture;
  114894. private _errorHandler;
  114895. /**
  114896. * Dispose all the elements created by the Helper.
  114897. */
  114898. dispose(): void;
  114899. }
  114900. }
  114901. declare module BABYLON {
  114902. /**
  114903. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114904. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114905. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114906. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114907. */
  114908. export class PhotoDome extends TransformNode {
  114909. /**
  114910. * Define the image as a Monoscopic panoramic 360 image.
  114911. */
  114912. static readonly MODE_MONOSCOPIC: number;
  114913. /**
  114914. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114915. */
  114916. static readonly MODE_TOPBOTTOM: number;
  114917. /**
  114918. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114919. */
  114920. static readonly MODE_SIDEBYSIDE: number;
  114921. private _useDirectMapping;
  114922. /**
  114923. * The texture being displayed on the sphere
  114924. */
  114925. protected _photoTexture: Texture;
  114926. /**
  114927. * Gets or sets the texture being displayed on the sphere
  114928. */
  114929. photoTexture: Texture;
  114930. /**
  114931. * Observable raised when an error occured while loading the 360 image
  114932. */
  114933. onLoadErrorObservable: Observable<string>;
  114934. /**
  114935. * The skybox material
  114936. */
  114937. protected _material: BackgroundMaterial;
  114938. /**
  114939. * The surface used for the skybox
  114940. */
  114941. protected _mesh: Mesh;
  114942. /**
  114943. * Gets the mesh used for the skybox.
  114944. */
  114945. readonly mesh: Mesh;
  114946. /**
  114947. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114948. * Also see the options.resolution property.
  114949. */
  114950. fovMultiplier: number;
  114951. private _imageMode;
  114952. /**
  114953. * Gets or set the current video mode for the video. It can be:
  114954. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114955. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114956. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114957. */
  114958. imageMode: number;
  114959. /**
  114960. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114961. * @param name Element's name, child elements will append suffixes for their own names.
  114962. * @param urlsOfPhoto defines the url of the photo to display
  114963. * @param options defines an object containing optional or exposed sub element properties
  114964. * @param onError defines a callback called when an error occured while loading the texture
  114965. */
  114966. constructor(name: string, urlOfPhoto: string, options: {
  114967. resolution?: number;
  114968. size?: number;
  114969. useDirectMapping?: boolean;
  114970. faceForward?: boolean;
  114971. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114972. private _onBeforeCameraRenderObserver;
  114973. private _changeImageMode;
  114974. /**
  114975. * Releases resources associated with this node.
  114976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114978. */
  114979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114980. }
  114981. }
  114982. declare module BABYLON {
  114983. /**
  114984. * Class used to host RGBD texture specific utilities
  114985. */
  114986. export class RGBDTextureTools {
  114987. /**
  114988. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114989. * @param texture the texture to expand.
  114990. */
  114991. static ExpandRGBDTexture(texture: Texture): void;
  114992. }
  114993. }
  114994. declare module BABYLON {
  114995. /**
  114996. * Class used to host texture specific utilities
  114997. */
  114998. export class BRDFTextureTools {
  114999. /**
  115000. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115001. * @param scene defines the hosting scene
  115002. * @returns the environment BRDF texture
  115003. */
  115004. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115005. private static _environmentBRDFBase64Texture;
  115006. }
  115007. }
  115008. declare module BABYLON {
  115009. /**
  115010. * @hidden
  115011. */
  115012. export interface IMaterialClearCoatDefines {
  115013. CLEARCOAT: boolean;
  115014. CLEARCOAT_DEFAULTIOR: boolean;
  115015. CLEARCOAT_TEXTURE: boolean;
  115016. CLEARCOAT_TEXTUREDIRECTUV: number;
  115017. CLEARCOAT_BUMP: boolean;
  115018. CLEARCOAT_BUMPDIRECTUV: number;
  115019. CLEARCOAT_TINT: boolean;
  115020. CLEARCOAT_TINT_TEXTURE: boolean;
  115021. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115022. /** @hidden */
  115023. _areTexturesDirty: boolean;
  115024. }
  115025. /**
  115026. * Define the code related to the clear coat parameters of the pbr material.
  115027. */
  115028. export class PBRClearCoatConfiguration {
  115029. /**
  115030. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115031. * The default fits with a polyurethane material.
  115032. */
  115033. private static readonly _DefaultIndexOfRefraction;
  115034. private _isEnabled;
  115035. /**
  115036. * Defines if the clear coat is enabled in the material.
  115037. */
  115038. isEnabled: boolean;
  115039. /**
  115040. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115041. */
  115042. intensity: number;
  115043. /**
  115044. * Defines the clear coat layer roughness.
  115045. */
  115046. roughness: number;
  115047. private _indexOfRefraction;
  115048. /**
  115049. * Defines the index of refraction of the clear coat.
  115050. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115051. * The default fits with a polyurethane material.
  115052. * Changing the default value is more performance intensive.
  115053. */
  115054. indexOfRefraction: number;
  115055. private _texture;
  115056. /**
  115057. * Stores the clear coat values in a texture.
  115058. */
  115059. texture: Nullable<BaseTexture>;
  115060. private _bumpTexture;
  115061. /**
  115062. * Define the clear coat specific bump texture.
  115063. */
  115064. bumpTexture: Nullable<BaseTexture>;
  115065. private _isTintEnabled;
  115066. /**
  115067. * Defines if the clear coat tint is enabled in the material.
  115068. */
  115069. isTintEnabled: boolean;
  115070. /**
  115071. * Defines the clear coat tint of the material.
  115072. * This is only use if tint is enabled
  115073. */
  115074. tintColor: Color3;
  115075. /**
  115076. * Defines the distance at which the tint color should be found in the
  115077. * clear coat media.
  115078. * This is only use if tint is enabled
  115079. */
  115080. tintColorAtDistance: number;
  115081. /**
  115082. * Defines the clear coat layer thickness.
  115083. * This is only use if tint is enabled
  115084. */
  115085. tintThickness: number;
  115086. private _tintTexture;
  115087. /**
  115088. * Stores the clear tint values in a texture.
  115089. * rgb is tint
  115090. * a is a thickness factor
  115091. */
  115092. tintTexture: Nullable<BaseTexture>;
  115093. /** @hidden */
  115094. private _internalMarkAllSubMeshesAsTexturesDirty;
  115095. /** @hidden */
  115096. _markAllSubMeshesAsTexturesDirty(): void;
  115097. /**
  115098. * Instantiate a new istance of clear coat configuration.
  115099. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115100. */
  115101. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115102. /**
  115103. * Gets wehter the submesh is ready to be used or not.
  115104. * @param defines the list of "defines" to update.
  115105. * @param scene defines the scene the material belongs to.
  115106. * @param engine defines the engine the material belongs to.
  115107. * @param disableBumpMap defines wether the material disables bump or not.
  115108. * @returns - boolean indicating that the submesh is ready or not.
  115109. */
  115110. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115111. /**
  115112. * Checks to see if a texture is used in the material.
  115113. * @param defines the list of "defines" to update.
  115114. * @param scene defines the scene to the material belongs to.
  115115. */
  115116. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115117. /**
  115118. * Binds the material data.
  115119. * @param uniformBuffer defines the Uniform buffer to fill in.
  115120. * @param scene defines the scene the material belongs to.
  115121. * @param engine defines the engine the material belongs to.
  115122. * @param disableBumpMap defines wether the material disables bump or not.
  115123. * @param isFrozen defines wether the material is frozen or not.
  115124. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115125. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115126. */
  115127. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115128. /**
  115129. * Checks to see if a texture is used in the material.
  115130. * @param texture - Base texture to use.
  115131. * @returns - Boolean specifying if a texture is used in the material.
  115132. */
  115133. hasTexture(texture: BaseTexture): boolean;
  115134. /**
  115135. * Returns an array of the actively used textures.
  115136. * @param activeTextures Array of BaseTextures
  115137. */
  115138. getActiveTextures(activeTextures: BaseTexture[]): void;
  115139. /**
  115140. * Returns the animatable textures.
  115141. * @param animatables Array of animatable textures.
  115142. */
  115143. getAnimatables(animatables: IAnimatable[]): void;
  115144. /**
  115145. * Disposes the resources of the material.
  115146. * @param forceDisposeTextures - Forces the disposal of all textures.
  115147. */
  115148. dispose(forceDisposeTextures?: boolean): void;
  115149. /**
  115150. * Get the current class name of the texture useful for serialization or dynamic coding.
  115151. * @returns "PBRClearCoatConfiguration"
  115152. */
  115153. getClassName(): string;
  115154. /**
  115155. * Add fallbacks to the effect fallbacks list.
  115156. * @param defines defines the Base texture to use.
  115157. * @param fallbacks defines the current fallback list.
  115158. * @param currentRank defines the current fallback rank.
  115159. * @returns the new fallback rank.
  115160. */
  115161. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115162. /**
  115163. * Add the required uniforms to the current list.
  115164. * @param uniforms defines the current uniform list.
  115165. */
  115166. static AddUniforms(uniforms: string[]): void;
  115167. /**
  115168. * Add the required samplers to the current list.
  115169. * @param samplers defines the current sampler list.
  115170. */
  115171. static AddSamplers(samplers: string[]): void;
  115172. /**
  115173. * Add the required uniforms to the current buffer.
  115174. * @param uniformBuffer defines the current uniform buffer.
  115175. */
  115176. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115177. /**
  115178. * Makes a duplicate of the current configuration into another one.
  115179. * @param clearCoatConfiguration define the config where to copy the info
  115180. */
  115181. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115182. /**
  115183. * Serializes this clear coat configuration.
  115184. * @returns - An object with the serialized config.
  115185. */
  115186. serialize(): any;
  115187. /**
  115188. * Parses a anisotropy Configuration from a serialized object.
  115189. * @param source - Serialized object.
  115190. * @param scene Defines the scene we are parsing for
  115191. * @param rootUrl Defines the rootUrl to load from
  115192. */
  115193. parse(source: any, scene: Scene, rootUrl: string): void;
  115194. }
  115195. }
  115196. declare module BABYLON {
  115197. /**
  115198. * @hidden
  115199. */
  115200. export interface IMaterialAnisotropicDefines {
  115201. ANISOTROPIC: boolean;
  115202. ANISOTROPIC_TEXTURE: boolean;
  115203. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115204. MAINUV1: boolean;
  115205. _areTexturesDirty: boolean;
  115206. _needUVs: boolean;
  115207. }
  115208. /**
  115209. * Define the code related to the anisotropic parameters of the pbr material.
  115210. */
  115211. export class PBRAnisotropicConfiguration {
  115212. private _isEnabled;
  115213. /**
  115214. * Defines if the anisotropy is enabled in the material.
  115215. */
  115216. isEnabled: boolean;
  115217. /**
  115218. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115219. */
  115220. intensity: number;
  115221. /**
  115222. * Defines if the effect is along the tangents, bitangents or in between.
  115223. * By default, the effect is "strectching" the highlights along the tangents.
  115224. */
  115225. direction: Vector2;
  115226. private _texture;
  115227. /**
  115228. * Stores the anisotropy values in a texture.
  115229. * rg is direction (like normal from -1 to 1)
  115230. * b is a intensity
  115231. */
  115232. texture: Nullable<BaseTexture>;
  115233. /** @hidden */
  115234. private _internalMarkAllSubMeshesAsTexturesDirty;
  115235. /** @hidden */
  115236. _markAllSubMeshesAsTexturesDirty(): void;
  115237. /**
  115238. * Instantiate a new istance of anisotropy configuration.
  115239. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115240. */
  115241. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115242. /**
  115243. * Specifies that the submesh is ready to be used.
  115244. * @param defines the list of "defines" to update.
  115245. * @param scene defines the scene the material belongs to.
  115246. * @returns - boolean indicating that the submesh is ready or not.
  115247. */
  115248. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115249. /**
  115250. * Checks to see if a texture is used in the material.
  115251. * @param defines the list of "defines" to update.
  115252. * @param mesh the mesh we are preparing the defines for.
  115253. * @param scene defines the scene the material belongs to.
  115254. */
  115255. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115256. /**
  115257. * Binds the material data.
  115258. * @param uniformBuffer defines the Uniform buffer to fill in.
  115259. * @param scene defines the scene the material belongs to.
  115260. * @param isFrozen defines wether the material is frozen or not.
  115261. */
  115262. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115263. /**
  115264. * Checks to see if a texture is used in the material.
  115265. * @param texture - Base texture to use.
  115266. * @returns - Boolean specifying if a texture is used in the material.
  115267. */
  115268. hasTexture(texture: BaseTexture): boolean;
  115269. /**
  115270. * Returns an array of the actively used textures.
  115271. * @param activeTextures Array of BaseTextures
  115272. */
  115273. getActiveTextures(activeTextures: BaseTexture[]): void;
  115274. /**
  115275. * Returns the animatable textures.
  115276. * @param animatables Array of animatable textures.
  115277. */
  115278. getAnimatables(animatables: IAnimatable[]): void;
  115279. /**
  115280. * Disposes the resources of the material.
  115281. * @param forceDisposeTextures - Forces the disposal of all textures.
  115282. */
  115283. dispose(forceDisposeTextures?: boolean): void;
  115284. /**
  115285. * Get the current class name of the texture useful for serialization or dynamic coding.
  115286. * @returns "PBRAnisotropicConfiguration"
  115287. */
  115288. getClassName(): string;
  115289. /**
  115290. * Add fallbacks to the effect fallbacks list.
  115291. * @param defines defines the Base texture to use.
  115292. * @param fallbacks defines the current fallback list.
  115293. * @param currentRank defines the current fallback rank.
  115294. * @returns the new fallback rank.
  115295. */
  115296. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115297. /**
  115298. * Add the required uniforms to the current list.
  115299. * @param uniforms defines the current uniform list.
  115300. */
  115301. static AddUniforms(uniforms: string[]): void;
  115302. /**
  115303. * Add the required uniforms to the current buffer.
  115304. * @param uniformBuffer defines the current uniform buffer.
  115305. */
  115306. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115307. /**
  115308. * Add the required samplers to the current list.
  115309. * @param samplers defines the current sampler list.
  115310. */
  115311. static AddSamplers(samplers: string[]): void;
  115312. /**
  115313. * Makes a duplicate of the current configuration into another one.
  115314. * @param anisotropicConfiguration define the config where to copy the info
  115315. */
  115316. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115317. /**
  115318. * Serializes this anisotropy configuration.
  115319. * @returns - An object with the serialized config.
  115320. */
  115321. serialize(): any;
  115322. /**
  115323. * Parses a anisotropy Configuration from a serialized object.
  115324. * @param source - Serialized object.
  115325. * @param scene Defines the scene we are parsing for
  115326. * @param rootUrl Defines the rootUrl to load from
  115327. */
  115328. parse(source: any, scene: Scene, rootUrl: string): void;
  115329. }
  115330. }
  115331. declare module BABYLON {
  115332. /**
  115333. * @hidden
  115334. */
  115335. export interface IMaterialBRDFDefines {
  115336. BRDF_V_HEIGHT_CORRELATED: boolean;
  115337. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115338. SPHERICAL_HARMONICS: boolean;
  115339. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115340. /** @hidden */
  115341. _areMiscDirty: boolean;
  115342. }
  115343. /**
  115344. * Define the code related to the BRDF parameters of the pbr material.
  115345. */
  115346. export class PBRBRDFConfiguration {
  115347. /**
  115348. * Default value used for the energy conservation.
  115349. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115350. */
  115351. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115352. /**
  115353. * Default value used for the Smith Visibility Height Correlated mode.
  115354. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115355. */
  115356. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115357. /**
  115358. * Default value used for the IBL diffuse part.
  115359. * This can help switching back to the polynomials mode globally which is a tiny bit
  115360. * less GPU intensive at the drawback of a lower quality.
  115361. */
  115362. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115363. /**
  115364. * Default value used for activating energy conservation for the specular workflow.
  115365. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115366. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115367. */
  115368. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115369. private _useEnergyConservation;
  115370. /**
  115371. * Defines if the material uses energy conservation.
  115372. */
  115373. useEnergyConservation: boolean;
  115374. private _useSmithVisibilityHeightCorrelated;
  115375. /**
  115376. * LEGACY Mode set to false
  115377. * Defines if the material uses height smith correlated visibility term.
  115378. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115379. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115380. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115381. * Not relying on height correlated will also disable energy conservation.
  115382. */
  115383. useSmithVisibilityHeightCorrelated: boolean;
  115384. private _useSphericalHarmonics;
  115385. /**
  115386. * LEGACY Mode set to false
  115387. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115388. * diffuse part of the IBL.
  115389. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115390. * to the ground truth.
  115391. */
  115392. useSphericalHarmonics: boolean;
  115393. private _useSpecularGlossinessInputEnergyConservation;
  115394. /**
  115395. * Defines if the material uses energy conservation, when the specular workflow is active.
  115396. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115397. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115398. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115399. */
  115400. useSpecularGlossinessInputEnergyConservation: boolean;
  115401. /** @hidden */
  115402. private _internalMarkAllSubMeshesAsMiscDirty;
  115403. /** @hidden */
  115404. _markAllSubMeshesAsMiscDirty(): void;
  115405. /**
  115406. * Instantiate a new istance of clear coat configuration.
  115407. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115408. */
  115409. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115410. /**
  115411. * Checks to see if a texture is used in the material.
  115412. * @param defines the list of "defines" to update.
  115413. */
  115414. prepareDefines(defines: IMaterialBRDFDefines): void;
  115415. /**
  115416. * Get the current class name of the texture useful for serialization or dynamic coding.
  115417. * @returns "PBRClearCoatConfiguration"
  115418. */
  115419. getClassName(): string;
  115420. /**
  115421. * Makes a duplicate of the current configuration into another one.
  115422. * @param brdfConfiguration define the config where to copy the info
  115423. */
  115424. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115425. /**
  115426. * Serializes this BRDF configuration.
  115427. * @returns - An object with the serialized config.
  115428. */
  115429. serialize(): any;
  115430. /**
  115431. * Parses a anisotropy Configuration from a serialized object.
  115432. * @param source - Serialized object.
  115433. * @param scene Defines the scene we are parsing for
  115434. * @param rootUrl Defines the rootUrl to load from
  115435. */
  115436. parse(source: any, scene: Scene, rootUrl: string): void;
  115437. }
  115438. }
  115439. declare module BABYLON {
  115440. /**
  115441. * @hidden
  115442. */
  115443. export interface IMaterialSheenDefines {
  115444. SHEEN: boolean;
  115445. SHEEN_TEXTURE: boolean;
  115446. SHEEN_TEXTUREDIRECTUV: number;
  115447. SHEEN_LINKWITHALBEDO: boolean;
  115448. /** @hidden */
  115449. _areTexturesDirty: boolean;
  115450. }
  115451. /**
  115452. * Define the code related to the Sheen parameters of the pbr material.
  115453. */
  115454. export class PBRSheenConfiguration {
  115455. private _isEnabled;
  115456. /**
  115457. * Defines if the material uses sheen.
  115458. */
  115459. isEnabled: boolean;
  115460. private _linkSheenWithAlbedo;
  115461. /**
  115462. * Defines if the sheen is linked to the sheen color.
  115463. */
  115464. linkSheenWithAlbedo: boolean;
  115465. /**
  115466. * Defines the sheen intensity.
  115467. */
  115468. intensity: number;
  115469. /**
  115470. * Defines the sheen color.
  115471. */
  115472. color: Color3;
  115473. private _texture;
  115474. /**
  115475. * Stores the sheen tint values in a texture.
  115476. * rgb is tint
  115477. * a is a intensity
  115478. */
  115479. texture: Nullable<BaseTexture>;
  115480. /** @hidden */
  115481. private _internalMarkAllSubMeshesAsTexturesDirty;
  115482. /** @hidden */
  115483. _markAllSubMeshesAsTexturesDirty(): void;
  115484. /**
  115485. * Instantiate a new istance of clear coat configuration.
  115486. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115487. */
  115488. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115489. /**
  115490. * Specifies that the submesh is ready to be used.
  115491. * @param defines the list of "defines" to update.
  115492. * @param scene defines the scene the material belongs to.
  115493. * @returns - boolean indicating that the submesh is ready or not.
  115494. */
  115495. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115496. /**
  115497. * Checks to see if a texture is used in the material.
  115498. * @param defines the list of "defines" to update.
  115499. * @param scene defines the scene the material belongs to.
  115500. */
  115501. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115502. /**
  115503. * Binds the material data.
  115504. * @param uniformBuffer defines the Uniform buffer to fill in.
  115505. * @param scene defines the scene the material belongs to.
  115506. * @param isFrozen defines wether the material is frozen or not.
  115507. */
  115508. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115509. /**
  115510. * Checks to see if a texture is used in the material.
  115511. * @param texture - Base texture to use.
  115512. * @returns - Boolean specifying if a texture is used in the material.
  115513. */
  115514. hasTexture(texture: BaseTexture): boolean;
  115515. /**
  115516. * Returns an array of the actively used textures.
  115517. * @param activeTextures Array of BaseTextures
  115518. */
  115519. getActiveTextures(activeTextures: BaseTexture[]): void;
  115520. /**
  115521. * Returns the animatable textures.
  115522. * @param animatables Array of animatable textures.
  115523. */
  115524. getAnimatables(animatables: IAnimatable[]): void;
  115525. /**
  115526. * Disposes the resources of the material.
  115527. * @param forceDisposeTextures - Forces the disposal of all textures.
  115528. */
  115529. dispose(forceDisposeTextures?: boolean): void;
  115530. /**
  115531. * Get the current class name of the texture useful for serialization or dynamic coding.
  115532. * @returns "PBRSheenConfiguration"
  115533. */
  115534. getClassName(): string;
  115535. /**
  115536. * Add fallbacks to the effect fallbacks list.
  115537. * @param defines defines the Base texture to use.
  115538. * @param fallbacks defines the current fallback list.
  115539. * @param currentRank defines the current fallback rank.
  115540. * @returns the new fallback rank.
  115541. */
  115542. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115543. /**
  115544. * Add the required uniforms to the current list.
  115545. * @param uniforms defines the current uniform list.
  115546. */
  115547. static AddUniforms(uniforms: string[]): void;
  115548. /**
  115549. * Add the required uniforms to the current buffer.
  115550. * @param uniformBuffer defines the current uniform buffer.
  115551. */
  115552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115553. /**
  115554. * Add the required samplers to the current list.
  115555. * @param samplers defines the current sampler list.
  115556. */
  115557. static AddSamplers(samplers: string[]): void;
  115558. /**
  115559. * Makes a duplicate of the current configuration into another one.
  115560. * @param sheenConfiguration define the config where to copy the info
  115561. */
  115562. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115563. /**
  115564. * Serializes this BRDF configuration.
  115565. * @returns - An object with the serialized config.
  115566. */
  115567. serialize(): any;
  115568. /**
  115569. * Parses a anisotropy Configuration from a serialized object.
  115570. * @param source - Serialized object.
  115571. * @param scene Defines the scene we are parsing for
  115572. * @param rootUrl Defines the rootUrl to load from
  115573. */
  115574. parse(source: any, scene: Scene, rootUrl: string): void;
  115575. }
  115576. }
  115577. declare module BABYLON {
  115578. /**
  115579. * @hidden
  115580. */
  115581. export interface IMaterialSubSurfaceDefines {
  115582. SUBSURFACE: boolean;
  115583. SS_REFRACTION: boolean;
  115584. SS_TRANSLUCENCY: boolean;
  115585. SS_SCATERRING: boolean;
  115586. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115587. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115588. SS_REFRACTIONMAP_3D: boolean;
  115589. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115590. SS_LODINREFRACTIONALPHA: boolean;
  115591. SS_GAMMAREFRACTION: boolean;
  115592. SS_RGBDREFRACTION: boolean;
  115593. SS_LINEARSPECULARREFRACTION: boolean;
  115594. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115595. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115596. /** @hidden */
  115597. _areTexturesDirty: boolean;
  115598. }
  115599. /**
  115600. * Define the code related to the sub surface parameters of the pbr material.
  115601. */
  115602. export class PBRSubSurfaceConfiguration {
  115603. private _isRefractionEnabled;
  115604. /**
  115605. * Defines if the refraction is enabled in the material.
  115606. */
  115607. isRefractionEnabled: boolean;
  115608. private _isTranslucencyEnabled;
  115609. /**
  115610. * Defines if the translucency is enabled in the material.
  115611. */
  115612. isTranslucencyEnabled: boolean;
  115613. private _isScatteringEnabled;
  115614. /**
  115615. * Defines the refraction intensity of the material.
  115616. * The refraction when enabled replaces the Diffuse part of the material.
  115617. * The intensity helps transitionning between diffuse and refraction.
  115618. */
  115619. refractionIntensity: number;
  115620. /**
  115621. * Defines the translucency intensity of the material.
  115622. * When translucency has been enabled, this defines how much of the "translucency"
  115623. * is addded to the diffuse part of the material.
  115624. */
  115625. translucencyIntensity: number;
  115626. /**
  115627. * Defines the scattering intensity of the material.
  115628. * When scattering has been enabled, this defines how much of the "scattered light"
  115629. * is addded to the diffuse part of the material.
  115630. */
  115631. scatteringIntensity: number;
  115632. private _thicknessTexture;
  115633. /**
  115634. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115635. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115636. * 0 would mean minimumThickness
  115637. * 1 would mean maximumThickness
  115638. * The other channels might be use as a mask to vary the different effects intensity.
  115639. */
  115640. thicknessTexture: Nullable<BaseTexture>;
  115641. private _refractionTexture;
  115642. /**
  115643. * Defines the texture to use for refraction.
  115644. */
  115645. refractionTexture: Nullable<BaseTexture>;
  115646. private _indexOfRefraction;
  115647. /**
  115648. * Defines the index of refraction used in the material.
  115649. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115650. */
  115651. indexOfRefraction: number;
  115652. private _invertRefractionY;
  115653. /**
  115654. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115655. */
  115656. invertRefractionY: boolean;
  115657. private _linkRefractionWithTransparency;
  115658. /**
  115659. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115660. * Materials half opaque for instance using refraction could benefit from this control.
  115661. */
  115662. linkRefractionWithTransparency: boolean;
  115663. /**
  115664. * Defines the minimum thickness stored in the thickness map.
  115665. * If no thickness map is defined, this value will be used to simulate thickness.
  115666. */
  115667. minimumThickness: number;
  115668. /**
  115669. * Defines the maximum thickness stored in the thickness map.
  115670. */
  115671. maximumThickness: number;
  115672. /**
  115673. * Defines the volume tint of the material.
  115674. * This is used for both translucency and scattering.
  115675. */
  115676. tintColor: Color3;
  115677. /**
  115678. * Defines the distance at which the tint color should be found in the media.
  115679. * This is used for refraction only.
  115680. */
  115681. tintColorAtDistance: number;
  115682. /**
  115683. * Defines how far each channel transmit through the media.
  115684. * It is defined as a color to simplify it selection.
  115685. */
  115686. diffusionDistance: Color3;
  115687. private _useMaskFromThicknessTexture;
  115688. /**
  115689. * Stores the intensity of the different subsurface effects in the thickness texture.
  115690. * * the green channel is the translucency intensity.
  115691. * * the blue channel is the scattering intensity.
  115692. * * the alpha channel is the refraction intensity.
  115693. */
  115694. useMaskFromThicknessTexture: boolean;
  115695. /** @hidden */
  115696. private _internalMarkAllSubMeshesAsTexturesDirty;
  115697. /** @hidden */
  115698. _markAllSubMeshesAsTexturesDirty(): void;
  115699. /**
  115700. * Instantiate a new istance of sub surface configuration.
  115701. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115702. */
  115703. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115704. /**
  115705. * Gets wehter the submesh is ready to be used or not.
  115706. * @param defines the list of "defines" to update.
  115707. * @param scene defines the scene the material belongs to.
  115708. * @returns - boolean indicating that the submesh is ready or not.
  115709. */
  115710. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115711. /**
  115712. * Checks to see if a texture is used in the material.
  115713. * @param defines the list of "defines" to update.
  115714. * @param scene defines the scene to the material belongs to.
  115715. */
  115716. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115717. /**
  115718. * Binds the material data.
  115719. * @param uniformBuffer defines the Uniform buffer to fill in.
  115720. * @param scene defines the scene the material belongs to.
  115721. * @param engine defines the engine the material belongs to.
  115722. * @param isFrozen defines wether the material is frozen or not.
  115723. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115724. */
  115725. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115726. /**
  115727. * Unbinds the material from the mesh.
  115728. * @param activeEffect defines the effect that should be unbound from.
  115729. * @returns true if unbound, otherwise false
  115730. */
  115731. unbind(activeEffect: Effect): boolean;
  115732. /**
  115733. * Returns the texture used for refraction or null if none is used.
  115734. * @param scene defines the scene the material belongs to.
  115735. * @returns - Refraction texture if present. If no refraction texture and refraction
  115736. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115737. */
  115738. private _getRefractionTexture;
  115739. /**
  115740. * Returns true if alpha blending should be disabled.
  115741. */
  115742. readonly disableAlphaBlending: boolean;
  115743. /**
  115744. * Fills the list of render target textures.
  115745. * @param renderTargets the list of render targets to update
  115746. */
  115747. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115748. /**
  115749. * Checks to see if a texture is used in the material.
  115750. * @param texture - Base texture to use.
  115751. * @returns - Boolean specifying if a texture is used in the material.
  115752. */
  115753. hasTexture(texture: BaseTexture): boolean;
  115754. /**
  115755. * Gets a boolean indicating that current material needs to register RTT
  115756. * @returns true if this uses a render target otherwise false.
  115757. */
  115758. hasRenderTargetTextures(): boolean;
  115759. /**
  115760. * Returns an array of the actively used textures.
  115761. * @param activeTextures Array of BaseTextures
  115762. */
  115763. getActiveTextures(activeTextures: BaseTexture[]): void;
  115764. /**
  115765. * Returns the animatable textures.
  115766. * @param animatables Array of animatable textures.
  115767. */
  115768. getAnimatables(animatables: IAnimatable[]): void;
  115769. /**
  115770. * Disposes the resources of the material.
  115771. * @param forceDisposeTextures - Forces the disposal of all textures.
  115772. */
  115773. dispose(forceDisposeTextures?: boolean): void;
  115774. /**
  115775. * Get the current class name of the texture useful for serialization or dynamic coding.
  115776. * @returns "PBRSubSurfaceConfiguration"
  115777. */
  115778. getClassName(): string;
  115779. /**
  115780. * Add fallbacks to the effect fallbacks list.
  115781. * @param defines defines the Base texture to use.
  115782. * @param fallbacks defines the current fallback list.
  115783. * @param currentRank defines the current fallback rank.
  115784. * @returns the new fallback rank.
  115785. */
  115786. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115787. /**
  115788. * Add the required uniforms to the current list.
  115789. * @param uniforms defines the current uniform list.
  115790. */
  115791. static AddUniforms(uniforms: string[]): void;
  115792. /**
  115793. * Add the required samplers to the current list.
  115794. * @param samplers defines the current sampler list.
  115795. */
  115796. static AddSamplers(samplers: string[]): void;
  115797. /**
  115798. * Add the required uniforms to the current buffer.
  115799. * @param uniformBuffer defines the current uniform buffer.
  115800. */
  115801. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115802. /**
  115803. * Makes a duplicate of the current configuration into another one.
  115804. * @param configuration define the config where to copy the info
  115805. */
  115806. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115807. /**
  115808. * Serializes this Sub Surface configuration.
  115809. * @returns - An object with the serialized config.
  115810. */
  115811. serialize(): any;
  115812. /**
  115813. * Parses a anisotropy Configuration from a serialized object.
  115814. * @param source - Serialized object.
  115815. * @param scene Defines the scene we are parsing for
  115816. * @param rootUrl Defines the rootUrl to load from
  115817. */
  115818. parse(source: any, scene: Scene, rootUrl: string): void;
  115819. }
  115820. }
  115821. declare module BABYLON {
  115822. /** @hidden */
  115823. export var pbrFragmentDeclaration: {
  115824. name: string;
  115825. shader: string;
  115826. };
  115827. }
  115828. declare module BABYLON {
  115829. /** @hidden */
  115830. export var pbrUboDeclaration: {
  115831. name: string;
  115832. shader: string;
  115833. };
  115834. }
  115835. declare module BABYLON {
  115836. /** @hidden */
  115837. export var pbrFragmentExtraDeclaration: {
  115838. name: string;
  115839. shader: string;
  115840. };
  115841. }
  115842. declare module BABYLON {
  115843. /** @hidden */
  115844. export var pbrFragmentSamplersDeclaration: {
  115845. name: string;
  115846. shader: string;
  115847. };
  115848. }
  115849. declare module BABYLON {
  115850. /** @hidden */
  115851. export var pbrHelperFunctions: {
  115852. name: string;
  115853. shader: string;
  115854. };
  115855. }
  115856. declare module BABYLON {
  115857. /** @hidden */
  115858. export var harmonicsFunctions: {
  115859. name: string;
  115860. shader: string;
  115861. };
  115862. }
  115863. declare module BABYLON {
  115864. /** @hidden */
  115865. export var pbrDirectLightingSetupFunctions: {
  115866. name: string;
  115867. shader: string;
  115868. };
  115869. }
  115870. declare module BABYLON {
  115871. /** @hidden */
  115872. export var pbrDirectLightingFalloffFunctions: {
  115873. name: string;
  115874. shader: string;
  115875. };
  115876. }
  115877. declare module BABYLON {
  115878. /** @hidden */
  115879. export var pbrBRDFFunctions: {
  115880. name: string;
  115881. shader: string;
  115882. };
  115883. }
  115884. declare module BABYLON {
  115885. /** @hidden */
  115886. export var pbrDirectLightingFunctions: {
  115887. name: string;
  115888. shader: string;
  115889. };
  115890. }
  115891. declare module BABYLON {
  115892. /** @hidden */
  115893. export var pbrIBLFunctions: {
  115894. name: string;
  115895. shader: string;
  115896. };
  115897. }
  115898. declare module BABYLON {
  115899. /** @hidden */
  115900. export var pbrDebug: {
  115901. name: string;
  115902. shader: string;
  115903. };
  115904. }
  115905. declare module BABYLON {
  115906. /** @hidden */
  115907. export var pbrPixelShader: {
  115908. name: string;
  115909. shader: string;
  115910. };
  115911. }
  115912. declare module BABYLON {
  115913. /** @hidden */
  115914. export var pbrVertexDeclaration: {
  115915. name: string;
  115916. shader: string;
  115917. };
  115918. }
  115919. declare module BABYLON {
  115920. /** @hidden */
  115921. export var pbrVertexShader: {
  115922. name: string;
  115923. shader: string;
  115924. };
  115925. }
  115926. declare module BABYLON {
  115927. /**
  115928. * Manages the defines for the PBR Material.
  115929. * @hidden
  115930. */
  115931. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115932. PBR: boolean;
  115933. MAINUV1: boolean;
  115934. MAINUV2: boolean;
  115935. UV1: boolean;
  115936. UV2: boolean;
  115937. ALBEDO: boolean;
  115938. ALBEDODIRECTUV: number;
  115939. VERTEXCOLOR: boolean;
  115940. AMBIENT: boolean;
  115941. AMBIENTDIRECTUV: number;
  115942. AMBIENTINGRAYSCALE: boolean;
  115943. OPACITY: boolean;
  115944. VERTEXALPHA: boolean;
  115945. OPACITYDIRECTUV: number;
  115946. OPACITYRGB: boolean;
  115947. ALPHATEST: boolean;
  115948. DEPTHPREPASS: boolean;
  115949. ALPHABLEND: boolean;
  115950. ALPHAFROMALBEDO: boolean;
  115951. ALPHATESTVALUE: string;
  115952. SPECULAROVERALPHA: boolean;
  115953. RADIANCEOVERALPHA: boolean;
  115954. ALPHAFRESNEL: boolean;
  115955. LINEARALPHAFRESNEL: boolean;
  115956. PREMULTIPLYALPHA: boolean;
  115957. EMISSIVE: boolean;
  115958. EMISSIVEDIRECTUV: number;
  115959. REFLECTIVITY: boolean;
  115960. REFLECTIVITYDIRECTUV: number;
  115961. SPECULARTERM: boolean;
  115962. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115963. MICROSURFACEAUTOMATIC: boolean;
  115964. LODBASEDMICROSFURACE: boolean;
  115965. MICROSURFACEMAP: boolean;
  115966. MICROSURFACEMAPDIRECTUV: number;
  115967. METALLICWORKFLOW: boolean;
  115968. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115969. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115970. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115971. AOSTOREINMETALMAPRED: boolean;
  115972. METALLICF0FACTORFROMMETALLICMAP: boolean;
  115973. ENVIRONMENTBRDF: boolean;
  115974. ENVIRONMENTBRDF_RGBD: boolean;
  115975. NORMAL: boolean;
  115976. TANGENT: boolean;
  115977. BUMP: boolean;
  115978. BUMPDIRECTUV: number;
  115979. OBJECTSPACE_NORMALMAP: boolean;
  115980. PARALLAX: boolean;
  115981. PARALLAXOCCLUSION: boolean;
  115982. NORMALXYSCALE: boolean;
  115983. LIGHTMAP: boolean;
  115984. LIGHTMAPDIRECTUV: number;
  115985. USELIGHTMAPASSHADOWMAP: boolean;
  115986. GAMMALIGHTMAP: boolean;
  115987. RGBDLIGHTMAP: boolean;
  115988. REFLECTION: boolean;
  115989. REFLECTIONMAP_3D: boolean;
  115990. REFLECTIONMAP_SPHERICAL: boolean;
  115991. REFLECTIONMAP_PLANAR: boolean;
  115992. REFLECTIONMAP_CUBIC: boolean;
  115993. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115994. REFLECTIONMAP_PROJECTION: boolean;
  115995. REFLECTIONMAP_SKYBOX: boolean;
  115996. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115997. REFLECTIONMAP_EXPLICIT: boolean;
  115998. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115999. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116000. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116001. INVERTCUBICMAP: boolean;
  116002. USESPHERICALFROMREFLECTIONMAP: boolean;
  116003. USEIRRADIANCEMAP: boolean;
  116004. SPHERICAL_HARMONICS: boolean;
  116005. USESPHERICALINVERTEX: boolean;
  116006. REFLECTIONMAP_OPPOSITEZ: boolean;
  116007. LODINREFLECTIONALPHA: boolean;
  116008. GAMMAREFLECTION: boolean;
  116009. RGBDREFLECTION: boolean;
  116010. LINEARSPECULARREFLECTION: boolean;
  116011. RADIANCEOCCLUSION: boolean;
  116012. HORIZONOCCLUSION: boolean;
  116013. INSTANCES: boolean;
  116014. NUM_BONE_INFLUENCERS: number;
  116015. BonesPerMesh: number;
  116016. BONETEXTURE: boolean;
  116017. NONUNIFORMSCALING: boolean;
  116018. MORPHTARGETS: boolean;
  116019. MORPHTARGETS_NORMAL: boolean;
  116020. MORPHTARGETS_TANGENT: boolean;
  116021. MORPHTARGETS_UV: boolean;
  116022. NUM_MORPH_INFLUENCERS: number;
  116023. IMAGEPROCESSING: boolean;
  116024. VIGNETTE: boolean;
  116025. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116026. VIGNETTEBLENDMODEOPAQUE: boolean;
  116027. TONEMAPPING: boolean;
  116028. TONEMAPPING_ACES: boolean;
  116029. CONTRAST: boolean;
  116030. COLORCURVES: boolean;
  116031. COLORGRADING: boolean;
  116032. COLORGRADING3D: boolean;
  116033. SAMPLER3DGREENDEPTH: boolean;
  116034. SAMPLER3DBGRMAP: boolean;
  116035. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116036. EXPOSURE: boolean;
  116037. MULTIVIEW: boolean;
  116038. USEPHYSICALLIGHTFALLOFF: boolean;
  116039. USEGLTFLIGHTFALLOFF: boolean;
  116040. TWOSIDEDLIGHTING: boolean;
  116041. SHADOWFLOAT: boolean;
  116042. CLIPPLANE: boolean;
  116043. CLIPPLANE2: boolean;
  116044. CLIPPLANE3: boolean;
  116045. CLIPPLANE4: boolean;
  116046. POINTSIZE: boolean;
  116047. FOG: boolean;
  116048. LOGARITHMICDEPTH: boolean;
  116049. FORCENORMALFORWARD: boolean;
  116050. SPECULARAA: boolean;
  116051. CLEARCOAT: boolean;
  116052. CLEARCOAT_DEFAULTIOR: boolean;
  116053. CLEARCOAT_TEXTURE: boolean;
  116054. CLEARCOAT_TEXTUREDIRECTUV: number;
  116055. CLEARCOAT_BUMP: boolean;
  116056. CLEARCOAT_BUMPDIRECTUV: number;
  116057. CLEARCOAT_TINT: boolean;
  116058. CLEARCOAT_TINT_TEXTURE: boolean;
  116059. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116060. ANISOTROPIC: boolean;
  116061. ANISOTROPIC_TEXTURE: boolean;
  116062. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116063. BRDF_V_HEIGHT_CORRELATED: boolean;
  116064. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116065. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116066. SHEEN: boolean;
  116067. SHEEN_TEXTURE: boolean;
  116068. SHEEN_TEXTUREDIRECTUV: number;
  116069. SHEEN_LINKWITHALBEDO: boolean;
  116070. SUBSURFACE: boolean;
  116071. SS_REFRACTION: boolean;
  116072. SS_TRANSLUCENCY: boolean;
  116073. SS_SCATERRING: boolean;
  116074. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116075. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116076. SS_REFRACTIONMAP_3D: boolean;
  116077. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116078. SS_LODINREFRACTIONALPHA: boolean;
  116079. SS_GAMMAREFRACTION: boolean;
  116080. SS_RGBDREFRACTION: boolean;
  116081. SS_LINEARSPECULARREFRACTION: boolean;
  116082. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116083. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116084. UNLIT: boolean;
  116085. DEBUGMODE: number;
  116086. /**
  116087. * Initializes the PBR Material defines.
  116088. */
  116089. constructor();
  116090. /**
  116091. * Resets the PBR Material defines.
  116092. */
  116093. reset(): void;
  116094. }
  116095. /**
  116096. * The Physically based material base class of BJS.
  116097. *
  116098. * This offers the main features of a standard PBR material.
  116099. * For more information, please refer to the documentation :
  116100. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116101. */
  116102. export abstract class PBRBaseMaterial extends PushMaterial {
  116103. /**
  116104. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116105. */
  116106. static readonly PBRMATERIAL_OPAQUE: number;
  116107. /**
  116108. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116109. */
  116110. static readonly PBRMATERIAL_ALPHATEST: number;
  116111. /**
  116112. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116113. */
  116114. static readonly PBRMATERIAL_ALPHABLEND: number;
  116115. /**
  116116. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116117. * They are also discarded below the alpha cutoff threshold to improve performances.
  116118. */
  116119. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116120. /**
  116121. * Defines the default value of how much AO map is occluding the analytical lights
  116122. * (point spot...).
  116123. */
  116124. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116125. /**
  116126. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116127. */
  116128. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116129. /**
  116130. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116131. * to enhance interoperability with other engines.
  116132. */
  116133. static readonly LIGHTFALLOFF_GLTF: number;
  116134. /**
  116135. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116136. * to enhance interoperability with other materials.
  116137. */
  116138. static readonly LIGHTFALLOFF_STANDARD: number;
  116139. /**
  116140. * Intensity of the direct lights e.g. the four lights available in your scene.
  116141. * This impacts both the direct diffuse and specular highlights.
  116142. */
  116143. protected _directIntensity: number;
  116144. /**
  116145. * Intensity of the emissive part of the material.
  116146. * This helps controlling the emissive effect without modifying the emissive color.
  116147. */
  116148. protected _emissiveIntensity: number;
  116149. /**
  116150. * Intensity of the environment e.g. how much the environment will light the object
  116151. * either through harmonics for rough material or through the refelction for shiny ones.
  116152. */
  116153. protected _environmentIntensity: number;
  116154. /**
  116155. * This is a special control allowing the reduction of the specular highlights coming from the
  116156. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116157. */
  116158. protected _specularIntensity: number;
  116159. /**
  116160. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116161. */
  116162. private _lightingInfos;
  116163. /**
  116164. * Debug Control allowing disabling the bump map on this material.
  116165. */
  116166. protected _disableBumpMap: boolean;
  116167. /**
  116168. * AKA Diffuse Texture in standard nomenclature.
  116169. */
  116170. protected _albedoTexture: Nullable<BaseTexture>;
  116171. /**
  116172. * AKA Occlusion Texture in other nomenclature.
  116173. */
  116174. protected _ambientTexture: Nullable<BaseTexture>;
  116175. /**
  116176. * AKA Occlusion Texture Intensity in other nomenclature.
  116177. */
  116178. protected _ambientTextureStrength: number;
  116179. /**
  116180. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116181. * 1 means it completely occludes it
  116182. * 0 mean it has no impact
  116183. */
  116184. protected _ambientTextureImpactOnAnalyticalLights: number;
  116185. /**
  116186. * Stores the alpha values in a texture.
  116187. */
  116188. protected _opacityTexture: Nullable<BaseTexture>;
  116189. /**
  116190. * Stores the reflection values in a texture.
  116191. */
  116192. protected _reflectionTexture: Nullable<BaseTexture>;
  116193. /**
  116194. * Stores the emissive values in a texture.
  116195. */
  116196. protected _emissiveTexture: Nullable<BaseTexture>;
  116197. /**
  116198. * AKA Specular texture in other nomenclature.
  116199. */
  116200. protected _reflectivityTexture: Nullable<BaseTexture>;
  116201. /**
  116202. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116203. */
  116204. protected _metallicTexture: Nullable<BaseTexture>;
  116205. /**
  116206. * Specifies the metallic scalar of the metallic/roughness workflow.
  116207. * Can also be used to scale the metalness values of the metallic texture.
  116208. */
  116209. protected _metallic: Nullable<number>;
  116210. /**
  116211. * Specifies the roughness scalar of the metallic/roughness workflow.
  116212. * Can also be used to scale the roughness values of the metallic texture.
  116213. */
  116214. protected _roughness: Nullable<number>;
  116215. /**
  116216. * Specifies the an F0 factor to help configuring the material F0.
  116217. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116218. * to 0.5 the previously hard coded value stays the same.
  116219. * Can also be used to scale the F0 values of the metallic texture.
  116220. */
  116221. protected _metallicF0Factor: number;
  116222. /**
  116223. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116224. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116225. * your expectation as it multiplies with the texture data.
  116226. */
  116227. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116228. /**
  116229. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116230. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116231. */
  116232. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116233. /**
  116234. * Stores surface normal data used to displace a mesh in a texture.
  116235. */
  116236. protected _bumpTexture: Nullable<BaseTexture>;
  116237. /**
  116238. * Stores the pre-calculated light information of a mesh in a texture.
  116239. */
  116240. protected _lightmapTexture: Nullable<BaseTexture>;
  116241. /**
  116242. * The color of a material in ambient lighting.
  116243. */
  116244. protected _ambientColor: Color3;
  116245. /**
  116246. * AKA Diffuse Color in other nomenclature.
  116247. */
  116248. protected _albedoColor: Color3;
  116249. /**
  116250. * AKA Specular Color in other nomenclature.
  116251. */
  116252. protected _reflectivityColor: Color3;
  116253. /**
  116254. * The color applied when light is reflected from a material.
  116255. */
  116256. protected _reflectionColor: Color3;
  116257. /**
  116258. * The color applied when light is emitted from a material.
  116259. */
  116260. protected _emissiveColor: Color3;
  116261. /**
  116262. * AKA Glossiness in other nomenclature.
  116263. */
  116264. protected _microSurface: number;
  116265. /**
  116266. * Specifies that the material will use the light map as a show map.
  116267. */
  116268. protected _useLightmapAsShadowmap: boolean;
  116269. /**
  116270. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116271. * makes the reflect vector face the model (under horizon).
  116272. */
  116273. protected _useHorizonOcclusion: boolean;
  116274. /**
  116275. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116276. * too much the area relying on ambient texture to define their ambient occlusion.
  116277. */
  116278. protected _useRadianceOcclusion: boolean;
  116279. /**
  116280. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116281. */
  116282. protected _useAlphaFromAlbedoTexture: boolean;
  116283. /**
  116284. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116285. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116286. */
  116287. protected _useSpecularOverAlpha: boolean;
  116288. /**
  116289. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116290. */
  116291. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116292. /**
  116293. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116294. */
  116295. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116296. /**
  116297. * Specifies if the metallic texture contains the roughness information in its green channel.
  116298. */
  116299. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116300. /**
  116301. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116302. */
  116303. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116304. /**
  116305. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116306. */
  116307. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116308. /**
  116309. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116310. */
  116311. protected _useAmbientInGrayScale: boolean;
  116312. /**
  116313. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116314. * The material will try to infer what glossiness each pixel should be.
  116315. */
  116316. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116317. /**
  116318. * Defines the falloff type used in this material.
  116319. * It by default is Physical.
  116320. */
  116321. protected _lightFalloff: number;
  116322. /**
  116323. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116324. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116325. */
  116326. protected _useRadianceOverAlpha: boolean;
  116327. /**
  116328. * Allows using an object space normal map (instead of tangent space).
  116329. */
  116330. protected _useObjectSpaceNormalMap: boolean;
  116331. /**
  116332. * Allows using the bump map in parallax mode.
  116333. */
  116334. protected _useParallax: boolean;
  116335. /**
  116336. * Allows using the bump map in parallax occlusion mode.
  116337. */
  116338. protected _useParallaxOcclusion: boolean;
  116339. /**
  116340. * Controls the scale bias of the parallax mode.
  116341. */
  116342. protected _parallaxScaleBias: number;
  116343. /**
  116344. * If sets to true, disables all the lights affecting the material.
  116345. */
  116346. protected _disableLighting: boolean;
  116347. /**
  116348. * Number of Simultaneous lights allowed on the material.
  116349. */
  116350. protected _maxSimultaneousLights: number;
  116351. /**
  116352. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116353. */
  116354. protected _invertNormalMapX: boolean;
  116355. /**
  116356. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116357. */
  116358. protected _invertNormalMapY: boolean;
  116359. /**
  116360. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116361. */
  116362. protected _twoSidedLighting: boolean;
  116363. /**
  116364. * Defines the alpha limits in alpha test mode.
  116365. */
  116366. protected _alphaCutOff: number;
  116367. /**
  116368. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116369. */
  116370. protected _forceAlphaTest: boolean;
  116371. /**
  116372. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116373. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116374. */
  116375. protected _useAlphaFresnel: boolean;
  116376. /**
  116377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116378. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116379. */
  116380. protected _useLinearAlphaFresnel: boolean;
  116381. /**
  116382. * The transparency mode of the material.
  116383. */
  116384. protected _transparencyMode: Nullable<number>;
  116385. /**
  116386. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116387. * from cos thetav and roughness:
  116388. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116389. */
  116390. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116391. /**
  116392. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116393. */
  116394. protected _forceIrradianceInFragment: boolean;
  116395. /**
  116396. * Force normal to face away from face.
  116397. */
  116398. protected _forceNormalForward: boolean;
  116399. /**
  116400. * Enables specular anti aliasing in the PBR shader.
  116401. * It will both interacts on the Geometry for analytical and IBL lighting.
  116402. * It also prefilter the roughness map based on the bump values.
  116403. */
  116404. protected _enableSpecularAntiAliasing: boolean;
  116405. /**
  116406. * Default configuration related to image processing available in the PBR Material.
  116407. */
  116408. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116409. /**
  116410. * Keep track of the image processing observer to allow dispose and replace.
  116411. */
  116412. private _imageProcessingObserver;
  116413. /**
  116414. * Attaches a new image processing configuration to the PBR Material.
  116415. * @param configuration
  116416. */
  116417. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116418. /**
  116419. * Stores the available render targets.
  116420. */
  116421. private _renderTargets;
  116422. /**
  116423. * Sets the global ambient color for the material used in lighting calculations.
  116424. */
  116425. private _globalAmbientColor;
  116426. /**
  116427. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116428. */
  116429. private _useLogarithmicDepth;
  116430. /**
  116431. * If set to true, no lighting calculations will be applied.
  116432. */
  116433. private _unlit;
  116434. private _debugMode;
  116435. /**
  116436. * @hidden
  116437. * This is reserved for the inspector.
  116438. * Defines the material debug mode.
  116439. * It helps seeing only some components of the material while troubleshooting.
  116440. */
  116441. debugMode: number;
  116442. /**
  116443. * @hidden
  116444. * This is reserved for the inspector.
  116445. * Specify from where on screen the debug mode should start.
  116446. * The value goes from -1 (full screen) to 1 (not visible)
  116447. * It helps with side by side comparison against the final render
  116448. * This defaults to -1
  116449. */
  116450. private debugLimit;
  116451. /**
  116452. * @hidden
  116453. * This is reserved for the inspector.
  116454. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116455. * You can use the factor to better multiply the final value.
  116456. */
  116457. private debugFactor;
  116458. /**
  116459. * Defines the clear coat layer parameters for the material.
  116460. */
  116461. readonly clearCoat: PBRClearCoatConfiguration;
  116462. /**
  116463. * Defines the anisotropic parameters for the material.
  116464. */
  116465. readonly anisotropy: PBRAnisotropicConfiguration;
  116466. /**
  116467. * Defines the BRDF parameters for the material.
  116468. */
  116469. readonly brdf: PBRBRDFConfiguration;
  116470. /**
  116471. * Defines the Sheen parameters for the material.
  116472. */
  116473. readonly sheen: PBRSheenConfiguration;
  116474. /**
  116475. * Defines the SubSurface parameters for the material.
  116476. */
  116477. readonly subSurface: PBRSubSurfaceConfiguration;
  116478. /**
  116479. * Custom callback helping to override the default shader used in the material.
  116480. */
  116481. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116482. protected _rebuildInParallel: boolean;
  116483. /**
  116484. * Instantiates a new PBRMaterial instance.
  116485. *
  116486. * @param name The material name
  116487. * @param scene The scene the material will be use in.
  116488. */
  116489. constructor(name: string, scene: Scene);
  116490. /**
  116491. * Gets a boolean indicating that current material needs to register RTT
  116492. */
  116493. readonly hasRenderTargetTextures: boolean;
  116494. /**
  116495. * Gets the name of the material class.
  116496. */
  116497. getClassName(): string;
  116498. /**
  116499. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116500. */
  116501. /**
  116502. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116503. */
  116504. useLogarithmicDepth: boolean;
  116505. /**
  116506. * Gets the current transparency mode.
  116507. */
  116508. /**
  116509. * Sets the transparency mode of the material.
  116510. *
  116511. * | Value | Type | Description |
  116512. * | ----- | ----------------------------------- | ----------- |
  116513. * | 0 | OPAQUE | |
  116514. * | 1 | ALPHATEST | |
  116515. * | 2 | ALPHABLEND | |
  116516. * | 3 | ALPHATESTANDBLEND | |
  116517. *
  116518. */
  116519. transparencyMode: Nullable<number>;
  116520. /**
  116521. * Returns true if alpha blending should be disabled.
  116522. */
  116523. private readonly _disableAlphaBlending;
  116524. /**
  116525. * Specifies whether or not this material should be rendered in alpha blend mode.
  116526. */
  116527. needAlphaBlending(): boolean;
  116528. /**
  116529. * Specifies if the mesh will require alpha blending.
  116530. * @param mesh - BJS mesh.
  116531. */
  116532. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116533. /**
  116534. * Specifies whether or not this material should be rendered in alpha test mode.
  116535. */
  116536. needAlphaTesting(): boolean;
  116537. /**
  116538. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116539. */
  116540. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116541. /**
  116542. * Gets the texture used for the alpha test.
  116543. */
  116544. getAlphaTestTexture(): Nullable<BaseTexture>;
  116545. /**
  116546. * Specifies that the submesh is ready to be used.
  116547. * @param mesh - BJS mesh.
  116548. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116549. * @param useInstances - Specifies that instances should be used.
  116550. * @returns - boolean indicating that the submesh is ready or not.
  116551. */
  116552. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116553. /**
  116554. * Specifies if the material uses metallic roughness workflow.
  116555. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116556. */
  116557. isMetallicWorkflow(): boolean;
  116558. private _prepareEffect;
  116559. private _prepareDefines;
  116560. /**
  116561. * Force shader compilation
  116562. */
  116563. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116564. /**
  116565. * Initializes the uniform buffer layout for the shader.
  116566. */
  116567. buildUniformLayout(): void;
  116568. /**
  116569. * Unbinds the material from the mesh
  116570. */
  116571. unbind(): void;
  116572. /**
  116573. * Binds the submesh data.
  116574. * @param world - The world matrix.
  116575. * @param mesh - The BJS mesh.
  116576. * @param subMesh - A submesh of the BJS mesh.
  116577. */
  116578. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116579. /**
  116580. * Returns the animatable textures.
  116581. * @returns - Array of animatable textures.
  116582. */
  116583. getAnimatables(): IAnimatable[];
  116584. /**
  116585. * Returns the texture used for reflections.
  116586. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116587. */
  116588. private _getReflectionTexture;
  116589. /**
  116590. * Returns an array of the actively used textures.
  116591. * @returns - Array of BaseTextures
  116592. */
  116593. getActiveTextures(): BaseTexture[];
  116594. /**
  116595. * Checks to see if a texture is used in the material.
  116596. * @param texture - Base texture to use.
  116597. * @returns - Boolean specifying if a texture is used in the material.
  116598. */
  116599. hasTexture(texture: BaseTexture): boolean;
  116600. /**
  116601. * Disposes the resources of the material.
  116602. * @param forceDisposeEffect - Forces the disposal of effects.
  116603. * @param forceDisposeTextures - Forces the disposal of all textures.
  116604. */
  116605. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116606. }
  116607. }
  116608. declare module BABYLON {
  116609. /**
  116610. * The Physically based material of BJS.
  116611. *
  116612. * This offers the main features of a standard PBR material.
  116613. * For more information, please refer to the documentation :
  116614. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116615. */
  116616. export class PBRMaterial extends PBRBaseMaterial {
  116617. /**
  116618. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116619. */
  116620. static readonly PBRMATERIAL_OPAQUE: number;
  116621. /**
  116622. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116623. */
  116624. static readonly PBRMATERIAL_ALPHATEST: number;
  116625. /**
  116626. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116627. */
  116628. static readonly PBRMATERIAL_ALPHABLEND: number;
  116629. /**
  116630. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116631. * They are also discarded below the alpha cutoff threshold to improve performances.
  116632. */
  116633. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116634. /**
  116635. * Defines the default value of how much AO map is occluding the analytical lights
  116636. * (point spot...).
  116637. */
  116638. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116639. /**
  116640. * Intensity of the direct lights e.g. the four lights available in your scene.
  116641. * This impacts both the direct diffuse and specular highlights.
  116642. */
  116643. directIntensity: number;
  116644. /**
  116645. * Intensity of the emissive part of the material.
  116646. * This helps controlling the emissive effect without modifying the emissive color.
  116647. */
  116648. emissiveIntensity: number;
  116649. /**
  116650. * Intensity of the environment e.g. how much the environment will light the object
  116651. * either through harmonics for rough material or through the refelction for shiny ones.
  116652. */
  116653. environmentIntensity: number;
  116654. /**
  116655. * This is a special control allowing the reduction of the specular highlights coming from the
  116656. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116657. */
  116658. specularIntensity: number;
  116659. /**
  116660. * Debug Control allowing disabling the bump map on this material.
  116661. */
  116662. disableBumpMap: boolean;
  116663. /**
  116664. * AKA Diffuse Texture in standard nomenclature.
  116665. */
  116666. albedoTexture: BaseTexture;
  116667. /**
  116668. * AKA Occlusion Texture in other nomenclature.
  116669. */
  116670. ambientTexture: BaseTexture;
  116671. /**
  116672. * AKA Occlusion Texture Intensity in other nomenclature.
  116673. */
  116674. ambientTextureStrength: number;
  116675. /**
  116676. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116677. * 1 means it completely occludes it
  116678. * 0 mean it has no impact
  116679. */
  116680. ambientTextureImpactOnAnalyticalLights: number;
  116681. /**
  116682. * Stores the alpha values in a texture.
  116683. */
  116684. opacityTexture: BaseTexture;
  116685. /**
  116686. * Stores the reflection values in a texture.
  116687. */
  116688. reflectionTexture: Nullable<BaseTexture>;
  116689. /**
  116690. * Stores the emissive values in a texture.
  116691. */
  116692. emissiveTexture: BaseTexture;
  116693. /**
  116694. * AKA Specular texture in other nomenclature.
  116695. */
  116696. reflectivityTexture: BaseTexture;
  116697. /**
  116698. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116699. */
  116700. metallicTexture: BaseTexture;
  116701. /**
  116702. * Specifies the metallic scalar of the metallic/roughness workflow.
  116703. * Can also be used to scale the metalness values of the metallic texture.
  116704. */
  116705. metallic: Nullable<number>;
  116706. /**
  116707. * Specifies the roughness scalar of the metallic/roughness workflow.
  116708. * Can also be used to scale the roughness values of the metallic texture.
  116709. */
  116710. roughness: Nullable<number>;
  116711. /**
  116712. * Specifies the an F0 factor to help configuring the material F0.
  116713. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116714. * to 0.5 the previously hard coded value stays the same.
  116715. * Can also be used to scale the F0 values of the metallic texture.
  116716. */
  116717. metallicF0Factor: number;
  116718. /**
  116719. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116720. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116721. * your expectation as it multiplies with the texture data.
  116722. */
  116723. useMetallicF0FactorFromMetallicTexture: boolean;
  116724. /**
  116725. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116726. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116727. */
  116728. microSurfaceTexture: BaseTexture;
  116729. /**
  116730. * Stores surface normal data used to displace a mesh in a texture.
  116731. */
  116732. bumpTexture: BaseTexture;
  116733. /**
  116734. * Stores the pre-calculated light information of a mesh in a texture.
  116735. */
  116736. lightmapTexture: BaseTexture;
  116737. /**
  116738. * Stores the refracted light information in a texture.
  116739. */
  116740. refractionTexture: Nullable<BaseTexture>;
  116741. /**
  116742. * The color of a material in ambient lighting.
  116743. */
  116744. ambientColor: Color3;
  116745. /**
  116746. * AKA Diffuse Color in other nomenclature.
  116747. */
  116748. albedoColor: Color3;
  116749. /**
  116750. * AKA Specular Color in other nomenclature.
  116751. */
  116752. reflectivityColor: Color3;
  116753. /**
  116754. * The color reflected from the material.
  116755. */
  116756. reflectionColor: Color3;
  116757. /**
  116758. * The color emitted from the material.
  116759. */
  116760. emissiveColor: Color3;
  116761. /**
  116762. * AKA Glossiness in other nomenclature.
  116763. */
  116764. microSurface: number;
  116765. /**
  116766. * source material index of refraction (IOR)' / 'destination material IOR.
  116767. */
  116768. indexOfRefraction: number;
  116769. /**
  116770. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116771. */
  116772. invertRefractionY: boolean;
  116773. /**
  116774. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116775. * Materials half opaque for instance using refraction could benefit from this control.
  116776. */
  116777. linkRefractionWithTransparency: boolean;
  116778. /**
  116779. * If true, the light map contains occlusion information instead of lighting info.
  116780. */
  116781. useLightmapAsShadowmap: boolean;
  116782. /**
  116783. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116784. */
  116785. useAlphaFromAlbedoTexture: boolean;
  116786. /**
  116787. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116788. */
  116789. forceAlphaTest: boolean;
  116790. /**
  116791. * Defines the alpha limits in alpha test mode.
  116792. */
  116793. alphaCutOff: number;
  116794. /**
  116795. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116796. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116797. */
  116798. useSpecularOverAlpha: boolean;
  116799. /**
  116800. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116801. */
  116802. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116803. /**
  116804. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116805. */
  116806. useRoughnessFromMetallicTextureAlpha: boolean;
  116807. /**
  116808. * Specifies if the metallic texture contains the roughness information in its green channel.
  116809. */
  116810. useRoughnessFromMetallicTextureGreen: boolean;
  116811. /**
  116812. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116813. */
  116814. useMetallnessFromMetallicTextureBlue: boolean;
  116815. /**
  116816. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116817. */
  116818. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116819. /**
  116820. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116821. */
  116822. useAmbientInGrayScale: boolean;
  116823. /**
  116824. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116825. * The material will try to infer what glossiness each pixel should be.
  116826. */
  116827. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116828. /**
  116829. * BJS is using an harcoded light falloff based on a manually sets up range.
  116830. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116831. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116832. */
  116833. /**
  116834. * BJS is using an harcoded light falloff based on a manually sets up range.
  116835. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116836. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116837. */
  116838. usePhysicalLightFalloff: boolean;
  116839. /**
  116840. * In order to support the falloff compatibility with gltf, a special mode has been added
  116841. * to reproduce the gltf light falloff.
  116842. */
  116843. /**
  116844. * In order to support the falloff compatibility with gltf, a special mode has been added
  116845. * to reproduce the gltf light falloff.
  116846. */
  116847. useGLTFLightFalloff: boolean;
  116848. /**
  116849. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116850. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116851. */
  116852. useRadianceOverAlpha: boolean;
  116853. /**
  116854. * Allows using an object space normal map (instead of tangent space).
  116855. */
  116856. useObjectSpaceNormalMap: boolean;
  116857. /**
  116858. * Allows using the bump map in parallax mode.
  116859. */
  116860. useParallax: boolean;
  116861. /**
  116862. * Allows using the bump map in parallax occlusion mode.
  116863. */
  116864. useParallaxOcclusion: boolean;
  116865. /**
  116866. * Controls the scale bias of the parallax mode.
  116867. */
  116868. parallaxScaleBias: number;
  116869. /**
  116870. * If sets to true, disables all the lights affecting the material.
  116871. */
  116872. disableLighting: boolean;
  116873. /**
  116874. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116875. */
  116876. forceIrradianceInFragment: boolean;
  116877. /**
  116878. * Number of Simultaneous lights allowed on the material.
  116879. */
  116880. maxSimultaneousLights: number;
  116881. /**
  116882. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116883. */
  116884. invertNormalMapX: boolean;
  116885. /**
  116886. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116887. */
  116888. invertNormalMapY: boolean;
  116889. /**
  116890. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116891. */
  116892. twoSidedLighting: boolean;
  116893. /**
  116894. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116895. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116896. */
  116897. useAlphaFresnel: boolean;
  116898. /**
  116899. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116900. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116901. */
  116902. useLinearAlphaFresnel: boolean;
  116903. /**
  116904. * Let user defines the brdf lookup texture used for IBL.
  116905. * A default 8bit version is embedded but you could point at :
  116906. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116907. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116908. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116909. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116910. */
  116911. environmentBRDFTexture: Nullable<BaseTexture>;
  116912. /**
  116913. * Force normal to face away from face.
  116914. */
  116915. forceNormalForward: boolean;
  116916. /**
  116917. * Enables specular anti aliasing in the PBR shader.
  116918. * It will both interacts on the Geometry for analytical and IBL lighting.
  116919. * It also prefilter the roughness map based on the bump values.
  116920. */
  116921. enableSpecularAntiAliasing: boolean;
  116922. /**
  116923. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116924. * makes the reflect vector face the model (under horizon).
  116925. */
  116926. useHorizonOcclusion: boolean;
  116927. /**
  116928. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116929. * too much the area relying on ambient texture to define their ambient occlusion.
  116930. */
  116931. useRadianceOcclusion: boolean;
  116932. /**
  116933. * If set to true, no lighting calculations will be applied.
  116934. */
  116935. unlit: boolean;
  116936. /**
  116937. * Gets the image processing configuration used either in this material.
  116938. */
  116939. /**
  116940. * Sets the Default image processing configuration used either in the this material.
  116941. *
  116942. * If sets to null, the scene one is in use.
  116943. */
  116944. imageProcessingConfiguration: ImageProcessingConfiguration;
  116945. /**
  116946. * Gets wether the color curves effect is enabled.
  116947. */
  116948. /**
  116949. * Sets wether the color curves effect is enabled.
  116950. */
  116951. cameraColorCurvesEnabled: boolean;
  116952. /**
  116953. * Gets wether the color grading effect is enabled.
  116954. */
  116955. /**
  116956. * Gets wether the color grading effect is enabled.
  116957. */
  116958. cameraColorGradingEnabled: boolean;
  116959. /**
  116960. * Gets wether tonemapping is enabled or not.
  116961. */
  116962. /**
  116963. * Sets wether tonemapping is enabled or not
  116964. */
  116965. cameraToneMappingEnabled: boolean;
  116966. /**
  116967. * The camera exposure used on this material.
  116968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116969. * This corresponds to a photographic exposure.
  116970. */
  116971. /**
  116972. * The camera exposure used on this material.
  116973. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116974. * This corresponds to a photographic exposure.
  116975. */
  116976. cameraExposure: number;
  116977. /**
  116978. * Gets The camera contrast used on this material.
  116979. */
  116980. /**
  116981. * Sets The camera contrast used on this material.
  116982. */
  116983. cameraContrast: number;
  116984. /**
  116985. * Gets the Color Grading 2D Lookup Texture.
  116986. */
  116987. /**
  116988. * Sets the Color Grading 2D Lookup Texture.
  116989. */
  116990. cameraColorGradingTexture: Nullable<BaseTexture>;
  116991. /**
  116992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116994. * 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;
  116995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116996. */
  116997. /**
  116998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117000. * 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;
  117001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117002. */
  117003. cameraColorCurves: Nullable<ColorCurves>;
  117004. /**
  117005. * Instantiates a new PBRMaterial instance.
  117006. *
  117007. * @param name The material name
  117008. * @param scene The scene the material will be use in.
  117009. */
  117010. constructor(name: string, scene: Scene);
  117011. /**
  117012. * Returns the name of this material class.
  117013. */
  117014. getClassName(): string;
  117015. /**
  117016. * Makes a duplicate of the current material.
  117017. * @param name - name to use for the new material.
  117018. */
  117019. clone(name: string): PBRMaterial;
  117020. /**
  117021. * Serializes this PBR Material.
  117022. * @returns - An object with the serialized material.
  117023. */
  117024. serialize(): any;
  117025. /**
  117026. * Parses a PBR Material from a serialized object.
  117027. * @param source - Serialized object.
  117028. * @param scene - BJS scene instance.
  117029. * @param rootUrl - url for the scene object
  117030. * @returns - PBRMaterial
  117031. */
  117032. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117033. }
  117034. }
  117035. declare module BABYLON {
  117036. /**
  117037. * Direct draw surface info
  117038. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117039. */
  117040. export interface DDSInfo {
  117041. /**
  117042. * Width of the texture
  117043. */
  117044. width: number;
  117045. /**
  117046. * Width of the texture
  117047. */
  117048. height: number;
  117049. /**
  117050. * Number of Mipmaps for the texture
  117051. * @see https://en.wikipedia.org/wiki/Mipmap
  117052. */
  117053. mipmapCount: number;
  117054. /**
  117055. * If the textures format is a known fourCC format
  117056. * @see https://www.fourcc.org/
  117057. */
  117058. isFourCC: boolean;
  117059. /**
  117060. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117061. */
  117062. isRGB: boolean;
  117063. /**
  117064. * If the texture is a lumincance format
  117065. */
  117066. isLuminance: boolean;
  117067. /**
  117068. * If this is a cube texture
  117069. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117070. */
  117071. isCube: boolean;
  117072. /**
  117073. * If the texture is a compressed format eg. FOURCC_DXT1
  117074. */
  117075. isCompressed: boolean;
  117076. /**
  117077. * The dxgiFormat of the texture
  117078. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117079. */
  117080. dxgiFormat: number;
  117081. /**
  117082. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117083. */
  117084. textureType: number;
  117085. /**
  117086. * Sphericle polynomial created for the dds texture
  117087. */
  117088. sphericalPolynomial?: SphericalPolynomial;
  117089. }
  117090. /**
  117091. * Class used to provide DDS decompression tools
  117092. */
  117093. export class DDSTools {
  117094. /**
  117095. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117096. */
  117097. static StoreLODInAlphaChannel: boolean;
  117098. /**
  117099. * Gets DDS information from an array buffer
  117100. * @param arrayBuffer defines the array buffer to read data from
  117101. * @returns the DDS information
  117102. */
  117103. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117104. private static _FloatView;
  117105. private static _Int32View;
  117106. private static _ToHalfFloat;
  117107. private static _FromHalfFloat;
  117108. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117109. private static _GetHalfFloatRGBAArrayBuffer;
  117110. private static _GetFloatRGBAArrayBuffer;
  117111. private static _GetFloatAsUIntRGBAArrayBuffer;
  117112. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117113. private static _GetRGBAArrayBuffer;
  117114. private static _ExtractLongWordOrder;
  117115. private static _GetRGBArrayBuffer;
  117116. private static _GetLuminanceArrayBuffer;
  117117. /**
  117118. * Uploads DDS Levels to a Babylon Texture
  117119. * @hidden
  117120. */
  117121. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117122. }
  117123. interface ThinEngine {
  117124. /**
  117125. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117126. * @param rootUrl defines the url where the file to load is located
  117127. * @param scene defines the current scene
  117128. * @param lodScale defines scale to apply to the mip map selection
  117129. * @param lodOffset defines offset to apply to the mip map selection
  117130. * @param onLoad defines an optional callback raised when the texture is loaded
  117131. * @param onError defines an optional callback raised if there is an issue to load the texture
  117132. * @param format defines the format of the data
  117133. * @param forcedExtension defines the extension to use to pick the right loader
  117134. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117135. * @returns the cube texture as an InternalTexture
  117136. */
  117137. 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;
  117138. }
  117139. }
  117140. declare module BABYLON {
  117141. /**
  117142. * Implementation of the DDS Texture Loader.
  117143. * @hidden
  117144. */
  117145. export class _DDSTextureLoader implements IInternalTextureLoader {
  117146. /**
  117147. * Defines wether the loader supports cascade loading the different faces.
  117148. */
  117149. readonly supportCascades: boolean;
  117150. /**
  117151. * This returns if the loader support the current file information.
  117152. * @param extension defines the file extension of the file being loaded
  117153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117154. * @param fallback defines the fallback internal texture if any
  117155. * @param isBase64 defines whether the texture is encoded as a base64
  117156. * @param isBuffer defines whether the texture data are stored as a buffer
  117157. * @returns true if the loader can load the specified file
  117158. */
  117159. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117160. /**
  117161. * Transform the url before loading if required.
  117162. * @param rootUrl the url of the texture
  117163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117164. * @returns the transformed texture
  117165. */
  117166. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117167. /**
  117168. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117169. * @param rootUrl the url of the texture
  117170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117171. * @returns the fallback texture
  117172. */
  117173. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117174. /**
  117175. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117176. * @param data contains the texture data
  117177. * @param texture defines the BabylonJS internal texture
  117178. * @param createPolynomials will be true if polynomials have been requested
  117179. * @param onLoad defines the callback to trigger once the texture is ready
  117180. * @param onError defines the callback to trigger in case of error
  117181. */
  117182. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117183. /**
  117184. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117185. * @param data contains the texture data
  117186. * @param texture defines the BabylonJS internal texture
  117187. * @param callback defines the method to call once ready to upload
  117188. */
  117189. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117190. }
  117191. }
  117192. declare module BABYLON {
  117193. /**
  117194. * Implementation of the ENV Texture Loader.
  117195. * @hidden
  117196. */
  117197. export class _ENVTextureLoader implements IInternalTextureLoader {
  117198. /**
  117199. * Defines wether the loader supports cascade loading the different faces.
  117200. */
  117201. readonly supportCascades: boolean;
  117202. /**
  117203. * This returns if the loader support the current file information.
  117204. * @param extension defines the file extension of the file being loaded
  117205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117206. * @param fallback defines the fallback internal texture if any
  117207. * @param isBase64 defines whether the texture is encoded as a base64
  117208. * @param isBuffer defines whether the texture data are stored as a buffer
  117209. * @returns true if the loader can load the specified file
  117210. */
  117211. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117212. /**
  117213. * Transform the url before loading if required.
  117214. * @param rootUrl the url of the texture
  117215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117216. * @returns the transformed texture
  117217. */
  117218. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117219. /**
  117220. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117221. * @param rootUrl the url of the texture
  117222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117223. * @returns the fallback texture
  117224. */
  117225. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117226. /**
  117227. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117228. * @param data contains the texture data
  117229. * @param texture defines the BabylonJS internal texture
  117230. * @param createPolynomials will be true if polynomials have been requested
  117231. * @param onLoad defines the callback to trigger once the texture is ready
  117232. * @param onError defines the callback to trigger in case of error
  117233. */
  117234. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117235. /**
  117236. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117237. * @param data contains the texture data
  117238. * @param texture defines the BabylonJS internal texture
  117239. * @param callback defines the method to call once ready to upload
  117240. */
  117241. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117242. }
  117243. }
  117244. declare module BABYLON {
  117245. /**
  117246. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117247. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117248. */
  117249. export class KhronosTextureContainer {
  117250. /** contents of the KTX container file */
  117251. arrayBuffer: any;
  117252. private static HEADER_LEN;
  117253. private static COMPRESSED_2D;
  117254. private static COMPRESSED_3D;
  117255. private static TEX_2D;
  117256. private static TEX_3D;
  117257. /**
  117258. * Gets the openGL type
  117259. */
  117260. glType: number;
  117261. /**
  117262. * Gets the openGL type size
  117263. */
  117264. glTypeSize: number;
  117265. /**
  117266. * Gets the openGL format
  117267. */
  117268. glFormat: number;
  117269. /**
  117270. * Gets the openGL internal format
  117271. */
  117272. glInternalFormat: number;
  117273. /**
  117274. * Gets the base internal format
  117275. */
  117276. glBaseInternalFormat: number;
  117277. /**
  117278. * Gets image width in pixel
  117279. */
  117280. pixelWidth: number;
  117281. /**
  117282. * Gets image height in pixel
  117283. */
  117284. pixelHeight: number;
  117285. /**
  117286. * Gets image depth in pixels
  117287. */
  117288. pixelDepth: number;
  117289. /**
  117290. * Gets the number of array elements
  117291. */
  117292. numberOfArrayElements: number;
  117293. /**
  117294. * Gets the number of faces
  117295. */
  117296. numberOfFaces: number;
  117297. /**
  117298. * Gets the number of mipmap levels
  117299. */
  117300. numberOfMipmapLevels: number;
  117301. /**
  117302. * Gets the bytes of key value data
  117303. */
  117304. bytesOfKeyValueData: number;
  117305. /**
  117306. * Gets the load type
  117307. */
  117308. loadType: number;
  117309. /**
  117310. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117311. */
  117312. isInvalid: boolean;
  117313. /**
  117314. * Creates a new KhronosTextureContainer
  117315. * @param arrayBuffer contents of the KTX container file
  117316. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117317. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117318. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117319. */
  117320. constructor(
  117321. /** contents of the KTX container file */
  117322. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117323. /**
  117324. * Uploads KTX content to a Babylon Texture.
  117325. * It is assumed that the texture has already been created & is currently bound
  117326. * @hidden
  117327. */
  117328. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117329. private _upload2DCompressedLevels;
  117330. }
  117331. }
  117332. declare module BABYLON {
  117333. /**
  117334. * Implementation of the KTX Texture Loader.
  117335. * @hidden
  117336. */
  117337. export class _KTXTextureLoader implements IInternalTextureLoader {
  117338. /**
  117339. * Defines wether the loader supports cascade loading the different faces.
  117340. */
  117341. readonly supportCascades: boolean;
  117342. /**
  117343. * This returns if the loader support the current file information.
  117344. * @param extension defines the file extension of the file being loaded
  117345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117346. * @param fallback defines the fallback internal texture if any
  117347. * @param isBase64 defines whether the texture is encoded as a base64
  117348. * @param isBuffer defines whether the texture data are stored as a buffer
  117349. * @returns true if the loader can load the specified file
  117350. */
  117351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117352. /**
  117353. * Transform the url before loading if required.
  117354. * @param rootUrl the url of the texture
  117355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117356. * @returns the transformed texture
  117357. */
  117358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117359. /**
  117360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117361. * @param rootUrl the url of the texture
  117362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117363. * @returns the fallback texture
  117364. */
  117365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117366. /**
  117367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117368. * @param data contains the texture data
  117369. * @param texture defines the BabylonJS internal texture
  117370. * @param createPolynomials will be true if polynomials have been requested
  117371. * @param onLoad defines the callback to trigger once the texture is ready
  117372. * @param onError defines the callback to trigger in case of error
  117373. */
  117374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117375. /**
  117376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117377. * @param data contains the texture data
  117378. * @param texture defines the BabylonJS internal texture
  117379. * @param callback defines the method to call once ready to upload
  117380. */
  117381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117382. }
  117383. }
  117384. declare module BABYLON {
  117385. /**
  117386. * Options for the default xr helper
  117387. */
  117388. export class WebXRDefaultExperienceOptions {
  117389. /**
  117390. * Floor meshes that should be used for teleporting
  117391. */
  117392. floorMeshes: Array<AbstractMesh>;
  117393. /**
  117394. * Enable or disable default UI to enter XR
  117395. */
  117396. disableDefaultUI: boolean;
  117397. }
  117398. /**
  117399. * Default experience which provides a similar setup to the previous webVRExperience
  117400. */
  117401. export class WebXRDefaultExperience {
  117402. /**
  117403. * Base experience
  117404. */
  117405. baseExperience: WebXRExperienceHelper;
  117406. /**
  117407. * Input experience extension
  117408. */
  117409. input: WebXRInput;
  117410. /**
  117411. * Loads the controller models
  117412. */
  117413. controllerModelLoader: WebXRControllerModelLoader;
  117414. /**
  117415. * Enables laser pointer and selection
  117416. */
  117417. pointerSelection: WebXRControllerPointerSelection;
  117418. /**
  117419. * Enables teleportation
  117420. */
  117421. teleportation: WebXRControllerTeleportation;
  117422. /**
  117423. * Enables ui for enetering/exiting xr
  117424. */
  117425. enterExitUI: WebXREnterExitUI;
  117426. /**
  117427. * Default target xr should render to
  117428. */
  117429. renderTarget: WebXRRenderTarget;
  117430. /**
  117431. * Creates the default xr experience
  117432. * @param scene scene
  117433. * @param options options for basic configuration
  117434. * @returns resulting WebXRDefaultExperience
  117435. */
  117436. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117437. private constructor();
  117438. /**
  117439. * DIsposes of the experience helper
  117440. */
  117441. dispose(): void;
  117442. }
  117443. }
  117444. declare module BABYLON {
  117445. /** @hidden */
  117446. export var _forceSceneHelpersToBundle: boolean;
  117447. interface Scene {
  117448. /**
  117449. * Creates a default light for the scene.
  117450. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117451. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117452. */
  117453. createDefaultLight(replace?: boolean): void;
  117454. /**
  117455. * Creates a default camera for the scene.
  117456. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117457. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117458. * @param replace has default false, when true replaces the active camera in the scene
  117459. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117460. */
  117461. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117462. /**
  117463. * Creates a default camera and a default light.
  117464. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117465. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117466. * @param replace has the default false, when true replaces the active camera/light in the scene
  117467. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117468. */
  117469. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117470. /**
  117471. * Creates a new sky box
  117472. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117473. * @param environmentTexture defines the texture to use as environment texture
  117474. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117475. * @param scale defines the overall scale of the skybox
  117476. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117477. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117478. * @returns a new mesh holding the sky box
  117479. */
  117480. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117481. /**
  117482. * Creates a new environment
  117483. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117484. * @param options defines the options you can use to configure the environment
  117485. * @returns the new EnvironmentHelper
  117486. */
  117487. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117488. /**
  117489. * Creates a new VREXperienceHelper
  117490. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117491. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117492. * @returns a new VREXperienceHelper
  117493. */
  117494. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117495. /**
  117496. * Creates a new WebXRDefaultExperience
  117497. * @see http://doc.babylonjs.com/how_to/webxr
  117498. * @param options experience options
  117499. * @returns a promise for a new WebXRDefaultExperience
  117500. */
  117501. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117502. }
  117503. }
  117504. declare module BABYLON {
  117505. /**
  117506. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117507. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117508. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117509. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117510. */
  117511. export class VideoDome extends TransformNode {
  117512. /**
  117513. * Define the video source as a Monoscopic panoramic 360 video.
  117514. */
  117515. static readonly MODE_MONOSCOPIC: number;
  117516. /**
  117517. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117518. */
  117519. static readonly MODE_TOPBOTTOM: number;
  117520. /**
  117521. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117522. */
  117523. static readonly MODE_SIDEBYSIDE: number;
  117524. private _halfDome;
  117525. private _useDirectMapping;
  117526. /**
  117527. * The video texture being displayed on the sphere
  117528. */
  117529. protected _videoTexture: VideoTexture;
  117530. /**
  117531. * Gets the video texture being displayed on the sphere
  117532. */
  117533. readonly videoTexture: VideoTexture;
  117534. /**
  117535. * The skybox material
  117536. */
  117537. protected _material: BackgroundMaterial;
  117538. /**
  117539. * The surface used for the skybox
  117540. */
  117541. protected _mesh: Mesh;
  117542. /**
  117543. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117544. */
  117545. private _halfDomeMask;
  117546. /**
  117547. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117548. * Also see the options.resolution property.
  117549. */
  117550. fovMultiplier: number;
  117551. private _videoMode;
  117552. /**
  117553. * Gets or set the current video mode for the video. It can be:
  117554. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117555. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117556. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117557. */
  117558. videoMode: number;
  117559. /**
  117560. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117561. *
  117562. */
  117563. /**
  117564. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117565. */
  117566. halfDome: boolean;
  117567. /**
  117568. * Oberserver used in Stereoscopic VR Mode.
  117569. */
  117570. private _onBeforeCameraRenderObserver;
  117571. /**
  117572. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117573. * @param name Element's name, child elements will append suffixes for their own names.
  117574. * @param urlsOrVideo defines the url(s) or the video element to use
  117575. * @param options An object containing optional or exposed sub element properties
  117576. */
  117577. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117578. resolution?: number;
  117579. clickToPlay?: boolean;
  117580. autoPlay?: boolean;
  117581. loop?: boolean;
  117582. size?: number;
  117583. poster?: string;
  117584. faceForward?: boolean;
  117585. useDirectMapping?: boolean;
  117586. halfDomeMode?: boolean;
  117587. }, scene: Scene);
  117588. private _changeVideoMode;
  117589. /**
  117590. * Releases resources associated with this node.
  117591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117593. */
  117594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117595. }
  117596. }
  117597. declare module BABYLON {
  117598. /**
  117599. * This class can be used to get instrumentation data from a Babylon engine
  117600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117601. */
  117602. export class EngineInstrumentation implements IDisposable {
  117603. /**
  117604. * Define the instrumented engine.
  117605. */
  117606. engine: Engine;
  117607. private _captureGPUFrameTime;
  117608. private _gpuFrameTimeToken;
  117609. private _gpuFrameTime;
  117610. private _captureShaderCompilationTime;
  117611. private _shaderCompilationTime;
  117612. private _onBeginFrameObserver;
  117613. private _onEndFrameObserver;
  117614. private _onBeforeShaderCompilationObserver;
  117615. private _onAfterShaderCompilationObserver;
  117616. /**
  117617. * Gets the perf counter used for GPU frame time
  117618. */
  117619. readonly gpuFrameTimeCounter: PerfCounter;
  117620. /**
  117621. * Gets the GPU frame time capture status
  117622. */
  117623. /**
  117624. * Enable or disable the GPU frame time capture
  117625. */
  117626. captureGPUFrameTime: boolean;
  117627. /**
  117628. * Gets the perf counter used for shader compilation time
  117629. */
  117630. readonly shaderCompilationTimeCounter: PerfCounter;
  117631. /**
  117632. * Gets the shader compilation time capture status
  117633. */
  117634. /**
  117635. * Enable or disable the shader compilation time capture
  117636. */
  117637. captureShaderCompilationTime: boolean;
  117638. /**
  117639. * Instantiates a new engine instrumentation.
  117640. * This class can be used to get instrumentation data from a Babylon engine
  117641. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117642. * @param engine Defines the engine to instrument
  117643. */
  117644. constructor(
  117645. /**
  117646. * Define the instrumented engine.
  117647. */
  117648. engine: Engine);
  117649. /**
  117650. * Dispose and release associated resources.
  117651. */
  117652. dispose(): void;
  117653. }
  117654. }
  117655. declare module BABYLON {
  117656. /**
  117657. * This class can be used to get instrumentation data from a Babylon engine
  117658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117659. */
  117660. export class SceneInstrumentation implements IDisposable {
  117661. /**
  117662. * Defines the scene to instrument
  117663. */
  117664. scene: Scene;
  117665. private _captureActiveMeshesEvaluationTime;
  117666. private _activeMeshesEvaluationTime;
  117667. private _captureRenderTargetsRenderTime;
  117668. private _renderTargetsRenderTime;
  117669. private _captureFrameTime;
  117670. private _frameTime;
  117671. private _captureRenderTime;
  117672. private _renderTime;
  117673. private _captureInterFrameTime;
  117674. private _interFrameTime;
  117675. private _captureParticlesRenderTime;
  117676. private _particlesRenderTime;
  117677. private _captureSpritesRenderTime;
  117678. private _spritesRenderTime;
  117679. private _capturePhysicsTime;
  117680. private _physicsTime;
  117681. private _captureAnimationsTime;
  117682. private _animationsTime;
  117683. private _captureCameraRenderTime;
  117684. private _cameraRenderTime;
  117685. private _onBeforeActiveMeshesEvaluationObserver;
  117686. private _onAfterActiveMeshesEvaluationObserver;
  117687. private _onBeforeRenderTargetsRenderObserver;
  117688. private _onAfterRenderTargetsRenderObserver;
  117689. private _onAfterRenderObserver;
  117690. private _onBeforeDrawPhaseObserver;
  117691. private _onAfterDrawPhaseObserver;
  117692. private _onBeforeAnimationsObserver;
  117693. private _onBeforeParticlesRenderingObserver;
  117694. private _onAfterParticlesRenderingObserver;
  117695. private _onBeforeSpritesRenderingObserver;
  117696. private _onAfterSpritesRenderingObserver;
  117697. private _onBeforePhysicsObserver;
  117698. private _onAfterPhysicsObserver;
  117699. private _onAfterAnimationsObserver;
  117700. private _onBeforeCameraRenderObserver;
  117701. private _onAfterCameraRenderObserver;
  117702. /**
  117703. * Gets the perf counter used for active meshes evaluation time
  117704. */
  117705. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117706. /**
  117707. * Gets the active meshes evaluation time capture status
  117708. */
  117709. /**
  117710. * Enable or disable the active meshes evaluation time capture
  117711. */
  117712. captureActiveMeshesEvaluationTime: boolean;
  117713. /**
  117714. * Gets the perf counter used for render targets render time
  117715. */
  117716. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117717. /**
  117718. * Gets the render targets render time capture status
  117719. */
  117720. /**
  117721. * Enable or disable the render targets render time capture
  117722. */
  117723. captureRenderTargetsRenderTime: boolean;
  117724. /**
  117725. * Gets the perf counter used for particles render time
  117726. */
  117727. readonly particlesRenderTimeCounter: PerfCounter;
  117728. /**
  117729. * Gets the particles render time capture status
  117730. */
  117731. /**
  117732. * Enable or disable the particles render time capture
  117733. */
  117734. captureParticlesRenderTime: boolean;
  117735. /**
  117736. * Gets the perf counter used for sprites render time
  117737. */
  117738. readonly spritesRenderTimeCounter: PerfCounter;
  117739. /**
  117740. * Gets the sprites render time capture status
  117741. */
  117742. /**
  117743. * Enable or disable the sprites render time capture
  117744. */
  117745. captureSpritesRenderTime: boolean;
  117746. /**
  117747. * Gets the perf counter used for physics time
  117748. */
  117749. readonly physicsTimeCounter: PerfCounter;
  117750. /**
  117751. * Gets the physics time capture status
  117752. */
  117753. /**
  117754. * Enable or disable the physics time capture
  117755. */
  117756. capturePhysicsTime: boolean;
  117757. /**
  117758. * Gets the perf counter used for animations time
  117759. */
  117760. readonly animationsTimeCounter: PerfCounter;
  117761. /**
  117762. * Gets the animations time capture status
  117763. */
  117764. /**
  117765. * Enable or disable the animations time capture
  117766. */
  117767. captureAnimationsTime: boolean;
  117768. /**
  117769. * Gets the perf counter used for frame time capture
  117770. */
  117771. readonly frameTimeCounter: PerfCounter;
  117772. /**
  117773. * Gets the frame time capture status
  117774. */
  117775. /**
  117776. * Enable or disable the frame time capture
  117777. */
  117778. captureFrameTime: boolean;
  117779. /**
  117780. * Gets the perf counter used for inter-frames time capture
  117781. */
  117782. readonly interFrameTimeCounter: PerfCounter;
  117783. /**
  117784. * Gets the inter-frames time capture status
  117785. */
  117786. /**
  117787. * Enable or disable the inter-frames time capture
  117788. */
  117789. captureInterFrameTime: boolean;
  117790. /**
  117791. * Gets the perf counter used for render time capture
  117792. */
  117793. readonly renderTimeCounter: PerfCounter;
  117794. /**
  117795. * Gets the render time capture status
  117796. */
  117797. /**
  117798. * Enable or disable the render time capture
  117799. */
  117800. captureRenderTime: boolean;
  117801. /**
  117802. * Gets the perf counter used for camera render time capture
  117803. */
  117804. readonly cameraRenderTimeCounter: PerfCounter;
  117805. /**
  117806. * Gets the camera render time capture status
  117807. */
  117808. /**
  117809. * Enable or disable the camera render time capture
  117810. */
  117811. captureCameraRenderTime: boolean;
  117812. /**
  117813. * Gets the perf counter used for draw calls
  117814. */
  117815. readonly drawCallsCounter: PerfCounter;
  117816. /**
  117817. * Instantiates a new scene instrumentation.
  117818. * This class can be used to get instrumentation data from a Babylon engine
  117819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117820. * @param scene Defines the scene to instrument
  117821. */
  117822. constructor(
  117823. /**
  117824. * Defines the scene to instrument
  117825. */
  117826. scene: Scene);
  117827. /**
  117828. * Dispose and release associated resources.
  117829. */
  117830. dispose(): void;
  117831. }
  117832. }
  117833. declare module BABYLON {
  117834. /** @hidden */
  117835. export var glowMapGenerationPixelShader: {
  117836. name: string;
  117837. shader: string;
  117838. };
  117839. }
  117840. declare module BABYLON {
  117841. /** @hidden */
  117842. export var glowMapGenerationVertexShader: {
  117843. name: string;
  117844. shader: string;
  117845. };
  117846. }
  117847. declare module BABYLON {
  117848. /**
  117849. * Effect layer options. This helps customizing the behaviour
  117850. * of the effect layer.
  117851. */
  117852. export interface IEffectLayerOptions {
  117853. /**
  117854. * Multiplication factor apply to the canvas size to compute the render target size
  117855. * used to generated the objects (the smaller the faster).
  117856. */
  117857. mainTextureRatio: number;
  117858. /**
  117859. * Enforces a fixed size texture to ensure effect stability across devices.
  117860. */
  117861. mainTextureFixedSize?: number;
  117862. /**
  117863. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117864. */
  117865. alphaBlendingMode: number;
  117866. /**
  117867. * The camera attached to the layer.
  117868. */
  117869. camera: Nullable<Camera>;
  117870. /**
  117871. * The rendering group to draw the layer in.
  117872. */
  117873. renderingGroupId: number;
  117874. }
  117875. /**
  117876. * The effect layer Helps adding post process effect blended with the main pass.
  117877. *
  117878. * This can be for instance use to generate glow or higlight effects on the scene.
  117879. *
  117880. * The effect layer class can not be used directly and is intented to inherited from to be
  117881. * customized per effects.
  117882. */
  117883. export abstract class EffectLayer {
  117884. private _vertexBuffers;
  117885. private _indexBuffer;
  117886. private _cachedDefines;
  117887. private _effectLayerMapGenerationEffect;
  117888. private _effectLayerOptions;
  117889. private _mergeEffect;
  117890. protected _scene: Scene;
  117891. protected _engine: Engine;
  117892. protected _maxSize: number;
  117893. protected _mainTextureDesiredSize: ISize;
  117894. protected _mainTexture: RenderTargetTexture;
  117895. protected _shouldRender: boolean;
  117896. protected _postProcesses: PostProcess[];
  117897. protected _textures: BaseTexture[];
  117898. protected _emissiveTextureAndColor: {
  117899. texture: Nullable<BaseTexture>;
  117900. color: Color4;
  117901. };
  117902. /**
  117903. * The name of the layer
  117904. */
  117905. name: string;
  117906. /**
  117907. * The clear color of the texture used to generate the glow map.
  117908. */
  117909. neutralColor: Color4;
  117910. /**
  117911. * Specifies wether the highlight layer is enabled or not.
  117912. */
  117913. isEnabled: boolean;
  117914. /**
  117915. * Gets the camera attached to the layer.
  117916. */
  117917. readonly camera: Nullable<Camera>;
  117918. /**
  117919. * Gets the rendering group id the layer should render in.
  117920. */
  117921. renderingGroupId: number;
  117922. /**
  117923. * An event triggered when the effect layer has been disposed.
  117924. */
  117925. onDisposeObservable: Observable<EffectLayer>;
  117926. /**
  117927. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117928. */
  117929. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117930. /**
  117931. * An event triggered when the generated texture is being merged in the scene.
  117932. */
  117933. onBeforeComposeObservable: Observable<EffectLayer>;
  117934. /**
  117935. * An event triggered when the mesh is rendered into the effect render target.
  117936. */
  117937. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117938. /**
  117939. * An event triggered after the mesh has been rendered into the effect render target.
  117940. */
  117941. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117942. /**
  117943. * An event triggered when the generated texture has been merged in the scene.
  117944. */
  117945. onAfterComposeObservable: Observable<EffectLayer>;
  117946. /**
  117947. * An event triggered when the efffect layer changes its size.
  117948. */
  117949. onSizeChangedObservable: Observable<EffectLayer>;
  117950. /** @hidden */
  117951. static _SceneComponentInitialization: (scene: Scene) => void;
  117952. /**
  117953. * Instantiates a new effect Layer and references it in the scene.
  117954. * @param name The name of the layer
  117955. * @param scene The scene to use the layer in
  117956. */
  117957. constructor(
  117958. /** The Friendly of the effect in the scene */
  117959. name: string, scene: Scene);
  117960. /**
  117961. * Get the effect name of the layer.
  117962. * @return The effect name
  117963. */
  117964. abstract getEffectName(): string;
  117965. /**
  117966. * Checks for the readiness of the element composing the layer.
  117967. * @param subMesh the mesh to check for
  117968. * @param useInstances specify wether or not to use instances to render the mesh
  117969. * @return true if ready otherwise, false
  117970. */
  117971. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117972. /**
  117973. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117974. * @returns true if the effect requires stencil during the main canvas render pass.
  117975. */
  117976. abstract needStencil(): boolean;
  117977. /**
  117978. * Create the merge effect. This is the shader use to blit the information back
  117979. * to the main canvas at the end of the scene rendering.
  117980. * @returns The effect containing the shader used to merge the effect on the main canvas
  117981. */
  117982. protected abstract _createMergeEffect(): Effect;
  117983. /**
  117984. * Creates the render target textures and post processes used in the effect layer.
  117985. */
  117986. protected abstract _createTextureAndPostProcesses(): void;
  117987. /**
  117988. * Implementation specific of rendering the generating effect on the main canvas.
  117989. * @param effect The effect used to render through
  117990. */
  117991. protected abstract _internalRender(effect: Effect): void;
  117992. /**
  117993. * Sets the required values for both the emissive texture and and the main color.
  117994. */
  117995. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117996. /**
  117997. * Free any resources and references associated to a mesh.
  117998. * Internal use
  117999. * @param mesh The mesh to free.
  118000. */
  118001. abstract _disposeMesh(mesh: Mesh): void;
  118002. /**
  118003. * Serializes this layer (Glow or Highlight for example)
  118004. * @returns a serialized layer object
  118005. */
  118006. abstract serialize?(): any;
  118007. /**
  118008. * Initializes the effect layer with the required options.
  118009. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118010. */
  118011. protected _init(options: Partial<IEffectLayerOptions>): void;
  118012. /**
  118013. * Generates the index buffer of the full screen quad blending to the main canvas.
  118014. */
  118015. private _generateIndexBuffer;
  118016. /**
  118017. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118018. */
  118019. private _generateVertexBuffer;
  118020. /**
  118021. * Sets the main texture desired size which is the closest power of two
  118022. * of the engine canvas size.
  118023. */
  118024. private _setMainTextureSize;
  118025. /**
  118026. * Creates the main texture for the effect layer.
  118027. */
  118028. protected _createMainTexture(): void;
  118029. /**
  118030. * Adds specific effects defines.
  118031. * @param defines The defines to add specifics to.
  118032. */
  118033. protected _addCustomEffectDefines(defines: string[]): void;
  118034. /**
  118035. * Checks for the readiness of the element composing the layer.
  118036. * @param subMesh the mesh to check for
  118037. * @param useInstances specify wether or not to use instances to render the mesh
  118038. * @param emissiveTexture the associated emissive texture used to generate the glow
  118039. * @return true if ready otherwise, false
  118040. */
  118041. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118042. /**
  118043. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118044. */
  118045. render(): void;
  118046. /**
  118047. * Determine if a given mesh will be used in the current effect.
  118048. * @param mesh mesh to test
  118049. * @returns true if the mesh will be used
  118050. */
  118051. hasMesh(mesh: AbstractMesh): boolean;
  118052. /**
  118053. * Returns true if the layer contains information to display, otherwise false.
  118054. * @returns true if the glow layer should be rendered
  118055. */
  118056. shouldRender(): boolean;
  118057. /**
  118058. * Returns true if the mesh should render, otherwise false.
  118059. * @param mesh The mesh to render
  118060. * @returns true if it should render otherwise false
  118061. */
  118062. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118063. /**
  118064. * Returns true if the mesh can be rendered, otherwise false.
  118065. * @param mesh The mesh to render
  118066. * @param material The material used on the mesh
  118067. * @returns true if it can be rendered otherwise false
  118068. */
  118069. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118070. /**
  118071. * Returns true if the mesh should render, otherwise false.
  118072. * @param mesh The mesh to render
  118073. * @returns true if it should render otherwise false
  118074. */
  118075. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118076. /**
  118077. * Renders the submesh passed in parameter to the generation map.
  118078. */
  118079. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118080. /**
  118081. * Defines wether the current material of the mesh should be use to render the effect.
  118082. * @param mesh defines the current mesh to render
  118083. */
  118084. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118085. /**
  118086. * Rebuild the required buffers.
  118087. * @hidden Internal use only.
  118088. */
  118089. _rebuild(): void;
  118090. /**
  118091. * Dispose only the render target textures and post process.
  118092. */
  118093. private _disposeTextureAndPostProcesses;
  118094. /**
  118095. * Dispose the highlight layer and free resources.
  118096. */
  118097. dispose(): void;
  118098. /**
  118099. * Gets the class name of the effect layer
  118100. * @returns the string with the class name of the effect layer
  118101. */
  118102. getClassName(): string;
  118103. /**
  118104. * Creates an effect layer from parsed effect layer data
  118105. * @param parsedEffectLayer defines effect layer data
  118106. * @param scene defines the current scene
  118107. * @param rootUrl defines the root URL containing the effect layer information
  118108. * @returns a parsed effect Layer
  118109. */
  118110. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118111. }
  118112. }
  118113. declare module BABYLON {
  118114. interface AbstractScene {
  118115. /**
  118116. * The list of effect layers (highlights/glow) added to the scene
  118117. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118118. * @see http://doc.babylonjs.com/how_to/glow_layer
  118119. */
  118120. effectLayers: Array<EffectLayer>;
  118121. /**
  118122. * Removes the given effect layer from this scene.
  118123. * @param toRemove defines the effect layer to remove
  118124. * @returns the index of the removed effect layer
  118125. */
  118126. removeEffectLayer(toRemove: EffectLayer): number;
  118127. /**
  118128. * Adds the given effect layer to this scene
  118129. * @param newEffectLayer defines the effect layer to add
  118130. */
  118131. addEffectLayer(newEffectLayer: EffectLayer): void;
  118132. }
  118133. /**
  118134. * Defines the layer scene component responsible to manage any effect layers
  118135. * in a given scene.
  118136. */
  118137. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118138. /**
  118139. * The component name helpfull to identify the component in the list of scene components.
  118140. */
  118141. readonly name: string;
  118142. /**
  118143. * The scene the component belongs to.
  118144. */
  118145. scene: Scene;
  118146. private _engine;
  118147. private _renderEffects;
  118148. private _needStencil;
  118149. private _previousStencilState;
  118150. /**
  118151. * Creates a new instance of the component for the given scene
  118152. * @param scene Defines the scene to register the component in
  118153. */
  118154. constructor(scene: Scene);
  118155. /**
  118156. * Registers the component in a given scene
  118157. */
  118158. register(): void;
  118159. /**
  118160. * Rebuilds the elements related to this component in case of
  118161. * context lost for instance.
  118162. */
  118163. rebuild(): void;
  118164. /**
  118165. * Serializes the component data to the specified json object
  118166. * @param serializationObject The object to serialize to
  118167. */
  118168. serialize(serializationObject: any): void;
  118169. /**
  118170. * Adds all the elements from the container to the scene
  118171. * @param container the container holding the elements
  118172. */
  118173. addFromContainer(container: AbstractScene): void;
  118174. /**
  118175. * Removes all the elements in the container from the scene
  118176. * @param container contains the elements to remove
  118177. * @param dispose if the removed element should be disposed (default: false)
  118178. */
  118179. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118180. /**
  118181. * Disposes the component and the associated ressources.
  118182. */
  118183. dispose(): void;
  118184. private _isReadyForMesh;
  118185. private _renderMainTexture;
  118186. private _setStencil;
  118187. private _setStencilBack;
  118188. private _draw;
  118189. private _drawCamera;
  118190. private _drawRenderingGroup;
  118191. }
  118192. }
  118193. declare module BABYLON {
  118194. /** @hidden */
  118195. export var glowMapMergePixelShader: {
  118196. name: string;
  118197. shader: string;
  118198. };
  118199. }
  118200. declare module BABYLON {
  118201. /** @hidden */
  118202. export var glowMapMergeVertexShader: {
  118203. name: string;
  118204. shader: string;
  118205. };
  118206. }
  118207. declare module BABYLON {
  118208. interface AbstractScene {
  118209. /**
  118210. * Return a the first highlight layer of the scene with a given name.
  118211. * @param name The name of the highlight layer to look for.
  118212. * @return The highlight layer if found otherwise null.
  118213. */
  118214. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118215. }
  118216. /**
  118217. * Glow layer options. This helps customizing the behaviour
  118218. * of the glow layer.
  118219. */
  118220. export interface IGlowLayerOptions {
  118221. /**
  118222. * Multiplication factor apply to the canvas size to compute the render target size
  118223. * used to generated the glowing objects (the smaller the faster).
  118224. */
  118225. mainTextureRatio: number;
  118226. /**
  118227. * Enforces a fixed size texture to ensure resize independant blur.
  118228. */
  118229. mainTextureFixedSize?: number;
  118230. /**
  118231. * How big is the kernel of the blur texture.
  118232. */
  118233. blurKernelSize: number;
  118234. /**
  118235. * The camera attached to the layer.
  118236. */
  118237. camera: Nullable<Camera>;
  118238. /**
  118239. * Enable MSAA by chosing the number of samples.
  118240. */
  118241. mainTextureSamples?: number;
  118242. /**
  118243. * The rendering group to draw the layer in.
  118244. */
  118245. renderingGroupId: number;
  118246. }
  118247. /**
  118248. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118249. *
  118250. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118251. *
  118252. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118253. */
  118254. export class GlowLayer extends EffectLayer {
  118255. /**
  118256. * Effect Name of the layer.
  118257. */
  118258. static readonly EffectName: string;
  118259. /**
  118260. * The default blur kernel size used for the glow.
  118261. */
  118262. static DefaultBlurKernelSize: number;
  118263. /**
  118264. * The default texture size ratio used for the glow.
  118265. */
  118266. static DefaultTextureRatio: number;
  118267. /**
  118268. * Sets the kernel size of the blur.
  118269. */
  118270. /**
  118271. * Gets the kernel size of the blur.
  118272. */
  118273. blurKernelSize: number;
  118274. /**
  118275. * Sets the glow intensity.
  118276. */
  118277. /**
  118278. * Gets the glow intensity.
  118279. */
  118280. intensity: number;
  118281. private _options;
  118282. private _intensity;
  118283. private _horizontalBlurPostprocess1;
  118284. private _verticalBlurPostprocess1;
  118285. private _horizontalBlurPostprocess2;
  118286. private _verticalBlurPostprocess2;
  118287. private _blurTexture1;
  118288. private _blurTexture2;
  118289. private _postProcesses1;
  118290. private _postProcesses2;
  118291. private _includedOnlyMeshes;
  118292. private _excludedMeshes;
  118293. private _meshesUsingTheirOwnMaterials;
  118294. /**
  118295. * Callback used to let the user override the color selection on a per mesh basis
  118296. */
  118297. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118298. /**
  118299. * Callback used to let the user override the texture selection on a per mesh basis
  118300. */
  118301. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118302. /**
  118303. * Instantiates a new glow Layer and references it to the scene.
  118304. * @param name The name of the layer
  118305. * @param scene The scene to use the layer in
  118306. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118307. */
  118308. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118309. /**
  118310. * Get the effect name of the layer.
  118311. * @return The effect name
  118312. */
  118313. getEffectName(): string;
  118314. /**
  118315. * Create the merge effect. This is the shader use to blit the information back
  118316. * to the main canvas at the end of the scene rendering.
  118317. */
  118318. protected _createMergeEffect(): Effect;
  118319. /**
  118320. * Creates the render target textures and post processes used in the glow layer.
  118321. */
  118322. protected _createTextureAndPostProcesses(): void;
  118323. /**
  118324. * Checks for the readiness of the element composing the layer.
  118325. * @param subMesh the mesh to check for
  118326. * @param useInstances specify wether or not to use instances to render the mesh
  118327. * @param emissiveTexture the associated emissive texture used to generate the glow
  118328. * @return true if ready otherwise, false
  118329. */
  118330. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118331. /**
  118332. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118333. */
  118334. needStencil(): boolean;
  118335. /**
  118336. * Returns true if the mesh can be rendered, otherwise false.
  118337. * @param mesh The mesh to render
  118338. * @param material The material used on the mesh
  118339. * @returns true if it can be rendered otherwise false
  118340. */
  118341. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118342. /**
  118343. * Implementation specific of rendering the generating effect on the main canvas.
  118344. * @param effect The effect used to render through
  118345. */
  118346. protected _internalRender(effect: Effect): void;
  118347. /**
  118348. * Sets the required values for both the emissive texture and and the main color.
  118349. */
  118350. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118351. /**
  118352. * Returns true if the mesh should render, otherwise false.
  118353. * @param mesh The mesh to render
  118354. * @returns true if it should render otherwise false
  118355. */
  118356. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118357. /**
  118358. * Adds specific effects defines.
  118359. * @param defines The defines to add specifics to.
  118360. */
  118361. protected _addCustomEffectDefines(defines: string[]): void;
  118362. /**
  118363. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118364. * @param mesh The mesh to exclude from the glow layer
  118365. */
  118366. addExcludedMesh(mesh: Mesh): void;
  118367. /**
  118368. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118369. * @param mesh The mesh to remove
  118370. */
  118371. removeExcludedMesh(mesh: Mesh): void;
  118372. /**
  118373. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118374. * @param mesh The mesh to include in the glow layer
  118375. */
  118376. addIncludedOnlyMesh(mesh: Mesh): void;
  118377. /**
  118378. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118379. * @param mesh The mesh to remove
  118380. */
  118381. removeIncludedOnlyMesh(mesh: Mesh): void;
  118382. /**
  118383. * Determine if a given mesh will be used in the glow layer
  118384. * @param mesh The mesh to test
  118385. * @returns true if the mesh will be highlighted by the current glow layer
  118386. */
  118387. hasMesh(mesh: AbstractMesh): boolean;
  118388. /**
  118389. * Defines wether the current material of the mesh should be use to render the effect.
  118390. * @param mesh defines the current mesh to render
  118391. */
  118392. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118393. /**
  118394. * Add a mesh to be rendered through its own material and not with emissive only.
  118395. * @param mesh The mesh for which we need to use its material
  118396. */
  118397. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118398. /**
  118399. * Remove a mesh from being rendered through its own material and not with emissive only.
  118400. * @param mesh The mesh for which we need to not use its material
  118401. */
  118402. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118403. /**
  118404. * Free any resources and references associated to a mesh.
  118405. * Internal use
  118406. * @param mesh The mesh to free.
  118407. * @hidden
  118408. */
  118409. _disposeMesh(mesh: Mesh): void;
  118410. /**
  118411. * Gets the class name of the effect layer
  118412. * @returns the string with the class name of the effect layer
  118413. */
  118414. getClassName(): string;
  118415. /**
  118416. * Serializes this glow layer
  118417. * @returns a serialized glow layer object
  118418. */
  118419. serialize(): any;
  118420. /**
  118421. * Creates a Glow Layer from parsed glow layer data
  118422. * @param parsedGlowLayer defines glow layer data
  118423. * @param scene defines the current scene
  118424. * @param rootUrl defines the root URL containing the glow layer information
  118425. * @returns a parsed Glow Layer
  118426. */
  118427. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118428. }
  118429. }
  118430. declare module BABYLON {
  118431. /** @hidden */
  118432. export var glowBlurPostProcessPixelShader: {
  118433. name: string;
  118434. shader: string;
  118435. };
  118436. }
  118437. declare module BABYLON {
  118438. interface AbstractScene {
  118439. /**
  118440. * Return a the first highlight layer of the scene with a given name.
  118441. * @param name The name of the highlight layer to look for.
  118442. * @return The highlight layer if found otherwise null.
  118443. */
  118444. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118445. }
  118446. /**
  118447. * Highlight layer options. This helps customizing the behaviour
  118448. * of the highlight layer.
  118449. */
  118450. export interface IHighlightLayerOptions {
  118451. /**
  118452. * Multiplication factor apply to the canvas size to compute the render target size
  118453. * used to generated the glowing objects (the smaller the faster).
  118454. */
  118455. mainTextureRatio: number;
  118456. /**
  118457. * Enforces a fixed size texture to ensure resize independant blur.
  118458. */
  118459. mainTextureFixedSize?: number;
  118460. /**
  118461. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118462. * of the picture to blur (the smaller the faster).
  118463. */
  118464. blurTextureSizeRatio: number;
  118465. /**
  118466. * How big in texel of the blur texture is the vertical blur.
  118467. */
  118468. blurVerticalSize: number;
  118469. /**
  118470. * How big in texel of the blur texture is the horizontal blur.
  118471. */
  118472. blurHorizontalSize: number;
  118473. /**
  118474. * Alpha blending mode used to apply the blur. Default is combine.
  118475. */
  118476. alphaBlendingMode: number;
  118477. /**
  118478. * The camera attached to the layer.
  118479. */
  118480. camera: Nullable<Camera>;
  118481. /**
  118482. * Should we display highlight as a solid stroke?
  118483. */
  118484. isStroke?: boolean;
  118485. /**
  118486. * The rendering group to draw the layer in.
  118487. */
  118488. renderingGroupId: number;
  118489. }
  118490. /**
  118491. * The highlight layer Helps adding a glow effect around a mesh.
  118492. *
  118493. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118494. * glowy meshes to your scene.
  118495. *
  118496. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118497. */
  118498. export class HighlightLayer extends EffectLayer {
  118499. name: string;
  118500. /**
  118501. * Effect Name of the highlight layer.
  118502. */
  118503. static readonly EffectName: string;
  118504. /**
  118505. * The neutral color used during the preparation of the glow effect.
  118506. * This is black by default as the blend operation is a blend operation.
  118507. */
  118508. static NeutralColor: Color4;
  118509. /**
  118510. * Stencil value used for glowing meshes.
  118511. */
  118512. static GlowingMeshStencilReference: number;
  118513. /**
  118514. * Stencil value used for the other meshes in the scene.
  118515. */
  118516. static NormalMeshStencilReference: number;
  118517. /**
  118518. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118519. */
  118520. innerGlow: boolean;
  118521. /**
  118522. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118523. */
  118524. outerGlow: boolean;
  118525. /**
  118526. * Specifies the horizontal size of the blur.
  118527. */
  118528. /**
  118529. * Gets the horizontal size of the blur.
  118530. */
  118531. blurHorizontalSize: number;
  118532. /**
  118533. * Specifies the vertical size of the blur.
  118534. */
  118535. /**
  118536. * Gets the vertical size of the blur.
  118537. */
  118538. blurVerticalSize: number;
  118539. /**
  118540. * An event triggered when the highlight layer is being blurred.
  118541. */
  118542. onBeforeBlurObservable: Observable<HighlightLayer>;
  118543. /**
  118544. * An event triggered when the highlight layer has been blurred.
  118545. */
  118546. onAfterBlurObservable: Observable<HighlightLayer>;
  118547. private _instanceGlowingMeshStencilReference;
  118548. private _options;
  118549. private _downSamplePostprocess;
  118550. private _horizontalBlurPostprocess;
  118551. private _verticalBlurPostprocess;
  118552. private _blurTexture;
  118553. private _meshes;
  118554. private _excludedMeshes;
  118555. /**
  118556. * Instantiates a new highlight Layer and references it to the scene..
  118557. * @param name The name of the layer
  118558. * @param scene The scene to use the layer in
  118559. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118560. */
  118561. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118562. /**
  118563. * Get the effect name of the layer.
  118564. * @return The effect name
  118565. */
  118566. getEffectName(): string;
  118567. /**
  118568. * Create the merge effect. This is the shader use to blit the information back
  118569. * to the main canvas at the end of the scene rendering.
  118570. */
  118571. protected _createMergeEffect(): Effect;
  118572. /**
  118573. * Creates the render target textures and post processes used in the highlight layer.
  118574. */
  118575. protected _createTextureAndPostProcesses(): void;
  118576. /**
  118577. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118578. */
  118579. needStencil(): boolean;
  118580. /**
  118581. * Checks for the readiness of the element composing the layer.
  118582. * @param subMesh the mesh to check for
  118583. * @param useInstances specify wether or not to use instances to render the mesh
  118584. * @param emissiveTexture the associated emissive texture used to generate the glow
  118585. * @return true if ready otherwise, false
  118586. */
  118587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118588. /**
  118589. * Implementation specific of rendering the generating effect on the main canvas.
  118590. * @param effect The effect used to render through
  118591. */
  118592. protected _internalRender(effect: Effect): void;
  118593. /**
  118594. * Returns true if the layer contains information to display, otherwise false.
  118595. */
  118596. shouldRender(): boolean;
  118597. /**
  118598. * Returns true if the mesh should render, otherwise false.
  118599. * @param mesh The mesh to render
  118600. * @returns true if it should render otherwise false
  118601. */
  118602. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118603. /**
  118604. * Sets the required values for both the emissive texture and and the main color.
  118605. */
  118606. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118607. /**
  118608. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118609. * @param mesh The mesh to exclude from the highlight layer
  118610. */
  118611. addExcludedMesh(mesh: Mesh): void;
  118612. /**
  118613. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118614. * @param mesh The mesh to highlight
  118615. */
  118616. removeExcludedMesh(mesh: Mesh): void;
  118617. /**
  118618. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118619. * @param mesh mesh to test
  118620. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118621. */
  118622. hasMesh(mesh: AbstractMesh): boolean;
  118623. /**
  118624. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118625. * @param mesh The mesh to highlight
  118626. * @param color The color of the highlight
  118627. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118628. */
  118629. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118630. /**
  118631. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118632. * @param mesh The mesh to highlight
  118633. */
  118634. removeMesh(mesh: Mesh): void;
  118635. /**
  118636. * Force the stencil to the normal expected value for none glowing parts
  118637. */
  118638. private _defaultStencilReference;
  118639. /**
  118640. * Free any resources and references associated to a mesh.
  118641. * Internal use
  118642. * @param mesh The mesh to free.
  118643. * @hidden
  118644. */
  118645. _disposeMesh(mesh: Mesh): void;
  118646. /**
  118647. * Dispose the highlight layer and free resources.
  118648. */
  118649. dispose(): void;
  118650. /**
  118651. * Gets the class name of the effect layer
  118652. * @returns the string with the class name of the effect layer
  118653. */
  118654. getClassName(): string;
  118655. /**
  118656. * Serializes this Highlight layer
  118657. * @returns a serialized Highlight layer object
  118658. */
  118659. serialize(): any;
  118660. /**
  118661. * Creates a Highlight layer from parsed Highlight layer data
  118662. * @param parsedHightlightLayer defines the Highlight layer data
  118663. * @param scene defines the current scene
  118664. * @param rootUrl defines the root URL containing the Highlight layer information
  118665. * @returns a parsed Highlight layer
  118666. */
  118667. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118668. }
  118669. }
  118670. declare module BABYLON {
  118671. interface AbstractScene {
  118672. /**
  118673. * The list of layers (background and foreground) of the scene
  118674. */
  118675. layers: Array<Layer>;
  118676. }
  118677. /**
  118678. * Defines the layer scene component responsible to manage any layers
  118679. * in a given scene.
  118680. */
  118681. export class LayerSceneComponent implements ISceneComponent {
  118682. /**
  118683. * The component name helpfull to identify the component in the list of scene components.
  118684. */
  118685. readonly name: string;
  118686. /**
  118687. * The scene the component belongs to.
  118688. */
  118689. scene: Scene;
  118690. private _engine;
  118691. /**
  118692. * Creates a new instance of the component for the given scene
  118693. * @param scene Defines the scene to register the component in
  118694. */
  118695. constructor(scene: Scene);
  118696. /**
  118697. * Registers the component in a given scene
  118698. */
  118699. register(): void;
  118700. /**
  118701. * Rebuilds the elements related to this component in case of
  118702. * context lost for instance.
  118703. */
  118704. rebuild(): void;
  118705. /**
  118706. * Disposes the component and the associated ressources.
  118707. */
  118708. dispose(): void;
  118709. private _draw;
  118710. private _drawCameraPredicate;
  118711. private _drawCameraBackground;
  118712. private _drawCameraForeground;
  118713. private _drawRenderTargetPredicate;
  118714. private _drawRenderTargetBackground;
  118715. private _drawRenderTargetForeground;
  118716. /**
  118717. * Adds all the elements from the container to the scene
  118718. * @param container the container holding the elements
  118719. */
  118720. addFromContainer(container: AbstractScene): void;
  118721. /**
  118722. * Removes all the elements in the container from the scene
  118723. * @param container contains the elements to remove
  118724. * @param dispose if the removed element should be disposed (default: false)
  118725. */
  118726. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118727. }
  118728. }
  118729. declare module BABYLON {
  118730. /** @hidden */
  118731. export var layerPixelShader: {
  118732. name: string;
  118733. shader: string;
  118734. };
  118735. }
  118736. declare module BABYLON {
  118737. /** @hidden */
  118738. export var layerVertexShader: {
  118739. name: string;
  118740. shader: string;
  118741. };
  118742. }
  118743. declare module BABYLON {
  118744. /**
  118745. * This represents a full screen 2d layer.
  118746. * This can be useful to display a picture in the background of your scene for instance.
  118747. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118748. */
  118749. export class Layer {
  118750. /**
  118751. * Define the name of the layer.
  118752. */
  118753. name: string;
  118754. /**
  118755. * Define the texture the layer should display.
  118756. */
  118757. texture: Nullable<Texture>;
  118758. /**
  118759. * Is the layer in background or foreground.
  118760. */
  118761. isBackground: boolean;
  118762. /**
  118763. * Define the color of the layer (instead of texture).
  118764. */
  118765. color: Color4;
  118766. /**
  118767. * Define the scale of the layer in order to zoom in out of the texture.
  118768. */
  118769. scale: Vector2;
  118770. /**
  118771. * Define an offset for the layer in order to shift the texture.
  118772. */
  118773. offset: Vector2;
  118774. /**
  118775. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118776. */
  118777. alphaBlendingMode: number;
  118778. /**
  118779. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118780. * Alpha test will not mix with the background color in case of transparency.
  118781. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118782. */
  118783. alphaTest: boolean;
  118784. /**
  118785. * Define a mask to restrict the layer to only some of the scene cameras.
  118786. */
  118787. layerMask: number;
  118788. /**
  118789. * Define the list of render target the layer is visible into.
  118790. */
  118791. renderTargetTextures: RenderTargetTexture[];
  118792. /**
  118793. * Define if the layer is only used in renderTarget or if it also
  118794. * renders in the main frame buffer of the canvas.
  118795. */
  118796. renderOnlyInRenderTargetTextures: boolean;
  118797. private _scene;
  118798. private _vertexBuffers;
  118799. private _indexBuffer;
  118800. private _effect;
  118801. private _alphaTestEffect;
  118802. /**
  118803. * An event triggered when the layer is disposed.
  118804. */
  118805. onDisposeObservable: Observable<Layer>;
  118806. private _onDisposeObserver;
  118807. /**
  118808. * Back compatibility with callback before the onDisposeObservable existed.
  118809. * The set callback will be triggered when the layer has been disposed.
  118810. */
  118811. onDispose: () => void;
  118812. /**
  118813. * An event triggered before rendering the scene
  118814. */
  118815. onBeforeRenderObservable: Observable<Layer>;
  118816. private _onBeforeRenderObserver;
  118817. /**
  118818. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118819. * The set callback will be triggered just before rendering the layer.
  118820. */
  118821. onBeforeRender: () => void;
  118822. /**
  118823. * An event triggered after rendering the scene
  118824. */
  118825. onAfterRenderObservable: Observable<Layer>;
  118826. private _onAfterRenderObserver;
  118827. /**
  118828. * Back compatibility with callback before the onAfterRenderObservable existed.
  118829. * The set callback will be triggered just after rendering the layer.
  118830. */
  118831. onAfterRender: () => void;
  118832. /**
  118833. * Instantiates a new layer.
  118834. * This represents a full screen 2d layer.
  118835. * This can be useful to display a picture in the background of your scene for instance.
  118836. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118837. * @param name Define the name of the layer in the scene
  118838. * @param imgUrl Define the url of the texture to display in the layer
  118839. * @param scene Define the scene the layer belongs to
  118840. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118841. * @param color Defines a color for the layer
  118842. */
  118843. constructor(
  118844. /**
  118845. * Define the name of the layer.
  118846. */
  118847. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118848. private _createIndexBuffer;
  118849. /** @hidden */
  118850. _rebuild(): void;
  118851. /**
  118852. * Renders the layer in the scene.
  118853. */
  118854. render(): void;
  118855. /**
  118856. * Disposes and releases the associated ressources.
  118857. */
  118858. dispose(): void;
  118859. }
  118860. }
  118861. declare module BABYLON {
  118862. /** @hidden */
  118863. export var lensFlarePixelShader: {
  118864. name: string;
  118865. shader: string;
  118866. };
  118867. }
  118868. declare module BABYLON {
  118869. /** @hidden */
  118870. export var lensFlareVertexShader: {
  118871. name: string;
  118872. shader: string;
  118873. };
  118874. }
  118875. declare module BABYLON {
  118876. /**
  118877. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118878. * It is usually composed of several `lensFlare`.
  118879. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118880. */
  118881. export class LensFlareSystem {
  118882. /**
  118883. * Define the name of the lens flare system
  118884. */
  118885. name: string;
  118886. /**
  118887. * List of lens flares used in this system.
  118888. */
  118889. lensFlares: LensFlare[];
  118890. /**
  118891. * Define a limit from the border the lens flare can be visible.
  118892. */
  118893. borderLimit: number;
  118894. /**
  118895. * Define a viewport border we do not want to see the lens flare in.
  118896. */
  118897. viewportBorder: number;
  118898. /**
  118899. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118900. */
  118901. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118902. /**
  118903. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118904. */
  118905. layerMask: number;
  118906. /**
  118907. * Define the id of the lens flare system in the scene.
  118908. * (equal to name by default)
  118909. */
  118910. id: string;
  118911. private _scene;
  118912. private _emitter;
  118913. private _vertexBuffers;
  118914. private _indexBuffer;
  118915. private _effect;
  118916. private _positionX;
  118917. private _positionY;
  118918. private _isEnabled;
  118919. /** @hidden */
  118920. static _SceneComponentInitialization: (scene: Scene) => void;
  118921. /**
  118922. * Instantiates a lens flare system.
  118923. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118924. * It is usually composed of several `lensFlare`.
  118925. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118926. * @param name Define the name of the lens flare system in the scene
  118927. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118928. * @param scene Define the scene the lens flare system belongs to
  118929. */
  118930. constructor(
  118931. /**
  118932. * Define the name of the lens flare system
  118933. */
  118934. name: string, emitter: any, scene: Scene);
  118935. /**
  118936. * Define if the lens flare system is enabled.
  118937. */
  118938. isEnabled: boolean;
  118939. /**
  118940. * Get the scene the effects belongs to.
  118941. * @returns the scene holding the lens flare system
  118942. */
  118943. getScene(): Scene;
  118944. /**
  118945. * Get the emitter of the lens flare system.
  118946. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118947. * @returns the emitter of the lens flare system
  118948. */
  118949. getEmitter(): any;
  118950. /**
  118951. * Set the emitter of the lens flare system.
  118952. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118953. * @param newEmitter Define the new emitter of the system
  118954. */
  118955. setEmitter(newEmitter: any): void;
  118956. /**
  118957. * Get the lens flare system emitter position.
  118958. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118959. * @returns the position
  118960. */
  118961. getEmitterPosition(): Vector3;
  118962. /**
  118963. * @hidden
  118964. */
  118965. computeEffectivePosition(globalViewport: Viewport): boolean;
  118966. /** @hidden */
  118967. _isVisible(): boolean;
  118968. /**
  118969. * @hidden
  118970. */
  118971. render(): boolean;
  118972. /**
  118973. * Dispose and release the lens flare with its associated resources.
  118974. */
  118975. dispose(): void;
  118976. /**
  118977. * Parse a lens flare system from a JSON repressentation
  118978. * @param parsedLensFlareSystem Define the JSON to parse
  118979. * @param scene Define the scene the parsed system should be instantiated in
  118980. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118981. * @returns the parsed system
  118982. */
  118983. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118984. /**
  118985. * Serialize the current Lens Flare System into a JSON representation.
  118986. * @returns the serialized JSON
  118987. */
  118988. serialize(): any;
  118989. }
  118990. }
  118991. declare module BABYLON {
  118992. /**
  118993. * This represents one of the lens effect in a `lensFlareSystem`.
  118994. * It controls one of the indiviual texture used in the effect.
  118995. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118996. */
  118997. export class LensFlare {
  118998. /**
  118999. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119000. */
  119001. size: number;
  119002. /**
  119003. * 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.
  119004. */
  119005. position: number;
  119006. /**
  119007. * Define the lens color.
  119008. */
  119009. color: Color3;
  119010. /**
  119011. * Define the lens texture.
  119012. */
  119013. texture: Nullable<Texture>;
  119014. /**
  119015. * Define the alpha mode to render this particular lens.
  119016. */
  119017. alphaMode: number;
  119018. private _system;
  119019. /**
  119020. * Creates a new Lens Flare.
  119021. * This represents one of the lens effect in a `lensFlareSystem`.
  119022. * It controls one of the indiviual texture used in the effect.
  119023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119024. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119025. * @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.
  119026. * @param color Define the lens color
  119027. * @param imgUrl Define the lens texture url
  119028. * @param system Define the `lensFlareSystem` this flare is part of
  119029. * @returns The newly created Lens Flare
  119030. */
  119031. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119032. /**
  119033. * Instantiates a new Lens Flare.
  119034. * This represents one of the lens effect in a `lensFlareSystem`.
  119035. * It controls one of the indiviual texture used in the effect.
  119036. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119037. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119038. * @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.
  119039. * @param color Define the lens color
  119040. * @param imgUrl Define the lens texture url
  119041. * @param system Define the `lensFlareSystem` this flare is part of
  119042. */
  119043. constructor(
  119044. /**
  119045. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119046. */
  119047. size: number,
  119048. /**
  119049. * 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.
  119050. */
  119051. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119052. /**
  119053. * Dispose and release the lens flare with its associated resources.
  119054. */
  119055. dispose(): void;
  119056. }
  119057. }
  119058. declare module BABYLON {
  119059. interface AbstractScene {
  119060. /**
  119061. * The list of lens flare system added to the scene
  119062. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119063. */
  119064. lensFlareSystems: Array<LensFlareSystem>;
  119065. /**
  119066. * Removes the given lens flare system from this scene.
  119067. * @param toRemove The lens flare system to remove
  119068. * @returns The index of the removed lens flare system
  119069. */
  119070. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119071. /**
  119072. * Adds the given lens flare system to this scene
  119073. * @param newLensFlareSystem The lens flare system to add
  119074. */
  119075. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119076. /**
  119077. * Gets a lens flare system using its name
  119078. * @param name defines the name to look for
  119079. * @returns the lens flare system or null if not found
  119080. */
  119081. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119082. /**
  119083. * Gets a lens flare system using its id
  119084. * @param id defines the id to look for
  119085. * @returns the lens flare system or null if not found
  119086. */
  119087. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119088. }
  119089. /**
  119090. * Defines the lens flare scene component responsible to manage any lens flares
  119091. * in a given scene.
  119092. */
  119093. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119094. /**
  119095. * The component name helpfull to identify the component in the list of scene components.
  119096. */
  119097. readonly name: string;
  119098. /**
  119099. * The scene the component belongs to.
  119100. */
  119101. scene: Scene;
  119102. /**
  119103. * Creates a new instance of the component for the given scene
  119104. * @param scene Defines the scene to register the component in
  119105. */
  119106. constructor(scene: Scene);
  119107. /**
  119108. * Registers the component in a given scene
  119109. */
  119110. register(): void;
  119111. /**
  119112. * Rebuilds the elements related to this component in case of
  119113. * context lost for instance.
  119114. */
  119115. rebuild(): void;
  119116. /**
  119117. * Adds all the elements from the container to the scene
  119118. * @param container the container holding the elements
  119119. */
  119120. addFromContainer(container: AbstractScene): void;
  119121. /**
  119122. * Removes all the elements in the container from the scene
  119123. * @param container contains the elements to remove
  119124. * @param dispose if the removed element should be disposed (default: false)
  119125. */
  119126. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119127. /**
  119128. * Serializes the component data to the specified json object
  119129. * @param serializationObject The object to serialize to
  119130. */
  119131. serialize(serializationObject: any): void;
  119132. /**
  119133. * Disposes the component and the associated ressources.
  119134. */
  119135. dispose(): void;
  119136. private _draw;
  119137. }
  119138. }
  119139. declare module BABYLON {
  119140. /**
  119141. * Defines the shadow generator component responsible to manage any shadow generators
  119142. * in a given scene.
  119143. */
  119144. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119145. /**
  119146. * The component name helpfull to identify the component in the list of scene components.
  119147. */
  119148. readonly name: string;
  119149. /**
  119150. * The scene the component belongs to.
  119151. */
  119152. scene: Scene;
  119153. /**
  119154. * Creates a new instance of the component for the given scene
  119155. * @param scene Defines the scene to register the component in
  119156. */
  119157. constructor(scene: Scene);
  119158. /**
  119159. * Registers the component in a given scene
  119160. */
  119161. register(): void;
  119162. /**
  119163. * Rebuilds the elements related to this component in case of
  119164. * context lost for instance.
  119165. */
  119166. rebuild(): void;
  119167. /**
  119168. * Serializes the component data to the specified json object
  119169. * @param serializationObject The object to serialize to
  119170. */
  119171. serialize(serializationObject: any): void;
  119172. /**
  119173. * Adds all the elements from the container to the scene
  119174. * @param container the container holding the elements
  119175. */
  119176. addFromContainer(container: AbstractScene): void;
  119177. /**
  119178. * Removes all the elements in the container from the scene
  119179. * @param container contains the elements to remove
  119180. * @param dispose if the removed element should be disposed (default: false)
  119181. */
  119182. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119183. /**
  119184. * Rebuilds the elements related to this component in case of
  119185. * context lost for instance.
  119186. */
  119187. dispose(): void;
  119188. private _gatherRenderTargets;
  119189. }
  119190. }
  119191. declare module BABYLON {
  119192. /**
  119193. * A point light is a light defined by an unique point in world space.
  119194. * The light is emitted in every direction from this point.
  119195. * A good example of a point light is a standard light bulb.
  119196. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119197. */
  119198. export class PointLight extends ShadowLight {
  119199. private _shadowAngle;
  119200. /**
  119201. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119202. * This specifies what angle the shadow will use to be created.
  119203. *
  119204. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119205. */
  119206. /**
  119207. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119208. * This specifies what angle the shadow will use to be created.
  119209. *
  119210. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119211. */
  119212. shadowAngle: number;
  119213. /**
  119214. * Gets the direction if it has been set.
  119215. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119216. */
  119217. /**
  119218. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119219. */
  119220. direction: Vector3;
  119221. /**
  119222. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119223. * A PointLight emits the light in every direction.
  119224. * It can cast shadows.
  119225. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119226. * ```javascript
  119227. * var pointLight = new PointLight("pl", camera.position, scene);
  119228. * ```
  119229. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119230. * @param name The light friendly name
  119231. * @param position The position of the point light in the scene
  119232. * @param scene The scene the lights belongs to
  119233. */
  119234. constructor(name: string, position: Vector3, scene: Scene);
  119235. /**
  119236. * Returns the string "PointLight"
  119237. * @returns the class name
  119238. */
  119239. getClassName(): string;
  119240. /**
  119241. * Returns the integer 0.
  119242. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119243. */
  119244. getTypeID(): number;
  119245. /**
  119246. * Specifies wether or not the shadowmap should be a cube texture.
  119247. * @returns true if the shadowmap needs to be a cube texture.
  119248. */
  119249. needCube(): boolean;
  119250. /**
  119251. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119252. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119253. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119254. */
  119255. getShadowDirection(faceIndex?: number): Vector3;
  119256. /**
  119257. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119258. * - fov = PI / 2
  119259. * - aspect ratio : 1.0
  119260. * - z-near and far equal to the active camera minZ and maxZ.
  119261. * Returns the PointLight.
  119262. */
  119263. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119264. protected _buildUniformLayout(): void;
  119265. /**
  119266. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119267. * @param effect The effect to update
  119268. * @param lightIndex The index of the light in the effect to update
  119269. * @returns The point light
  119270. */
  119271. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119272. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119273. /**
  119274. * Prepares the list of defines specific to the light type.
  119275. * @param defines the list of defines
  119276. * @param lightIndex defines the index of the light for the effect
  119277. */
  119278. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119279. }
  119280. }
  119281. declare module BABYLON {
  119282. /**
  119283. * Header information of HDR texture files.
  119284. */
  119285. export interface HDRInfo {
  119286. /**
  119287. * The height of the texture in pixels.
  119288. */
  119289. height: number;
  119290. /**
  119291. * The width of the texture in pixels.
  119292. */
  119293. width: number;
  119294. /**
  119295. * The index of the beginning of the data in the binary file.
  119296. */
  119297. dataPosition: number;
  119298. }
  119299. /**
  119300. * This groups tools to convert HDR texture to native colors array.
  119301. */
  119302. export class HDRTools {
  119303. private static Ldexp;
  119304. private static Rgbe2float;
  119305. private static readStringLine;
  119306. /**
  119307. * Reads header information from an RGBE texture stored in a native array.
  119308. * More information on this format are available here:
  119309. * https://en.wikipedia.org/wiki/RGBE_image_format
  119310. *
  119311. * @param uint8array The binary file stored in native array.
  119312. * @return The header information.
  119313. */
  119314. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119315. /**
  119316. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119317. * This RGBE texture needs to store the information as a panorama.
  119318. *
  119319. * More information on this format are available here:
  119320. * https://en.wikipedia.org/wiki/RGBE_image_format
  119321. *
  119322. * @param buffer The binary file stored in an array buffer.
  119323. * @param size The expected size of the extracted cubemap.
  119324. * @return The Cube Map information.
  119325. */
  119326. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119327. /**
  119328. * Returns the pixels data extracted from an RGBE texture.
  119329. * This pixels will be stored left to right up to down in the R G B order in one array.
  119330. *
  119331. * More information on this format are available here:
  119332. * https://en.wikipedia.org/wiki/RGBE_image_format
  119333. *
  119334. * @param uint8array The binary file stored in an array buffer.
  119335. * @param hdrInfo The header information of the file.
  119336. * @return The pixels data in RGB right to left up to down order.
  119337. */
  119338. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119339. private static RGBE_ReadPixels_RLE;
  119340. }
  119341. }
  119342. declare module BABYLON {
  119343. /**
  119344. * This represents a texture coming from an HDR input.
  119345. *
  119346. * The only supported format is currently panorama picture stored in RGBE format.
  119347. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119348. */
  119349. export class HDRCubeTexture extends BaseTexture {
  119350. private static _facesMapping;
  119351. private _generateHarmonics;
  119352. private _noMipmap;
  119353. private _textureMatrix;
  119354. private _size;
  119355. private _onLoad;
  119356. private _onError;
  119357. /**
  119358. * The texture URL.
  119359. */
  119360. url: string;
  119361. /**
  119362. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119363. */
  119364. coordinatesMode: number;
  119365. protected _isBlocking: boolean;
  119366. /**
  119367. * Sets wether or not the texture is blocking during loading.
  119368. */
  119369. /**
  119370. * Gets wether or not the texture is blocking during loading.
  119371. */
  119372. isBlocking: boolean;
  119373. protected _rotationY: number;
  119374. /**
  119375. * Sets texture matrix rotation angle around Y axis in radians.
  119376. */
  119377. /**
  119378. * Gets texture matrix rotation angle around Y axis radians.
  119379. */
  119380. rotationY: number;
  119381. /**
  119382. * Gets or sets the center of the bounding box associated with the cube texture
  119383. * It must define where the camera used to render the texture was set
  119384. */
  119385. boundingBoxPosition: Vector3;
  119386. private _boundingBoxSize;
  119387. /**
  119388. * Gets or sets the size of the bounding box associated with the cube texture
  119389. * When defined, the cubemap will switch to local mode
  119390. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119391. * @example https://www.babylonjs-playground.com/#RNASML
  119392. */
  119393. boundingBoxSize: Vector3;
  119394. /**
  119395. * Instantiates an HDRTexture from the following parameters.
  119396. *
  119397. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119398. * @param scene The scene the texture will be used in
  119399. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119400. * @param noMipmap Forces to not generate the mipmap if true
  119401. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119402. * @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)
  119403. * @param reserved Reserved flag for internal use.
  119404. */
  119405. 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>);
  119406. /**
  119407. * Get the current class name of the texture useful for serialization or dynamic coding.
  119408. * @returns "HDRCubeTexture"
  119409. */
  119410. getClassName(): string;
  119411. /**
  119412. * Occurs when the file is raw .hdr file.
  119413. */
  119414. private loadTexture;
  119415. clone(): HDRCubeTexture;
  119416. delayLoad(): void;
  119417. /**
  119418. * Get the texture reflection matrix used to rotate/transform the reflection.
  119419. * @returns the reflection matrix
  119420. */
  119421. getReflectionTextureMatrix(): Matrix;
  119422. /**
  119423. * Set the texture reflection matrix used to rotate/transform the reflection.
  119424. * @param value Define the reflection matrix to set
  119425. */
  119426. setReflectionTextureMatrix(value: Matrix): void;
  119427. /**
  119428. * Parses a JSON representation of an HDR Texture in order to create the texture
  119429. * @param parsedTexture Define the JSON representation
  119430. * @param scene Define the scene the texture should be created in
  119431. * @param rootUrl Define the root url in case we need to load relative dependencies
  119432. * @returns the newly created texture after parsing
  119433. */
  119434. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119435. serialize(): any;
  119436. }
  119437. }
  119438. declare module BABYLON {
  119439. /**
  119440. * Class used to control physics engine
  119441. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119442. */
  119443. export class PhysicsEngine implements IPhysicsEngine {
  119444. private _physicsPlugin;
  119445. /**
  119446. * Global value used to control the smallest number supported by the simulation
  119447. */
  119448. static Epsilon: number;
  119449. private _impostors;
  119450. private _joints;
  119451. /**
  119452. * Gets the gravity vector used by the simulation
  119453. */
  119454. gravity: Vector3;
  119455. /**
  119456. * Factory used to create the default physics plugin.
  119457. * @returns The default physics plugin
  119458. */
  119459. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119460. /**
  119461. * Creates a new Physics Engine
  119462. * @param gravity defines the gravity vector used by the simulation
  119463. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119464. */
  119465. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119466. /**
  119467. * Sets the gravity vector used by the simulation
  119468. * @param gravity defines the gravity vector to use
  119469. */
  119470. setGravity(gravity: Vector3): void;
  119471. /**
  119472. * Set the time step of the physics engine.
  119473. * Default is 1/60.
  119474. * To slow it down, enter 1/600 for example.
  119475. * To speed it up, 1/30
  119476. * @param newTimeStep defines the new timestep to apply to this world.
  119477. */
  119478. setTimeStep(newTimeStep?: number): void;
  119479. /**
  119480. * Get the time step of the physics engine.
  119481. * @returns the current time step
  119482. */
  119483. getTimeStep(): number;
  119484. /**
  119485. * Release all resources
  119486. */
  119487. dispose(): void;
  119488. /**
  119489. * Gets the name of the current physics plugin
  119490. * @returns the name of the plugin
  119491. */
  119492. getPhysicsPluginName(): string;
  119493. /**
  119494. * Adding a new impostor for the impostor tracking.
  119495. * This will be done by the impostor itself.
  119496. * @param impostor the impostor to add
  119497. */
  119498. addImpostor(impostor: PhysicsImpostor): void;
  119499. /**
  119500. * Remove an impostor from the engine.
  119501. * This impostor and its mesh will not longer be updated by the physics engine.
  119502. * @param impostor the impostor to remove
  119503. */
  119504. removeImpostor(impostor: PhysicsImpostor): void;
  119505. /**
  119506. * Add a joint to the physics engine
  119507. * @param mainImpostor defines the main impostor to which the joint is added.
  119508. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119509. * @param joint defines the joint that will connect both impostors.
  119510. */
  119511. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119512. /**
  119513. * Removes a joint from the simulation
  119514. * @param mainImpostor defines the impostor used with the joint
  119515. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119516. * @param joint defines the joint to remove
  119517. */
  119518. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119519. /**
  119520. * Called by the scene. No need to call it.
  119521. * @param delta defines the timespam between frames
  119522. */
  119523. _step(delta: number): void;
  119524. /**
  119525. * Gets the current plugin used to run the simulation
  119526. * @returns current plugin
  119527. */
  119528. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119529. /**
  119530. * Gets the list of physic impostors
  119531. * @returns an array of PhysicsImpostor
  119532. */
  119533. getImpostors(): Array<PhysicsImpostor>;
  119534. /**
  119535. * Gets the impostor for a physics enabled object
  119536. * @param object defines the object impersonated by the impostor
  119537. * @returns the PhysicsImpostor or null if not found
  119538. */
  119539. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119540. /**
  119541. * Gets the impostor for a physics body object
  119542. * @param body defines physics body used by the impostor
  119543. * @returns the PhysicsImpostor or null if not found
  119544. */
  119545. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119546. /**
  119547. * Does a raycast in the physics world
  119548. * @param from when should the ray start?
  119549. * @param to when should the ray end?
  119550. * @returns PhysicsRaycastResult
  119551. */
  119552. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119553. }
  119554. }
  119555. declare module BABYLON {
  119556. /** @hidden */
  119557. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119558. private _useDeltaForWorldStep;
  119559. world: any;
  119560. name: string;
  119561. private _physicsMaterials;
  119562. private _fixedTimeStep;
  119563. private _cannonRaycastResult;
  119564. private _raycastResult;
  119565. private _physicsBodysToRemoveAfterStep;
  119566. BJSCANNON: any;
  119567. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119568. setGravity(gravity: Vector3): void;
  119569. setTimeStep(timeStep: number): void;
  119570. getTimeStep(): number;
  119571. executeStep(delta: number): void;
  119572. private _removeMarkedPhysicsBodiesFromWorld;
  119573. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119574. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119575. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119576. private _processChildMeshes;
  119577. removePhysicsBody(impostor: PhysicsImpostor): void;
  119578. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119579. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119580. private _addMaterial;
  119581. private _checkWithEpsilon;
  119582. private _createShape;
  119583. private _createHeightmap;
  119584. private _minus90X;
  119585. private _plus90X;
  119586. private _tmpPosition;
  119587. private _tmpDeltaPosition;
  119588. private _tmpUnityRotation;
  119589. private _updatePhysicsBodyTransformation;
  119590. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119591. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119592. isSupported(): boolean;
  119593. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119594. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119595. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119596. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119597. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119598. getBodyMass(impostor: PhysicsImpostor): number;
  119599. getBodyFriction(impostor: PhysicsImpostor): number;
  119600. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119601. getBodyRestitution(impostor: PhysicsImpostor): number;
  119602. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119603. sleepBody(impostor: PhysicsImpostor): void;
  119604. wakeUpBody(impostor: PhysicsImpostor): void;
  119605. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119606. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119607. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119609. getRadius(impostor: PhysicsImpostor): number;
  119610. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119611. dispose(): void;
  119612. private _extendNamespace;
  119613. /**
  119614. * Does a raycast in the physics world
  119615. * @param from when should the ray start?
  119616. * @param to when should the ray end?
  119617. * @returns PhysicsRaycastResult
  119618. */
  119619. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119620. }
  119621. }
  119622. declare module BABYLON {
  119623. /** @hidden */
  119624. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119625. world: any;
  119626. name: string;
  119627. BJSOIMO: any;
  119628. private _raycastResult;
  119629. constructor(iterations?: number, oimoInjection?: any);
  119630. setGravity(gravity: Vector3): void;
  119631. setTimeStep(timeStep: number): void;
  119632. getTimeStep(): number;
  119633. private _tmpImpostorsArray;
  119634. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119635. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119636. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119637. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119638. private _tmpPositionVector;
  119639. removePhysicsBody(impostor: PhysicsImpostor): void;
  119640. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119641. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119642. isSupported(): boolean;
  119643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119650. getBodyMass(impostor: PhysicsImpostor): number;
  119651. getBodyFriction(impostor: PhysicsImpostor): number;
  119652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119653. getBodyRestitution(impostor: PhysicsImpostor): number;
  119654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119655. sleepBody(impostor: PhysicsImpostor): void;
  119656. wakeUpBody(impostor: PhysicsImpostor): void;
  119657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119658. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119659. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119661. getRadius(impostor: PhysicsImpostor): number;
  119662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119663. dispose(): void;
  119664. /**
  119665. * Does a raycast in the physics world
  119666. * @param from when should the ray start?
  119667. * @param to when should the ray end?
  119668. * @returns PhysicsRaycastResult
  119669. */
  119670. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119671. }
  119672. }
  119673. declare module BABYLON {
  119674. /**
  119675. * Class containing static functions to help procedurally build meshes
  119676. */
  119677. export class RibbonBuilder {
  119678. /**
  119679. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119680. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119681. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119682. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119683. * * 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
  119684. * * 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
  119685. * * 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
  119686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119688. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119689. * * 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
  119690. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119691. * * 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
  119692. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119694. * @param name defines the name of the mesh
  119695. * @param options defines the options used to create the mesh
  119696. * @param scene defines the hosting scene
  119697. * @returns the ribbon mesh
  119698. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119699. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119700. */
  119701. static CreateRibbon(name: string, options: {
  119702. pathArray: Vector3[][];
  119703. closeArray?: boolean;
  119704. closePath?: boolean;
  119705. offset?: number;
  119706. updatable?: boolean;
  119707. sideOrientation?: number;
  119708. frontUVs?: Vector4;
  119709. backUVs?: Vector4;
  119710. instance?: Mesh;
  119711. invertUV?: boolean;
  119712. uvs?: Vector2[];
  119713. colors?: Color4[];
  119714. }, scene?: Nullable<Scene>): Mesh;
  119715. }
  119716. }
  119717. declare module BABYLON {
  119718. /**
  119719. * Class containing static functions to help procedurally build meshes
  119720. */
  119721. export class ShapeBuilder {
  119722. /**
  119723. * 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.
  119724. * * 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.
  119725. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119726. * * 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.
  119727. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119728. * * 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
  119729. * * 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
  119730. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119733. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119735. * @param name defines the name of the mesh
  119736. * @param options defines the options used to create the mesh
  119737. * @param scene defines the hosting scene
  119738. * @returns the extruded shape mesh
  119739. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119741. */
  119742. static ExtrudeShape(name: string, options: {
  119743. shape: Vector3[];
  119744. path: Vector3[];
  119745. scale?: number;
  119746. rotation?: number;
  119747. cap?: number;
  119748. updatable?: boolean;
  119749. sideOrientation?: number;
  119750. frontUVs?: Vector4;
  119751. backUVs?: Vector4;
  119752. instance?: Mesh;
  119753. invertUV?: boolean;
  119754. }, scene?: Nullable<Scene>): Mesh;
  119755. /**
  119756. * Creates an custom extruded shape mesh.
  119757. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119758. * * 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.
  119759. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119760. * * 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
  119761. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119762. * * 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
  119763. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119764. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119765. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119766. * * 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
  119767. * * 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
  119768. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119771. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119773. * @param name defines the name of the mesh
  119774. * @param options defines the options used to create the mesh
  119775. * @param scene defines the hosting scene
  119776. * @returns the custom extruded shape mesh
  119777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119778. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119780. */
  119781. static ExtrudeShapeCustom(name: string, options: {
  119782. shape: Vector3[];
  119783. path: Vector3[];
  119784. scaleFunction?: any;
  119785. rotationFunction?: any;
  119786. ribbonCloseArray?: boolean;
  119787. ribbonClosePath?: boolean;
  119788. cap?: number;
  119789. updatable?: boolean;
  119790. sideOrientation?: number;
  119791. frontUVs?: Vector4;
  119792. backUVs?: Vector4;
  119793. instance?: Mesh;
  119794. invertUV?: boolean;
  119795. }, scene?: Nullable<Scene>): Mesh;
  119796. private static _ExtrudeShapeGeneric;
  119797. }
  119798. }
  119799. declare module BABYLON {
  119800. /**
  119801. * AmmoJS Physics plugin
  119802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119803. * @see https://github.com/kripken/ammo.js/
  119804. */
  119805. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119806. private _useDeltaForWorldStep;
  119807. /**
  119808. * Reference to the Ammo library
  119809. */
  119810. bjsAMMO: any;
  119811. /**
  119812. * Created ammoJS world which physics bodies are added to
  119813. */
  119814. world: any;
  119815. /**
  119816. * Name of the plugin
  119817. */
  119818. name: string;
  119819. private _timeStep;
  119820. private _fixedTimeStep;
  119821. private _maxSteps;
  119822. private _tmpQuaternion;
  119823. private _tmpAmmoTransform;
  119824. private _tmpAmmoQuaternion;
  119825. private _tmpAmmoConcreteContactResultCallback;
  119826. private _collisionConfiguration;
  119827. private _dispatcher;
  119828. private _overlappingPairCache;
  119829. private _solver;
  119830. private _softBodySolver;
  119831. private _tmpAmmoVectorA;
  119832. private _tmpAmmoVectorB;
  119833. private _tmpAmmoVectorC;
  119834. private _tmpAmmoVectorD;
  119835. private _tmpContactCallbackResult;
  119836. private _tmpAmmoVectorRCA;
  119837. private _tmpAmmoVectorRCB;
  119838. private _raycastResult;
  119839. private static readonly DISABLE_COLLISION_FLAG;
  119840. private static readonly KINEMATIC_FLAG;
  119841. private static readonly DISABLE_DEACTIVATION_FLAG;
  119842. /**
  119843. * Initializes the ammoJS plugin
  119844. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119845. * @param ammoInjection can be used to inject your own ammo reference
  119846. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119847. */
  119848. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119849. /**
  119850. * Sets the gravity of the physics world (m/(s^2))
  119851. * @param gravity Gravity to set
  119852. */
  119853. setGravity(gravity: Vector3): void;
  119854. /**
  119855. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119856. * @param timeStep timestep to use in seconds
  119857. */
  119858. setTimeStep(timeStep: number): void;
  119859. /**
  119860. * 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)
  119861. * @param fixedTimeStep fixedTimeStep to use in seconds
  119862. */
  119863. setFixedTimeStep(fixedTimeStep: number): void;
  119864. /**
  119865. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119866. * @param maxSteps the maximum number of steps by the physics engine per frame
  119867. */
  119868. setMaxSteps(maxSteps: number): void;
  119869. /**
  119870. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119871. * @returns the current timestep in seconds
  119872. */
  119873. getTimeStep(): number;
  119874. private _isImpostorInContact;
  119875. private _isImpostorPairInContact;
  119876. private _stepSimulation;
  119877. /**
  119878. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119879. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119880. * After the step the babylon meshes are set to the position of the physics imposters
  119881. * @param delta amount of time to step forward
  119882. * @param impostors array of imposters to update before/after the step
  119883. */
  119884. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119885. /**
  119886. * Update babylon mesh to match physics world object
  119887. * @param impostor imposter to match
  119888. */
  119889. private _afterSoftStep;
  119890. /**
  119891. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119892. * @param impostor imposter to match
  119893. */
  119894. private _ropeStep;
  119895. /**
  119896. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119897. * @param impostor imposter to match
  119898. */
  119899. private _softbodyOrClothStep;
  119900. private _tmpVector;
  119901. private _tmpMatrix;
  119902. /**
  119903. * Applies an impulse on the imposter
  119904. * @param impostor imposter to apply impulse to
  119905. * @param force amount of force to be applied to the imposter
  119906. * @param contactPoint the location to apply the impulse on the imposter
  119907. */
  119908. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119909. /**
  119910. * Applies a force on the imposter
  119911. * @param impostor imposter to apply force
  119912. * @param force amount of force to be applied to the imposter
  119913. * @param contactPoint the location to apply the force on the imposter
  119914. */
  119915. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119916. /**
  119917. * Creates a physics body using the plugin
  119918. * @param impostor the imposter to create the physics body on
  119919. */
  119920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119921. /**
  119922. * Removes the physics body from the imposter and disposes of the body's memory
  119923. * @param impostor imposter to remove the physics body from
  119924. */
  119925. removePhysicsBody(impostor: PhysicsImpostor): void;
  119926. /**
  119927. * Generates a joint
  119928. * @param impostorJoint the imposter joint to create the joint with
  119929. */
  119930. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119931. /**
  119932. * Removes a joint
  119933. * @param impostorJoint the imposter joint to remove the joint from
  119934. */
  119935. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119936. private _addMeshVerts;
  119937. /**
  119938. * Initialise the soft body vertices to match its object's (mesh) vertices
  119939. * Softbody vertices (nodes) are in world space and to match this
  119940. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119941. * @param impostor to create the softbody for
  119942. */
  119943. private _softVertexData;
  119944. /**
  119945. * Create an impostor's soft body
  119946. * @param impostor to create the softbody for
  119947. */
  119948. private _createSoftbody;
  119949. /**
  119950. * Create cloth for an impostor
  119951. * @param impostor to create the softbody for
  119952. */
  119953. private _createCloth;
  119954. /**
  119955. * Create rope for an impostor
  119956. * @param impostor to create the softbody for
  119957. */
  119958. private _createRope;
  119959. private _addHullVerts;
  119960. private _createShape;
  119961. /**
  119962. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119963. * @param impostor imposter containing the physics body and babylon object
  119964. */
  119965. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119966. /**
  119967. * Sets the babylon object's position/rotation from the physics body's position/rotation
  119968. * @param impostor imposter containing the physics body and babylon object
  119969. * @param newPosition new position
  119970. * @param newRotation new rotation
  119971. */
  119972. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119973. /**
  119974. * If this plugin is supported
  119975. * @returns true if its supported
  119976. */
  119977. isSupported(): boolean;
  119978. /**
  119979. * Sets the linear velocity of the physics body
  119980. * @param impostor imposter to set the velocity on
  119981. * @param velocity velocity to set
  119982. */
  119983. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119984. /**
  119985. * Sets the angular velocity of the physics body
  119986. * @param impostor imposter to set the velocity on
  119987. * @param velocity velocity to set
  119988. */
  119989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119990. /**
  119991. * gets the linear velocity
  119992. * @param impostor imposter to get linear velocity from
  119993. * @returns linear velocity
  119994. */
  119995. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119996. /**
  119997. * gets the angular velocity
  119998. * @param impostor imposter to get angular velocity from
  119999. * @returns angular velocity
  120000. */
  120001. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120002. /**
  120003. * Sets the mass of physics body
  120004. * @param impostor imposter to set the mass on
  120005. * @param mass mass to set
  120006. */
  120007. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120008. /**
  120009. * Gets the mass of the physics body
  120010. * @param impostor imposter to get the mass from
  120011. * @returns mass
  120012. */
  120013. getBodyMass(impostor: PhysicsImpostor): number;
  120014. /**
  120015. * Gets friction of the impostor
  120016. * @param impostor impostor to get friction from
  120017. * @returns friction value
  120018. */
  120019. getBodyFriction(impostor: PhysicsImpostor): number;
  120020. /**
  120021. * Sets friction of the impostor
  120022. * @param impostor impostor to set friction on
  120023. * @param friction friction value
  120024. */
  120025. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120026. /**
  120027. * Gets restitution of the impostor
  120028. * @param impostor impostor to get restitution from
  120029. * @returns restitution value
  120030. */
  120031. getBodyRestitution(impostor: PhysicsImpostor): number;
  120032. /**
  120033. * Sets resitution of the impostor
  120034. * @param impostor impostor to set resitution on
  120035. * @param restitution resitution value
  120036. */
  120037. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120038. /**
  120039. * Gets pressure inside the impostor
  120040. * @param impostor impostor to get pressure from
  120041. * @returns pressure value
  120042. */
  120043. getBodyPressure(impostor: PhysicsImpostor): number;
  120044. /**
  120045. * Sets pressure inside a soft body impostor
  120046. * Cloth and rope must remain 0 pressure
  120047. * @param impostor impostor to set pressure on
  120048. * @param pressure pressure value
  120049. */
  120050. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120051. /**
  120052. * Gets stiffness of the impostor
  120053. * @param impostor impostor to get stiffness from
  120054. * @returns pressure value
  120055. */
  120056. getBodyStiffness(impostor: PhysicsImpostor): number;
  120057. /**
  120058. * Sets stiffness of the impostor
  120059. * @param impostor impostor to set stiffness on
  120060. * @param stiffness stiffness value from 0 to 1
  120061. */
  120062. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120063. /**
  120064. * Gets velocityIterations of the impostor
  120065. * @param impostor impostor to get velocity iterations from
  120066. * @returns velocityIterations value
  120067. */
  120068. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120069. /**
  120070. * Sets velocityIterations of the impostor
  120071. * @param impostor impostor to set velocity iterations on
  120072. * @param velocityIterations velocityIterations value
  120073. */
  120074. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120075. /**
  120076. * Gets positionIterations of the impostor
  120077. * @param impostor impostor to get position iterations from
  120078. * @returns positionIterations value
  120079. */
  120080. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120081. /**
  120082. * Sets positionIterations of the impostor
  120083. * @param impostor impostor to set position on
  120084. * @param positionIterations positionIterations value
  120085. */
  120086. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120087. /**
  120088. * Append an anchor to a cloth object
  120089. * @param impostor is the cloth impostor to add anchor to
  120090. * @param otherImpostor is the rigid impostor to anchor to
  120091. * @param width ratio across width from 0 to 1
  120092. * @param height ratio up height from 0 to 1
  120093. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120094. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120095. */
  120096. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120097. /**
  120098. * Append an hook to a rope object
  120099. * @param impostor is the rope impostor to add hook to
  120100. * @param otherImpostor is the rigid impostor to hook to
  120101. * @param length ratio along the rope from 0 to 1
  120102. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120103. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120104. */
  120105. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120106. /**
  120107. * Sleeps the physics body and stops it from being active
  120108. * @param impostor impostor to sleep
  120109. */
  120110. sleepBody(impostor: PhysicsImpostor): void;
  120111. /**
  120112. * Activates the physics body
  120113. * @param impostor impostor to activate
  120114. */
  120115. wakeUpBody(impostor: PhysicsImpostor): void;
  120116. /**
  120117. * Updates the distance parameters of the joint
  120118. * @param joint joint to update
  120119. * @param maxDistance maximum distance of the joint
  120120. * @param minDistance minimum distance of the joint
  120121. */
  120122. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120123. /**
  120124. * Sets a motor on the joint
  120125. * @param joint joint to set motor on
  120126. * @param speed speed of the motor
  120127. * @param maxForce maximum force of the motor
  120128. * @param motorIndex index of the motor
  120129. */
  120130. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120131. /**
  120132. * Sets the motors limit
  120133. * @param joint joint to set limit on
  120134. * @param upperLimit upper limit
  120135. * @param lowerLimit lower limit
  120136. */
  120137. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120138. /**
  120139. * Syncs the position and rotation of a mesh with the impostor
  120140. * @param mesh mesh to sync
  120141. * @param impostor impostor to update the mesh with
  120142. */
  120143. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120144. /**
  120145. * Gets the radius of the impostor
  120146. * @param impostor impostor to get radius from
  120147. * @returns the radius
  120148. */
  120149. getRadius(impostor: PhysicsImpostor): number;
  120150. /**
  120151. * Gets the box size of the impostor
  120152. * @param impostor impostor to get box size from
  120153. * @param result the resulting box size
  120154. */
  120155. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120156. /**
  120157. * Disposes of the impostor
  120158. */
  120159. dispose(): void;
  120160. /**
  120161. * Does a raycast in the physics world
  120162. * @param from when should the ray start?
  120163. * @param to when should the ray end?
  120164. * @returns PhysicsRaycastResult
  120165. */
  120166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120167. }
  120168. }
  120169. declare module BABYLON {
  120170. interface AbstractScene {
  120171. /**
  120172. * The list of reflection probes added to the scene
  120173. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120174. */
  120175. reflectionProbes: Array<ReflectionProbe>;
  120176. /**
  120177. * Removes the given reflection probe from this scene.
  120178. * @param toRemove The reflection probe to remove
  120179. * @returns The index of the removed reflection probe
  120180. */
  120181. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120182. /**
  120183. * Adds the given reflection probe to this scene.
  120184. * @param newReflectionProbe The reflection probe to add
  120185. */
  120186. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120187. }
  120188. /**
  120189. * Class used to generate realtime reflection / refraction cube textures
  120190. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120191. */
  120192. export class ReflectionProbe {
  120193. /** defines the name of the probe */
  120194. name: string;
  120195. private _scene;
  120196. private _renderTargetTexture;
  120197. private _projectionMatrix;
  120198. private _viewMatrix;
  120199. private _target;
  120200. private _add;
  120201. private _attachedMesh;
  120202. private _invertYAxis;
  120203. /** Gets or sets probe position (center of the cube map) */
  120204. position: Vector3;
  120205. /**
  120206. * Creates a new reflection probe
  120207. * @param name defines the name of the probe
  120208. * @param size defines the texture resolution (for each face)
  120209. * @param scene defines the hosting scene
  120210. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120211. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120212. */
  120213. constructor(
  120214. /** defines the name of the probe */
  120215. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120216. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120217. samples: number;
  120218. /** Gets or sets the refresh rate to use (on every frame by default) */
  120219. refreshRate: number;
  120220. /**
  120221. * Gets the hosting scene
  120222. * @returns a Scene
  120223. */
  120224. getScene(): Scene;
  120225. /** Gets the internal CubeTexture used to render to */
  120226. readonly cubeTexture: RenderTargetTexture;
  120227. /** Gets the list of meshes to render */
  120228. readonly renderList: Nullable<AbstractMesh[]>;
  120229. /**
  120230. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120231. * @param mesh defines the mesh to attach to
  120232. */
  120233. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120234. /**
  120235. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120236. * @param renderingGroupId The rendering group id corresponding to its index
  120237. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120238. */
  120239. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120240. /**
  120241. * Clean all associated resources
  120242. */
  120243. dispose(): void;
  120244. /**
  120245. * Converts the reflection probe information to a readable string for debug purpose.
  120246. * @param fullDetails Supports for multiple levels of logging within scene loading
  120247. * @returns the human readable reflection probe info
  120248. */
  120249. toString(fullDetails?: boolean): string;
  120250. /**
  120251. * Get the class name of the relfection probe.
  120252. * @returns "ReflectionProbe"
  120253. */
  120254. getClassName(): string;
  120255. /**
  120256. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120257. * @returns The JSON representation of the texture
  120258. */
  120259. serialize(): any;
  120260. /**
  120261. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120262. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120263. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120264. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120265. * @returns The parsed reflection probe if successful
  120266. */
  120267. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120268. }
  120269. }
  120270. declare module BABYLON {
  120271. /** @hidden */
  120272. export var _BabylonLoaderRegistered: boolean;
  120273. /**
  120274. * Helps setting up some configuration for the babylon file loader.
  120275. */
  120276. export class BabylonFileLoaderConfiguration {
  120277. /**
  120278. * The loader does not allow injecting custom physix engine into the plugins.
  120279. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120280. * So you could set this variable to your engine import to make it work.
  120281. */
  120282. static LoaderInjectedPhysicsEngine: any;
  120283. }
  120284. }
  120285. declare module BABYLON {
  120286. /**
  120287. * The Physically based simple base material of BJS.
  120288. *
  120289. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120290. * It is used as the base class for both the specGloss and metalRough conventions.
  120291. */
  120292. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120293. /**
  120294. * Number of Simultaneous lights allowed on the material.
  120295. */
  120296. maxSimultaneousLights: number;
  120297. /**
  120298. * If sets to true, disables all the lights affecting the material.
  120299. */
  120300. disableLighting: boolean;
  120301. /**
  120302. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120303. */
  120304. environmentTexture: BaseTexture;
  120305. /**
  120306. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120307. */
  120308. invertNormalMapX: boolean;
  120309. /**
  120310. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120311. */
  120312. invertNormalMapY: boolean;
  120313. /**
  120314. * Normal map used in the model.
  120315. */
  120316. normalTexture: BaseTexture;
  120317. /**
  120318. * Emissivie color used to self-illuminate the model.
  120319. */
  120320. emissiveColor: Color3;
  120321. /**
  120322. * Emissivie texture used to self-illuminate the model.
  120323. */
  120324. emissiveTexture: BaseTexture;
  120325. /**
  120326. * Occlusion Channel Strenght.
  120327. */
  120328. occlusionStrength: number;
  120329. /**
  120330. * Occlusion Texture of the material (adding extra occlusion effects).
  120331. */
  120332. occlusionTexture: BaseTexture;
  120333. /**
  120334. * Defines the alpha limits in alpha test mode.
  120335. */
  120336. alphaCutOff: number;
  120337. /**
  120338. * Gets the current double sided mode.
  120339. */
  120340. /**
  120341. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120342. */
  120343. doubleSided: boolean;
  120344. /**
  120345. * Stores the pre-calculated light information of a mesh in a texture.
  120346. */
  120347. lightmapTexture: BaseTexture;
  120348. /**
  120349. * If true, the light map contains occlusion information instead of lighting info.
  120350. */
  120351. useLightmapAsShadowmap: boolean;
  120352. /**
  120353. * Instantiates a new PBRMaterial instance.
  120354. *
  120355. * @param name The material name
  120356. * @param scene The scene the material will be use in.
  120357. */
  120358. constructor(name: string, scene: Scene);
  120359. getClassName(): string;
  120360. }
  120361. }
  120362. declare module BABYLON {
  120363. /**
  120364. * The PBR material of BJS following the metal roughness convention.
  120365. *
  120366. * This fits to the PBR convention in the GLTF definition:
  120367. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120368. */
  120369. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120370. /**
  120371. * The base color has two different interpretations depending on the value of metalness.
  120372. * When the material is a metal, the base color is the specific measured reflectance value
  120373. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120374. * of the material.
  120375. */
  120376. baseColor: Color3;
  120377. /**
  120378. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120379. * well as opacity information in the alpha channel.
  120380. */
  120381. baseTexture: BaseTexture;
  120382. /**
  120383. * Specifies the metallic scalar value of the material.
  120384. * Can also be used to scale the metalness values of the metallic texture.
  120385. */
  120386. metallic: number;
  120387. /**
  120388. * Specifies the roughness scalar value of the material.
  120389. * Can also be used to scale the roughness values of the metallic texture.
  120390. */
  120391. roughness: number;
  120392. /**
  120393. * Texture containing both the metallic value in the B channel and the
  120394. * roughness value in the G channel to keep better precision.
  120395. */
  120396. metallicRoughnessTexture: BaseTexture;
  120397. /**
  120398. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120399. *
  120400. * @param name The material name
  120401. * @param scene The scene the material will be use in.
  120402. */
  120403. constructor(name: string, scene: Scene);
  120404. /**
  120405. * Return the currrent class name of the material.
  120406. */
  120407. getClassName(): string;
  120408. /**
  120409. * Makes a duplicate of the current material.
  120410. * @param name - name to use for the new material.
  120411. */
  120412. clone(name: string): PBRMetallicRoughnessMaterial;
  120413. /**
  120414. * Serialize the material to a parsable JSON object.
  120415. */
  120416. serialize(): any;
  120417. /**
  120418. * Parses a JSON object correponding to the serialize function.
  120419. */
  120420. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120421. }
  120422. }
  120423. declare module BABYLON {
  120424. /**
  120425. * The PBR material of BJS following the specular glossiness convention.
  120426. *
  120427. * This fits to the PBR convention in the GLTF definition:
  120428. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120429. */
  120430. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120431. /**
  120432. * Specifies the diffuse color of the material.
  120433. */
  120434. diffuseColor: Color3;
  120435. /**
  120436. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120437. * channel.
  120438. */
  120439. diffuseTexture: BaseTexture;
  120440. /**
  120441. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120442. */
  120443. specularColor: Color3;
  120444. /**
  120445. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120446. */
  120447. glossiness: number;
  120448. /**
  120449. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120450. */
  120451. specularGlossinessTexture: BaseTexture;
  120452. /**
  120453. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120454. *
  120455. * @param name The material name
  120456. * @param scene The scene the material will be use in.
  120457. */
  120458. constructor(name: string, scene: Scene);
  120459. /**
  120460. * Return the currrent class name of the material.
  120461. */
  120462. getClassName(): string;
  120463. /**
  120464. * Makes a duplicate of the current material.
  120465. * @param name - name to use for the new material.
  120466. */
  120467. clone(name: string): PBRSpecularGlossinessMaterial;
  120468. /**
  120469. * Serialize the material to a parsable JSON object.
  120470. */
  120471. serialize(): any;
  120472. /**
  120473. * Parses a JSON object correponding to the serialize function.
  120474. */
  120475. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120481. * It can help converting any input color in a desired output one. This can then be used to create effects
  120482. * from sepia, black and white to sixties or futuristic rendering...
  120483. *
  120484. * The only supported format is currently 3dl.
  120485. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120486. */
  120487. export class ColorGradingTexture extends BaseTexture {
  120488. /**
  120489. * The current texture matrix. (will always be identity in color grading texture)
  120490. */
  120491. private _textureMatrix;
  120492. /**
  120493. * The texture URL.
  120494. */
  120495. url: string;
  120496. /**
  120497. * Empty line regex stored for GC.
  120498. */
  120499. private static _noneEmptyLineRegex;
  120500. private _engine;
  120501. /**
  120502. * Instantiates a ColorGradingTexture from the following parameters.
  120503. *
  120504. * @param url The location of the color gradind data (currently only supporting 3dl)
  120505. * @param scene The scene the texture will be used in
  120506. */
  120507. constructor(url: string, scene: Scene);
  120508. /**
  120509. * Returns the texture matrix used in most of the material.
  120510. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120511. */
  120512. getTextureMatrix(): Matrix;
  120513. /**
  120514. * Occurs when the file being loaded is a .3dl LUT file.
  120515. */
  120516. private load3dlTexture;
  120517. /**
  120518. * Starts the loading process of the texture.
  120519. */
  120520. private loadTexture;
  120521. /**
  120522. * Clones the color gradind texture.
  120523. */
  120524. clone(): ColorGradingTexture;
  120525. /**
  120526. * Called during delayed load for textures.
  120527. */
  120528. delayLoad(): void;
  120529. /**
  120530. * Parses a color grading texture serialized by Babylon.
  120531. * @param parsedTexture The texture information being parsedTexture
  120532. * @param scene The scene to load the texture in
  120533. * @param rootUrl The root url of the data assets to load
  120534. * @return A color gradind texture
  120535. */
  120536. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120537. /**
  120538. * Serializes the LUT texture to json format.
  120539. */
  120540. serialize(): any;
  120541. }
  120542. }
  120543. declare module BABYLON {
  120544. /**
  120545. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120546. */
  120547. export class EquiRectangularCubeTexture extends BaseTexture {
  120548. /** The six faces of the cube. */
  120549. private static _FacesMapping;
  120550. private _noMipmap;
  120551. private _onLoad;
  120552. private _onError;
  120553. /** The size of the cubemap. */
  120554. private _size;
  120555. /** The buffer of the image. */
  120556. private _buffer;
  120557. /** The width of the input image. */
  120558. private _width;
  120559. /** The height of the input image. */
  120560. private _height;
  120561. /** The URL to the image. */
  120562. url: string;
  120563. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120564. coordinatesMode: number;
  120565. /**
  120566. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120567. * @param url The location of the image
  120568. * @param scene The scene the texture will be used in
  120569. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120570. * @param noMipmap Forces to not generate the mipmap if true
  120571. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120572. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120573. * @param onLoad — defines a callback called when texture is loaded
  120574. * @param onError — defines a callback called if there is an error
  120575. */
  120576. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120577. /**
  120578. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120579. */
  120580. private loadImage;
  120581. /**
  120582. * Convert the image buffer into a cubemap and create a CubeTexture.
  120583. */
  120584. private loadTexture;
  120585. /**
  120586. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120587. * @param buffer The ArrayBuffer that should be converted.
  120588. * @returns The buffer as Float32Array.
  120589. */
  120590. private getFloat32ArrayFromArrayBuffer;
  120591. /**
  120592. * Get the current class name of the texture useful for serialization or dynamic coding.
  120593. * @returns "EquiRectangularCubeTexture"
  120594. */
  120595. getClassName(): string;
  120596. /**
  120597. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120598. * @returns A clone of the current EquiRectangularCubeTexture.
  120599. */
  120600. clone(): EquiRectangularCubeTexture;
  120601. }
  120602. }
  120603. declare module BABYLON {
  120604. /**
  120605. * Based on jsTGALoader - Javascript loader for TGA file
  120606. * By Vincent Thibault
  120607. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120608. */
  120609. export class TGATools {
  120610. private static _TYPE_INDEXED;
  120611. private static _TYPE_RGB;
  120612. private static _TYPE_GREY;
  120613. private static _TYPE_RLE_INDEXED;
  120614. private static _TYPE_RLE_RGB;
  120615. private static _TYPE_RLE_GREY;
  120616. private static _ORIGIN_MASK;
  120617. private static _ORIGIN_SHIFT;
  120618. private static _ORIGIN_BL;
  120619. private static _ORIGIN_BR;
  120620. private static _ORIGIN_UL;
  120621. private static _ORIGIN_UR;
  120622. /**
  120623. * Gets the header of a TGA file
  120624. * @param data defines the TGA data
  120625. * @returns the header
  120626. */
  120627. static GetTGAHeader(data: Uint8Array): any;
  120628. /**
  120629. * Uploads TGA content to a Babylon Texture
  120630. * @hidden
  120631. */
  120632. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120633. /** @hidden */
  120634. 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;
  120635. /** @hidden */
  120636. 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;
  120637. /** @hidden */
  120638. 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;
  120639. /** @hidden */
  120640. 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;
  120641. /** @hidden */
  120642. 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;
  120643. /** @hidden */
  120644. 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;
  120645. }
  120646. }
  120647. declare module BABYLON {
  120648. /**
  120649. * Implementation of the TGA Texture Loader.
  120650. * @hidden
  120651. */
  120652. export class _TGATextureLoader implements IInternalTextureLoader {
  120653. /**
  120654. * Defines wether the loader supports cascade loading the different faces.
  120655. */
  120656. readonly supportCascades: boolean;
  120657. /**
  120658. * This returns if the loader support the current file information.
  120659. * @param extension defines the file extension of the file being loaded
  120660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120661. * @param fallback defines the fallback internal texture if any
  120662. * @param isBase64 defines whether the texture is encoded as a base64
  120663. * @param isBuffer defines whether the texture data are stored as a buffer
  120664. * @returns true if the loader can load the specified file
  120665. */
  120666. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120667. /**
  120668. * Transform the url before loading if required.
  120669. * @param rootUrl the url of the texture
  120670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120671. * @returns the transformed texture
  120672. */
  120673. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120674. /**
  120675. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120676. * @param rootUrl the url of the texture
  120677. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120678. * @returns the fallback texture
  120679. */
  120680. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120681. /**
  120682. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120683. * @param data contains the texture data
  120684. * @param texture defines the BabylonJS internal texture
  120685. * @param createPolynomials will be true if polynomials have been requested
  120686. * @param onLoad defines the callback to trigger once the texture is ready
  120687. * @param onError defines the callback to trigger in case of error
  120688. */
  120689. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120690. /**
  120691. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120692. * @param data contains the texture data
  120693. * @param texture defines the BabylonJS internal texture
  120694. * @param callback defines the method to call once ready to upload
  120695. */
  120696. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120697. }
  120698. }
  120699. declare module BABYLON {
  120700. /**
  120701. * Info about the .basis files
  120702. */
  120703. class BasisFileInfo {
  120704. /**
  120705. * If the file has alpha
  120706. */
  120707. hasAlpha: boolean;
  120708. /**
  120709. * Info about each image of the basis file
  120710. */
  120711. images: Array<{
  120712. levels: Array<{
  120713. width: number;
  120714. height: number;
  120715. transcodedPixels: ArrayBufferView;
  120716. }>;
  120717. }>;
  120718. }
  120719. /**
  120720. * Result of transcoding a basis file
  120721. */
  120722. class TranscodeResult {
  120723. /**
  120724. * Info about the .basis file
  120725. */
  120726. fileInfo: BasisFileInfo;
  120727. /**
  120728. * Format to use when loading the file
  120729. */
  120730. format: number;
  120731. }
  120732. /**
  120733. * Configuration options for the Basis transcoder
  120734. */
  120735. export class BasisTranscodeConfiguration {
  120736. /**
  120737. * Supported compression formats used to determine the supported output format of the transcoder
  120738. */
  120739. supportedCompressionFormats?: {
  120740. /**
  120741. * etc1 compression format
  120742. */
  120743. etc1?: boolean;
  120744. /**
  120745. * s3tc compression format
  120746. */
  120747. s3tc?: boolean;
  120748. /**
  120749. * pvrtc compression format
  120750. */
  120751. pvrtc?: boolean;
  120752. /**
  120753. * etc2 compression format
  120754. */
  120755. etc2?: boolean;
  120756. };
  120757. /**
  120758. * If mipmap levels should be loaded for transcoded images (Default: true)
  120759. */
  120760. loadMipmapLevels?: boolean;
  120761. /**
  120762. * Index of a single image to load (Default: all images)
  120763. */
  120764. loadSingleImage?: number;
  120765. }
  120766. /**
  120767. * Used to load .Basis files
  120768. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120769. */
  120770. export class BasisTools {
  120771. private static _IgnoreSupportedFormats;
  120772. /**
  120773. * URL to use when loading the basis transcoder
  120774. */
  120775. static JSModuleURL: string;
  120776. /**
  120777. * URL to use when loading the wasm module for the transcoder
  120778. */
  120779. static WasmModuleURL: string;
  120780. /**
  120781. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120782. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120783. * @returns internal format corresponding to the Basis format
  120784. */
  120785. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120786. private static _WorkerPromise;
  120787. private static _Worker;
  120788. private static _actionId;
  120789. private static _CreateWorkerAsync;
  120790. /**
  120791. * Transcodes a loaded image file to compressed pixel data
  120792. * @param imageData image data to transcode
  120793. * @param config configuration options for the transcoding
  120794. * @returns a promise resulting in the transcoded image
  120795. */
  120796. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120797. /**
  120798. * Loads a texture from the transcode result
  120799. * @param texture texture load to
  120800. * @param transcodeResult the result of transcoding the basis file to load from
  120801. */
  120802. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120803. }
  120804. }
  120805. declare module BABYLON {
  120806. /**
  120807. * Loader for .basis file format
  120808. */
  120809. export class _BasisTextureLoader implements IInternalTextureLoader {
  120810. /**
  120811. * Defines whether the loader supports cascade loading the different faces.
  120812. */
  120813. readonly supportCascades: boolean;
  120814. /**
  120815. * This returns if the loader support the current file information.
  120816. * @param extension defines the file extension of the file being loaded
  120817. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120818. * @param fallback defines the fallback internal texture if any
  120819. * @param isBase64 defines whether the texture is encoded as a base64
  120820. * @param isBuffer defines whether the texture data are stored as a buffer
  120821. * @returns true if the loader can load the specified file
  120822. */
  120823. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120824. /**
  120825. * Transform the url before loading if required.
  120826. * @param rootUrl the url of the texture
  120827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120828. * @returns the transformed texture
  120829. */
  120830. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120831. /**
  120832. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120833. * @param rootUrl the url of the texture
  120834. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120835. * @returns the fallback texture
  120836. */
  120837. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120838. /**
  120839. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120840. * @param data contains the texture data
  120841. * @param texture defines the BabylonJS internal texture
  120842. * @param createPolynomials will be true if polynomials have been requested
  120843. * @param onLoad defines the callback to trigger once the texture is ready
  120844. * @param onError defines the callback to trigger in case of error
  120845. */
  120846. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120847. /**
  120848. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120849. * @param data contains the texture data
  120850. * @param texture defines the BabylonJS internal texture
  120851. * @param callback defines the method to call once ready to upload
  120852. */
  120853. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. /**
  120858. * 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.
  120859. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120860. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120861. */
  120862. export class CustomProceduralTexture extends ProceduralTexture {
  120863. private _animate;
  120864. private _time;
  120865. private _config;
  120866. private _texturePath;
  120867. /**
  120868. * Instantiates a new Custom Procedural Texture.
  120869. * 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.
  120870. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120871. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120872. * @param name Define the name of the texture
  120873. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120874. * @param size Define the size of the texture to create
  120875. * @param scene Define the scene the texture belongs to
  120876. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120877. * @param generateMipMaps Define if the texture should creates mip maps or not
  120878. */
  120879. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120880. private _loadJson;
  120881. /**
  120882. * Is the texture ready to be used ? (rendered at least once)
  120883. * @returns true if ready, otherwise, false.
  120884. */
  120885. isReady(): boolean;
  120886. /**
  120887. * Render the texture to its associated render target.
  120888. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120889. */
  120890. render(useCameraPostProcess?: boolean): void;
  120891. /**
  120892. * Update the list of dependant textures samplers in the shader.
  120893. */
  120894. updateTextures(): void;
  120895. /**
  120896. * Update the uniform values of the procedural texture in the shader.
  120897. */
  120898. updateShaderUniforms(): void;
  120899. /**
  120900. * Define if the texture animates or not.
  120901. */
  120902. animate: boolean;
  120903. }
  120904. }
  120905. declare module BABYLON {
  120906. /** @hidden */
  120907. export var noisePixelShader: {
  120908. name: string;
  120909. shader: string;
  120910. };
  120911. }
  120912. declare module BABYLON {
  120913. /**
  120914. * Class used to generate noise procedural textures
  120915. */
  120916. export class NoiseProceduralTexture extends ProceduralTexture {
  120917. private _time;
  120918. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120919. brightness: number;
  120920. /** Defines the number of octaves to process */
  120921. octaves: number;
  120922. /** Defines the level of persistence (0.8 by default) */
  120923. persistence: number;
  120924. /** Gets or sets animation speed factor (default is 1) */
  120925. animationSpeedFactor: number;
  120926. /**
  120927. * Creates a new NoiseProceduralTexture
  120928. * @param name defines the name fo the texture
  120929. * @param size defines the size of the texture (default is 256)
  120930. * @param scene defines the hosting scene
  120931. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120932. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120933. */
  120934. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120935. private _updateShaderUniforms;
  120936. protected _getDefines(): string;
  120937. /** Generate the current state of the procedural texture */
  120938. render(useCameraPostProcess?: boolean): void;
  120939. /**
  120940. * Serializes this noise procedural texture
  120941. * @returns a serialized noise procedural texture object
  120942. */
  120943. serialize(): any;
  120944. /**
  120945. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120946. * @param parsedTexture defines parsed texture data
  120947. * @param scene defines the current scene
  120948. * @param rootUrl defines the root URL containing noise procedural texture information
  120949. * @returns a parsed NoiseProceduralTexture
  120950. */
  120951. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  120952. }
  120953. }
  120954. declare module BABYLON {
  120955. /**
  120956. * Raw cube texture where the raw buffers are passed in
  120957. */
  120958. export class RawCubeTexture extends CubeTexture {
  120959. /**
  120960. * Creates a cube texture where the raw buffers are passed in.
  120961. * @param scene defines the scene the texture is attached to
  120962. * @param data defines the array of data to use to create each face
  120963. * @param size defines the size of the textures
  120964. * @param format defines the format of the data
  120965. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  120966. * @param generateMipMaps defines if the engine should generate the mip levels
  120967. * @param invertY defines if data must be stored with Y axis inverted
  120968. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  120969. * @param compression defines the compression used (null by default)
  120970. */
  120971. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  120972. /**
  120973. * Updates the raw cube texture.
  120974. * @param data defines the data to store
  120975. * @param format defines the data format
  120976. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120977. * @param invertY defines if data must be stored with Y axis inverted
  120978. * @param compression defines the compression used (null by default)
  120979. * @param level defines which level of the texture to update
  120980. */
  120981. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  120982. /**
  120983. * Updates a raw cube texture with RGBD encoded data.
  120984. * @param data defines the array of data [mipmap][face] to use to create each face
  120985. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  120986. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120987. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120988. * @returns a promsie that resolves when the operation is complete
  120989. */
  120990. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120991. /**
  120992. * Clones the raw cube texture.
  120993. * @return a new cube texture
  120994. */
  120995. clone(): CubeTexture;
  120996. /** @hidden */
  120997. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120998. }
  120999. }
  121000. declare module BABYLON {
  121001. /**
  121002. * Class used to store 3D textures containing user data
  121003. */
  121004. export class RawTexture3D extends Texture {
  121005. /** Gets or sets the texture format to use */
  121006. format: number;
  121007. private _engine;
  121008. /**
  121009. * Create a new RawTexture3D
  121010. * @param data defines the data of the texture
  121011. * @param width defines the width of the texture
  121012. * @param height defines the height of the texture
  121013. * @param depth defines the depth of the texture
  121014. * @param format defines the texture format to use
  121015. * @param scene defines the hosting scene
  121016. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121017. * @param invertY defines if texture must be stored with Y axis inverted
  121018. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121019. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121020. */
  121021. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121022. /** Gets or sets the texture format to use */
  121023. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121024. /**
  121025. * Update the texture with new data
  121026. * @param data defines the data to store in the texture
  121027. */
  121028. update(data: ArrayBufferView): void;
  121029. }
  121030. }
  121031. declare module BABYLON {
  121032. /**
  121033. * Class used to store 2D array textures containing user data
  121034. */
  121035. export class RawTexture2DArray extends Texture {
  121036. /** Gets or sets the texture format to use */
  121037. format: number;
  121038. private _engine;
  121039. /**
  121040. * Create a new RawTexture2DArray
  121041. * @param data defines the data of the texture
  121042. * @param width defines the width of the texture
  121043. * @param height defines the height of the texture
  121044. * @param depth defines the number of layers of the texture
  121045. * @param format defines the texture format to use
  121046. * @param scene defines the hosting scene
  121047. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121048. * @param invertY defines if texture must be stored with Y axis inverted
  121049. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121050. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121051. */
  121052. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121053. /** Gets or sets the texture format to use */
  121054. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121055. /**
  121056. * Update the texture with new data
  121057. * @param data defines the data to store in the texture
  121058. */
  121059. update(data: ArrayBufferView): void;
  121060. }
  121061. }
  121062. declare module BABYLON {
  121063. /**
  121064. * Creates a refraction texture used by refraction channel of the standard material.
  121065. * It is like a mirror but to see through a material.
  121066. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121067. */
  121068. export class RefractionTexture extends RenderTargetTexture {
  121069. /**
  121070. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121071. * 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.
  121072. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121073. */
  121074. refractionPlane: Plane;
  121075. /**
  121076. * Define how deep under the surface we should see.
  121077. */
  121078. depth: number;
  121079. /**
  121080. * Creates a refraction texture used by refraction channel of the standard material.
  121081. * It is like a mirror but to see through a material.
  121082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121083. * @param name Define the texture name
  121084. * @param size Define the size of the underlying texture
  121085. * @param scene Define the scene the refraction belongs to
  121086. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121087. */
  121088. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121089. /**
  121090. * Clone the refraction texture.
  121091. * @returns the cloned texture
  121092. */
  121093. clone(): RefractionTexture;
  121094. /**
  121095. * Serialize the texture to a JSON representation you could use in Parse later on
  121096. * @returns the serialized JSON representation
  121097. */
  121098. serialize(): any;
  121099. }
  121100. }
  121101. declare module BABYLON {
  121102. /**
  121103. * Defines the options related to the creation of an HtmlElementTexture
  121104. */
  121105. export interface IHtmlElementTextureOptions {
  121106. /**
  121107. * Defines wether mip maps should be created or not.
  121108. */
  121109. generateMipMaps?: boolean;
  121110. /**
  121111. * Defines the sampling mode of the texture.
  121112. */
  121113. samplingMode?: number;
  121114. /**
  121115. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121116. */
  121117. engine: Nullable<ThinEngine>;
  121118. /**
  121119. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121120. */
  121121. scene: Nullable<Scene>;
  121122. }
  121123. /**
  121124. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121125. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121126. * is automatically managed.
  121127. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121128. * in your application.
  121129. *
  121130. * As the update is not automatic, you need to call them manually.
  121131. */
  121132. export class HtmlElementTexture extends BaseTexture {
  121133. /**
  121134. * The texture URL.
  121135. */
  121136. element: HTMLVideoElement | HTMLCanvasElement;
  121137. private static readonly DefaultOptions;
  121138. private _textureMatrix;
  121139. private _engine;
  121140. private _isVideo;
  121141. private _generateMipMaps;
  121142. private _samplingMode;
  121143. /**
  121144. * Instantiates a HtmlElementTexture from the following parameters.
  121145. *
  121146. * @param name Defines the name of the texture
  121147. * @param element Defines the video or canvas the texture is filled with
  121148. * @param options Defines the other none mandatory texture creation options
  121149. */
  121150. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121151. private _createInternalTexture;
  121152. /**
  121153. * Returns the texture matrix used in most of the material.
  121154. */
  121155. getTextureMatrix(): Matrix;
  121156. /**
  121157. * Updates the content of the texture.
  121158. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121159. */
  121160. update(invertY?: Nullable<boolean>): void;
  121161. }
  121162. }
  121163. declare module BABYLON {
  121164. /**
  121165. * Enum used to define the target of a block
  121166. */
  121167. export enum NodeMaterialBlockTargets {
  121168. /** Vertex shader */
  121169. Vertex = 1,
  121170. /** Fragment shader */
  121171. Fragment = 2,
  121172. /** Neutral */
  121173. Neutral = 4,
  121174. /** Vertex and Fragment */
  121175. VertexAndFragment = 3
  121176. }
  121177. }
  121178. declare module BABYLON {
  121179. /**
  121180. * Defines the kind of connection point for node based material
  121181. */
  121182. export enum NodeMaterialBlockConnectionPointTypes {
  121183. /** Float */
  121184. Float = 1,
  121185. /** Int */
  121186. Int = 2,
  121187. /** Vector2 */
  121188. Vector2 = 4,
  121189. /** Vector3 */
  121190. Vector3 = 8,
  121191. /** Vector4 */
  121192. Vector4 = 16,
  121193. /** Color3 */
  121194. Color3 = 32,
  121195. /** Color4 */
  121196. Color4 = 64,
  121197. /** Matrix */
  121198. Matrix = 128,
  121199. /** Detect type based on connection */
  121200. AutoDetect = 1024,
  121201. /** Output type that will be defined by input type */
  121202. BasedOnInput = 2048
  121203. }
  121204. }
  121205. declare module BABYLON {
  121206. /**
  121207. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121208. */
  121209. export enum NodeMaterialBlockConnectionPointMode {
  121210. /** Value is an uniform */
  121211. Uniform = 0,
  121212. /** Value is a mesh attribute */
  121213. Attribute = 1,
  121214. /** Value is a varying between vertex and fragment shaders */
  121215. Varying = 2,
  121216. /** Mode is undefined */
  121217. Undefined = 3
  121218. }
  121219. }
  121220. declare module BABYLON {
  121221. /**
  121222. * Enum used to define system values e.g. values automatically provided by the system
  121223. */
  121224. export enum NodeMaterialSystemValues {
  121225. /** World */
  121226. World = 1,
  121227. /** View */
  121228. View = 2,
  121229. /** Projection */
  121230. Projection = 3,
  121231. /** ViewProjection */
  121232. ViewProjection = 4,
  121233. /** WorldView */
  121234. WorldView = 5,
  121235. /** WorldViewProjection */
  121236. WorldViewProjection = 6,
  121237. /** CameraPosition */
  121238. CameraPosition = 7,
  121239. /** Fog Color */
  121240. FogColor = 8,
  121241. /** Delta time */
  121242. DeltaTime = 9
  121243. }
  121244. }
  121245. declare module BABYLON {
  121246. /**
  121247. * Root class for all node material optimizers
  121248. */
  121249. export class NodeMaterialOptimizer {
  121250. /**
  121251. * Function used to optimize a NodeMaterial graph
  121252. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121253. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121254. */
  121255. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121256. }
  121257. }
  121258. declare module BABYLON {
  121259. /**
  121260. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121261. */
  121262. export class TransformBlock extends NodeMaterialBlock {
  121263. /**
  121264. * Defines the value to use to complement W value to transform it to a Vector4
  121265. */
  121266. complementW: number;
  121267. /**
  121268. * Defines the value to use to complement z value to transform it to a Vector4
  121269. */
  121270. complementZ: number;
  121271. /**
  121272. * Creates a new TransformBlock
  121273. * @param name defines the block name
  121274. */
  121275. constructor(name: string);
  121276. /**
  121277. * Gets the current class name
  121278. * @returns the class name
  121279. */
  121280. getClassName(): string;
  121281. /**
  121282. * Gets the vector input
  121283. */
  121284. readonly vector: NodeMaterialConnectionPoint;
  121285. /**
  121286. * Gets the output component
  121287. */
  121288. readonly output: NodeMaterialConnectionPoint;
  121289. /**
  121290. * Gets the matrix transform input
  121291. */
  121292. readonly transform: NodeMaterialConnectionPoint;
  121293. protected _buildBlock(state: NodeMaterialBuildState): this;
  121294. serialize(): any;
  121295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121296. protected _dumpPropertiesCode(): string;
  121297. }
  121298. }
  121299. declare module BABYLON {
  121300. /**
  121301. * Block used to output the vertex position
  121302. */
  121303. export class VertexOutputBlock extends NodeMaterialBlock {
  121304. /**
  121305. * Creates a new VertexOutputBlock
  121306. * @param name defines the block name
  121307. */
  121308. constructor(name: string);
  121309. /**
  121310. * Gets the current class name
  121311. * @returns the class name
  121312. */
  121313. getClassName(): string;
  121314. /**
  121315. * Gets the vector input component
  121316. */
  121317. readonly vector: NodeMaterialConnectionPoint;
  121318. protected _buildBlock(state: NodeMaterialBuildState): this;
  121319. }
  121320. }
  121321. declare module BABYLON {
  121322. /**
  121323. * Block used to output the final color
  121324. */
  121325. export class FragmentOutputBlock extends NodeMaterialBlock {
  121326. /**
  121327. * Create a new FragmentOutputBlock
  121328. * @param name defines the block name
  121329. */
  121330. constructor(name: string);
  121331. /**
  121332. * Gets the current class name
  121333. * @returns the class name
  121334. */
  121335. getClassName(): string;
  121336. /**
  121337. * Gets the rgba input component
  121338. */
  121339. readonly rgba: NodeMaterialConnectionPoint;
  121340. /**
  121341. * Gets the rgb input component
  121342. */
  121343. readonly rgb: NodeMaterialConnectionPoint;
  121344. /**
  121345. * Gets the a input component
  121346. */
  121347. readonly a: NodeMaterialConnectionPoint;
  121348. protected _buildBlock(state: NodeMaterialBuildState): this;
  121349. }
  121350. }
  121351. declare module BABYLON {
  121352. /**
  121353. * Block used to read a reflection texture from a sampler
  121354. */
  121355. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121356. private _define3DName;
  121357. private _defineCubicName;
  121358. private _defineExplicitName;
  121359. private _defineProjectionName;
  121360. private _defineLocalCubicName;
  121361. private _defineSphericalName;
  121362. private _definePlanarName;
  121363. private _defineEquirectangularName;
  121364. private _defineMirroredEquirectangularFixedName;
  121365. private _defineEquirectangularFixedName;
  121366. private _defineSkyboxName;
  121367. private _cubeSamplerName;
  121368. private _2DSamplerName;
  121369. private _positionUVWName;
  121370. private _directionWName;
  121371. private _reflectionCoordsName;
  121372. private _reflection2DCoordsName;
  121373. private _reflectionColorName;
  121374. private _reflectionMatrixName;
  121375. /**
  121376. * Gets or sets the texture associated with the node
  121377. */
  121378. texture: Nullable<BaseTexture>;
  121379. /**
  121380. * Create a new TextureBlock
  121381. * @param name defines the block name
  121382. */
  121383. constructor(name: string);
  121384. /**
  121385. * Gets the current class name
  121386. * @returns the class name
  121387. */
  121388. getClassName(): string;
  121389. /**
  121390. * Gets the world position input component
  121391. */
  121392. readonly position: NodeMaterialConnectionPoint;
  121393. /**
  121394. * Gets the world position input component
  121395. */
  121396. readonly worldPosition: NodeMaterialConnectionPoint;
  121397. /**
  121398. * Gets the world normal input component
  121399. */
  121400. readonly worldNormal: NodeMaterialConnectionPoint;
  121401. /**
  121402. * Gets the world input component
  121403. */
  121404. readonly world: NodeMaterialConnectionPoint;
  121405. /**
  121406. * Gets the camera (or eye) position component
  121407. */
  121408. readonly cameraPosition: NodeMaterialConnectionPoint;
  121409. /**
  121410. * Gets the view input component
  121411. */
  121412. readonly view: NodeMaterialConnectionPoint;
  121413. /**
  121414. * Gets the rgb output component
  121415. */
  121416. readonly rgb: NodeMaterialConnectionPoint;
  121417. /**
  121418. * Gets the r output component
  121419. */
  121420. readonly r: NodeMaterialConnectionPoint;
  121421. /**
  121422. * Gets the g output component
  121423. */
  121424. readonly g: NodeMaterialConnectionPoint;
  121425. /**
  121426. * Gets the b output component
  121427. */
  121428. readonly b: NodeMaterialConnectionPoint;
  121429. autoConfigure(material: NodeMaterial): void;
  121430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121431. isReady(): boolean;
  121432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121433. private _injectVertexCode;
  121434. private _writeOutput;
  121435. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121436. protected _dumpPropertiesCode(): string;
  121437. serialize(): any;
  121438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121439. }
  121440. }
  121441. declare module BABYLON {
  121442. /**
  121443. * Interface used to configure the node material editor
  121444. */
  121445. export interface INodeMaterialEditorOptions {
  121446. /** Define the URl to load node editor script */
  121447. editorURL?: string;
  121448. }
  121449. /** @hidden */
  121450. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121451. /** BONES */
  121452. NUM_BONE_INFLUENCERS: number;
  121453. BonesPerMesh: number;
  121454. BONETEXTURE: boolean;
  121455. /** MORPH TARGETS */
  121456. MORPHTARGETS: boolean;
  121457. MORPHTARGETS_NORMAL: boolean;
  121458. MORPHTARGETS_TANGENT: boolean;
  121459. MORPHTARGETS_UV: boolean;
  121460. NUM_MORPH_INFLUENCERS: number;
  121461. /** IMAGE PROCESSING */
  121462. IMAGEPROCESSING: boolean;
  121463. VIGNETTE: boolean;
  121464. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121465. VIGNETTEBLENDMODEOPAQUE: boolean;
  121466. TONEMAPPING: boolean;
  121467. TONEMAPPING_ACES: boolean;
  121468. CONTRAST: boolean;
  121469. EXPOSURE: boolean;
  121470. COLORCURVES: boolean;
  121471. COLORGRADING: boolean;
  121472. COLORGRADING3D: boolean;
  121473. SAMPLER3DGREENDEPTH: boolean;
  121474. SAMPLER3DBGRMAP: boolean;
  121475. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121476. /** MISC. */
  121477. BUMPDIRECTUV: number;
  121478. constructor();
  121479. setValue(name: string, value: boolean): void;
  121480. }
  121481. /**
  121482. * Class used to configure NodeMaterial
  121483. */
  121484. export interface INodeMaterialOptions {
  121485. /**
  121486. * Defines if blocks should emit comments
  121487. */
  121488. emitComments: boolean;
  121489. }
  121490. /**
  121491. * Class used to create a node based material built by assembling shader blocks
  121492. */
  121493. export class NodeMaterial extends PushMaterial {
  121494. private static _BuildIdGenerator;
  121495. private _options;
  121496. private _vertexCompilationState;
  121497. private _fragmentCompilationState;
  121498. private _sharedData;
  121499. private _buildId;
  121500. private _buildWasSuccessful;
  121501. private _cachedWorldViewMatrix;
  121502. private _cachedWorldViewProjectionMatrix;
  121503. private _optimizers;
  121504. private _animationFrame;
  121505. /** Define the URl to load node editor script */
  121506. static EditorURL: string;
  121507. private BJSNODEMATERIALEDITOR;
  121508. /** Get the inspector from bundle or global */
  121509. private _getGlobalNodeMaterialEditor;
  121510. /**
  121511. * 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)
  121512. */
  121513. ignoreAlpha: boolean;
  121514. /**
  121515. * Defines the maximum number of lights that can be used in the material
  121516. */
  121517. maxSimultaneousLights: number;
  121518. /**
  121519. * Observable raised when the material is built
  121520. */
  121521. onBuildObservable: Observable<NodeMaterial>;
  121522. /**
  121523. * Gets or sets the root nodes of the material vertex shader
  121524. */
  121525. _vertexOutputNodes: NodeMaterialBlock[];
  121526. /**
  121527. * Gets or sets the root nodes of the material fragment (pixel) shader
  121528. */
  121529. _fragmentOutputNodes: NodeMaterialBlock[];
  121530. /** Gets or sets options to control the node material overall behavior */
  121531. options: INodeMaterialOptions;
  121532. /**
  121533. * Default configuration related to image processing available in the standard Material.
  121534. */
  121535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121536. /**
  121537. * Gets the image processing configuration used either in this material.
  121538. */
  121539. /**
  121540. * Sets the Default image processing configuration used either in the this material.
  121541. *
  121542. * If sets to null, the scene one is in use.
  121543. */
  121544. imageProcessingConfiguration: ImageProcessingConfiguration;
  121545. /**
  121546. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121547. */
  121548. attachedBlocks: NodeMaterialBlock[];
  121549. /**
  121550. * Create a new node based material
  121551. * @param name defines the material name
  121552. * @param scene defines the hosting scene
  121553. * @param options defines creation option
  121554. */
  121555. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121556. /**
  121557. * Gets the current class name of the material e.g. "NodeMaterial"
  121558. * @returns the class name
  121559. */
  121560. getClassName(): string;
  121561. /**
  121562. * Keep track of the image processing observer to allow dispose and replace.
  121563. */
  121564. private _imageProcessingObserver;
  121565. /**
  121566. * Attaches a new image processing configuration to the Standard Material.
  121567. * @param configuration
  121568. */
  121569. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121570. /**
  121571. * Get a block by its name
  121572. * @param name defines the name of the block to retrieve
  121573. * @returns the required block or null if not found
  121574. */
  121575. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121576. /**
  121577. * Get a block by its name
  121578. * @param predicate defines the predicate used to find the good candidate
  121579. * @returns the required block or null if not found
  121580. */
  121581. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121582. /**
  121583. * Get an input block by its name
  121584. * @param predicate defines the predicate used to find the good candidate
  121585. * @returns the required input block or null if not found
  121586. */
  121587. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121588. /**
  121589. * Gets the list of input blocks attached to this material
  121590. * @returns an array of InputBlocks
  121591. */
  121592. getInputBlocks(): InputBlock[];
  121593. /**
  121594. * Adds a new optimizer to the list of optimizers
  121595. * @param optimizer defines the optimizers to add
  121596. * @returns the current material
  121597. */
  121598. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121599. /**
  121600. * Remove an optimizer from the list of optimizers
  121601. * @param optimizer defines the optimizers to remove
  121602. * @returns the current material
  121603. */
  121604. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121605. /**
  121606. * Add a new block to the list of output nodes
  121607. * @param node defines the node to add
  121608. * @returns the current material
  121609. */
  121610. addOutputNode(node: NodeMaterialBlock): this;
  121611. /**
  121612. * Remove a block from the list of root nodes
  121613. * @param node defines the node to remove
  121614. * @returns the current material
  121615. */
  121616. removeOutputNode(node: NodeMaterialBlock): this;
  121617. private _addVertexOutputNode;
  121618. private _removeVertexOutputNode;
  121619. private _addFragmentOutputNode;
  121620. private _removeFragmentOutputNode;
  121621. /**
  121622. * Specifies if the material will require alpha blending
  121623. * @returns a boolean specifying if alpha blending is needed
  121624. */
  121625. needAlphaBlending(): boolean;
  121626. /**
  121627. * Specifies if this material should be rendered in alpha test mode
  121628. * @returns a boolean specifying if an alpha test is needed.
  121629. */
  121630. needAlphaTesting(): boolean;
  121631. private _initializeBlock;
  121632. private _resetDualBlocks;
  121633. /**
  121634. * Build the material and generates the inner effect
  121635. * @param verbose defines if the build should log activity
  121636. */
  121637. build(verbose?: boolean): void;
  121638. /**
  121639. * Runs an otpimization phase to try to improve the shader code
  121640. */
  121641. optimize(): void;
  121642. private _prepareDefinesForAttributes;
  121643. /**
  121644. * Get if the submesh is ready to be used and all its information available.
  121645. * Child classes can use it to update shaders
  121646. * @param mesh defines the mesh to check
  121647. * @param subMesh defines which submesh to check
  121648. * @param useInstances specifies that instances should be used
  121649. * @returns a boolean indicating that the submesh is ready or not
  121650. */
  121651. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121652. /**
  121653. * Get a string representing the shaders built by the current node graph
  121654. */
  121655. readonly compiledShaders: string;
  121656. /**
  121657. * Binds the world matrix to the material
  121658. * @param world defines the world transformation matrix
  121659. */
  121660. bindOnlyWorldMatrix(world: Matrix): void;
  121661. /**
  121662. * Binds the submesh to this material by preparing the effect and shader to draw
  121663. * @param world defines the world transformation matrix
  121664. * @param mesh defines the mesh containing the submesh
  121665. * @param subMesh defines the submesh to bind the material to
  121666. */
  121667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121668. /**
  121669. * Gets the active textures from the material
  121670. * @returns an array of textures
  121671. */
  121672. getActiveTextures(): BaseTexture[];
  121673. /**
  121674. * Gets the list of texture blocks
  121675. * @returns an array of texture blocks
  121676. */
  121677. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121678. /**
  121679. * Specifies if the material uses a texture
  121680. * @param texture defines the texture to check against the material
  121681. * @returns a boolean specifying if the material uses the texture
  121682. */
  121683. hasTexture(texture: BaseTexture): boolean;
  121684. /**
  121685. * Disposes the material
  121686. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121687. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121688. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121689. */
  121690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121691. /** Creates the node editor window. */
  121692. private _createNodeEditor;
  121693. /**
  121694. * Launch the node material editor
  121695. * @param config Define the configuration of the editor
  121696. * @return a promise fulfilled when the node editor is visible
  121697. */
  121698. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121699. /**
  121700. * Clear the current material
  121701. */
  121702. clear(): void;
  121703. /**
  121704. * Clear the current material and set it to a default state
  121705. */
  121706. setToDefault(): void;
  121707. /**
  121708. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121709. * @param url defines the url to load from
  121710. * @returns a promise that will fullfil when the material is fully loaded
  121711. */
  121712. loadAsync(url: string): Promise<void>;
  121713. private _gatherBlocks;
  121714. /**
  121715. * Generate a string containing the code declaration required to create an equivalent of this material
  121716. * @returns a string
  121717. */
  121718. generateCode(): string;
  121719. /**
  121720. * Serializes this material in a JSON representation
  121721. * @returns the serialized material object
  121722. */
  121723. serialize(): any;
  121724. private _restoreConnections;
  121725. /**
  121726. * Clear the current graph and load a new one from a serialization object
  121727. * @param source defines the JSON representation of the material
  121728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121729. */
  121730. loadFromSerialization(source: any, rootUrl?: string): void;
  121731. /**
  121732. * Creates a node material from parsed material data
  121733. * @param source defines the JSON representation of the material
  121734. * @param scene defines the hosting scene
  121735. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121736. * @returns a new node material
  121737. */
  121738. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121739. /**
  121740. * Creates a new node material set to default basic configuration
  121741. * @param name defines the name of the material
  121742. * @param scene defines the hosting scene
  121743. * @returns a new NodeMaterial
  121744. */
  121745. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121746. }
  121747. }
  121748. declare module BABYLON {
  121749. /**
  121750. * Block used to read a texture from a sampler
  121751. */
  121752. export class TextureBlock extends NodeMaterialBlock {
  121753. private _defineName;
  121754. private _linearDefineName;
  121755. private _samplerName;
  121756. private _transformedUVName;
  121757. private _textureTransformName;
  121758. private _textureInfoName;
  121759. private _mainUVName;
  121760. private _mainUVDefineName;
  121761. /**
  121762. * Gets or sets the texture associated with the node
  121763. */
  121764. texture: Nullable<Texture>;
  121765. /**
  121766. * Create a new TextureBlock
  121767. * @param name defines the block name
  121768. */
  121769. constructor(name: string);
  121770. /**
  121771. * Gets the current class name
  121772. * @returns the class name
  121773. */
  121774. getClassName(): string;
  121775. /**
  121776. * Gets the uv input component
  121777. */
  121778. readonly uv: NodeMaterialConnectionPoint;
  121779. /**
  121780. * Gets the rgba output component
  121781. */
  121782. readonly rgba: NodeMaterialConnectionPoint;
  121783. /**
  121784. * Gets the rgb output component
  121785. */
  121786. readonly rgb: NodeMaterialConnectionPoint;
  121787. /**
  121788. * Gets the r output component
  121789. */
  121790. readonly r: NodeMaterialConnectionPoint;
  121791. /**
  121792. * Gets the g output component
  121793. */
  121794. readonly g: NodeMaterialConnectionPoint;
  121795. /**
  121796. * Gets the b output component
  121797. */
  121798. readonly b: NodeMaterialConnectionPoint;
  121799. /**
  121800. * Gets the a output component
  121801. */
  121802. readonly a: NodeMaterialConnectionPoint;
  121803. readonly target: NodeMaterialBlockTargets;
  121804. autoConfigure(material: NodeMaterial): void;
  121805. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121807. isReady(): boolean;
  121808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121809. private readonly _isMixed;
  121810. private _injectVertexCode;
  121811. private _writeOutput;
  121812. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121813. protected _dumpPropertiesCode(): string;
  121814. serialize(): any;
  121815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121816. }
  121817. }
  121818. declare module BABYLON {
  121819. /**
  121820. * Class used to store shared data between 2 NodeMaterialBuildState
  121821. */
  121822. export class NodeMaterialBuildStateSharedData {
  121823. /**
  121824. * Gets the list of emitted varyings
  121825. */
  121826. temps: string[];
  121827. /**
  121828. * Gets the list of emitted varyings
  121829. */
  121830. varyings: string[];
  121831. /**
  121832. * Gets the varying declaration string
  121833. */
  121834. varyingDeclaration: string;
  121835. /**
  121836. * Input blocks
  121837. */
  121838. inputBlocks: InputBlock[];
  121839. /**
  121840. * Input blocks
  121841. */
  121842. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121843. /**
  121844. * Bindable blocks (Blocks that need to set data to the effect)
  121845. */
  121846. bindableBlocks: NodeMaterialBlock[];
  121847. /**
  121848. * List of blocks that can provide a compilation fallback
  121849. */
  121850. blocksWithFallbacks: NodeMaterialBlock[];
  121851. /**
  121852. * List of blocks that can provide a define update
  121853. */
  121854. blocksWithDefines: NodeMaterialBlock[];
  121855. /**
  121856. * List of blocks that can provide a repeatable content
  121857. */
  121858. repeatableContentBlocks: NodeMaterialBlock[];
  121859. /**
  121860. * List of blocks that can provide a dynamic list of uniforms
  121861. */
  121862. dynamicUniformBlocks: NodeMaterialBlock[];
  121863. /**
  121864. * List of blocks that can block the isReady function for the material
  121865. */
  121866. blockingBlocks: NodeMaterialBlock[];
  121867. /**
  121868. * Gets the list of animated inputs
  121869. */
  121870. animatedInputs: InputBlock[];
  121871. /**
  121872. * Build Id used to avoid multiple recompilations
  121873. */
  121874. buildId: number;
  121875. /** List of emitted variables */
  121876. variableNames: {
  121877. [key: string]: number;
  121878. };
  121879. /** List of emitted defines */
  121880. defineNames: {
  121881. [key: string]: number;
  121882. };
  121883. /** Should emit comments? */
  121884. emitComments: boolean;
  121885. /** Emit build activity */
  121886. verbose: boolean;
  121887. /** Gets or sets the hosting scene */
  121888. scene: Scene;
  121889. /**
  121890. * Gets the compilation hints emitted at compilation time
  121891. */
  121892. hints: {
  121893. needWorldViewMatrix: boolean;
  121894. needWorldViewProjectionMatrix: boolean;
  121895. needAlphaBlending: boolean;
  121896. needAlphaTesting: boolean;
  121897. };
  121898. /**
  121899. * List of compilation checks
  121900. */
  121901. checks: {
  121902. emitVertex: boolean;
  121903. emitFragment: boolean;
  121904. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121905. };
  121906. /** Creates a new shared data */
  121907. constructor();
  121908. /**
  121909. * Emits console errors and exceptions if there is a failing check
  121910. */
  121911. emitErrors(): void;
  121912. }
  121913. }
  121914. declare module BABYLON {
  121915. /**
  121916. * Class used to store node based material build state
  121917. */
  121918. export class NodeMaterialBuildState {
  121919. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121920. supportUniformBuffers: boolean;
  121921. /**
  121922. * Gets the list of emitted attributes
  121923. */
  121924. attributes: string[];
  121925. /**
  121926. * Gets the list of emitted uniforms
  121927. */
  121928. uniforms: string[];
  121929. /**
  121930. * Gets the list of emitted constants
  121931. */
  121932. constants: string[];
  121933. /**
  121934. * Gets the list of emitted samplers
  121935. */
  121936. samplers: string[];
  121937. /**
  121938. * Gets the list of emitted functions
  121939. */
  121940. functions: {
  121941. [key: string]: string;
  121942. };
  121943. /**
  121944. * Gets the list of emitted extensions
  121945. */
  121946. extensions: {
  121947. [key: string]: string;
  121948. };
  121949. /**
  121950. * Gets the target of the compilation state
  121951. */
  121952. target: NodeMaterialBlockTargets;
  121953. /**
  121954. * Gets the list of emitted counters
  121955. */
  121956. counters: {
  121957. [key: string]: number;
  121958. };
  121959. /**
  121960. * Shared data between multiple NodeMaterialBuildState instances
  121961. */
  121962. sharedData: NodeMaterialBuildStateSharedData;
  121963. /** @hidden */
  121964. _vertexState: NodeMaterialBuildState;
  121965. /** @hidden */
  121966. _attributeDeclaration: string;
  121967. /** @hidden */
  121968. _uniformDeclaration: string;
  121969. /** @hidden */
  121970. _constantDeclaration: string;
  121971. /** @hidden */
  121972. _samplerDeclaration: string;
  121973. /** @hidden */
  121974. _varyingTransfer: string;
  121975. private _repeatableContentAnchorIndex;
  121976. /** @hidden */
  121977. _builtCompilationString: string;
  121978. /**
  121979. * Gets the emitted compilation strings
  121980. */
  121981. compilationString: string;
  121982. /**
  121983. * Finalize the compilation strings
  121984. * @param state defines the current compilation state
  121985. */
  121986. finalize(state: NodeMaterialBuildState): void;
  121987. /** @hidden */
  121988. readonly _repeatableContentAnchor: string;
  121989. /** @hidden */
  121990. _getFreeVariableName(prefix: string): string;
  121991. /** @hidden */
  121992. _getFreeDefineName(prefix: string): string;
  121993. /** @hidden */
  121994. _excludeVariableName(name: string): void;
  121995. /** @hidden */
  121996. _emit2DSampler(name: string): void;
  121997. /** @hidden */
  121998. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  121999. /** @hidden */
  122000. _emitExtension(name: string, extension: string): void;
  122001. /** @hidden */
  122002. _emitFunction(name: string, code: string, comments: string): void;
  122003. /** @hidden */
  122004. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122005. replaceStrings?: {
  122006. search: RegExp;
  122007. replace: string;
  122008. }[];
  122009. repeatKey?: string;
  122010. }): string;
  122011. /** @hidden */
  122012. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122013. repeatKey?: string;
  122014. removeAttributes?: boolean;
  122015. removeUniforms?: boolean;
  122016. removeVaryings?: boolean;
  122017. removeIfDef?: boolean;
  122018. replaceStrings?: {
  122019. search: RegExp;
  122020. replace: string;
  122021. }[];
  122022. }, storeKey?: string): void;
  122023. /** @hidden */
  122024. _registerTempVariable(name: string): boolean;
  122025. /** @hidden */
  122026. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122027. /** @hidden */
  122028. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122029. /** @hidden */
  122030. _emitFloat(value: number): string;
  122031. }
  122032. }
  122033. declare module BABYLON {
  122034. /**
  122035. * Defines a block that can be used inside a node based material
  122036. */
  122037. export class NodeMaterialBlock {
  122038. private _buildId;
  122039. private _buildTarget;
  122040. private _target;
  122041. private _isFinalMerger;
  122042. private _isInput;
  122043. /** @hidden */
  122044. _codeVariableName: string;
  122045. /** @hidden */
  122046. _inputs: NodeMaterialConnectionPoint[];
  122047. /** @hidden */
  122048. _outputs: NodeMaterialConnectionPoint[];
  122049. /** @hidden */
  122050. _preparationId: number;
  122051. /**
  122052. * Gets or sets the name of the block
  122053. */
  122054. name: string;
  122055. /**
  122056. * Gets or sets the unique id of the node
  122057. */
  122058. uniqueId: number;
  122059. /**
  122060. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122061. */
  122062. readonly isFinalMerger: boolean;
  122063. /**
  122064. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122065. */
  122066. readonly isInput: boolean;
  122067. /**
  122068. * Gets or sets the build Id
  122069. */
  122070. buildId: number;
  122071. /**
  122072. * Gets or sets the target of the block
  122073. */
  122074. target: NodeMaterialBlockTargets;
  122075. /**
  122076. * Gets the list of input points
  122077. */
  122078. readonly inputs: NodeMaterialConnectionPoint[];
  122079. /** Gets the list of output points */
  122080. readonly outputs: NodeMaterialConnectionPoint[];
  122081. /**
  122082. * Find an input by its name
  122083. * @param name defines the name of the input to look for
  122084. * @returns the input or null if not found
  122085. */
  122086. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122087. /**
  122088. * Find an output by its name
  122089. * @param name defines the name of the outputto look for
  122090. * @returns the output or null if not found
  122091. */
  122092. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122093. /**
  122094. * Creates a new NodeMaterialBlock
  122095. * @param name defines the block name
  122096. * @param target defines the target of that block (Vertex by default)
  122097. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122098. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122099. */
  122100. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122101. /**
  122102. * Initialize the block and prepare the context for build
  122103. * @param state defines the state that will be used for the build
  122104. */
  122105. initialize(state: NodeMaterialBuildState): void;
  122106. /**
  122107. * Bind data to effect. Will only be called for blocks with isBindable === true
  122108. * @param effect defines the effect to bind data to
  122109. * @param nodeMaterial defines the hosting NodeMaterial
  122110. * @param mesh defines the mesh that will be rendered
  122111. */
  122112. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122113. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122114. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122115. protected _writeFloat(value: number): string;
  122116. /**
  122117. * Gets the current class name e.g. "NodeMaterialBlock"
  122118. * @returns the class name
  122119. */
  122120. getClassName(): string;
  122121. /**
  122122. * Register a new input. Must be called inside a block constructor
  122123. * @param name defines the connection point name
  122124. * @param type defines the connection point type
  122125. * @param isOptional defines a boolean indicating that this input can be omitted
  122126. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122127. * @returns the current block
  122128. */
  122129. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122130. /**
  122131. * Register a new output. Must be called inside a block constructor
  122132. * @param name defines the connection point name
  122133. * @param type defines the connection point type
  122134. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122135. * @returns the current block
  122136. */
  122137. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122138. /**
  122139. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122140. * @param forOutput defines an optional connection point to check compatibility with
  122141. * @returns the first available input or null
  122142. */
  122143. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122144. /**
  122145. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122146. * @param forBlock defines an optional block to check compatibility with
  122147. * @returns the first available input or null
  122148. */
  122149. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122150. /**
  122151. * Gets the sibling of the given output
  122152. * @param current defines the current output
  122153. * @returns the next output in the list or null
  122154. */
  122155. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122156. /**
  122157. * Connect current block with another block
  122158. * @param other defines the block to connect with
  122159. * @param options define the various options to help pick the right connections
  122160. * @returns the current block
  122161. */
  122162. connectTo(other: NodeMaterialBlock, options?: {
  122163. input?: string;
  122164. output?: string;
  122165. outputSwizzle?: string;
  122166. }): this | undefined;
  122167. protected _buildBlock(state: NodeMaterialBuildState): void;
  122168. /**
  122169. * Add uniforms, samplers and uniform buffers at compilation time
  122170. * @param state defines the state to update
  122171. * @param nodeMaterial defines the node material requesting the update
  122172. * @param defines defines the material defines to update
  122173. * @param uniformBuffers defines the list of uniform buffer names
  122174. */
  122175. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122176. /**
  122177. * Add potential fallbacks if shader compilation fails
  122178. * @param mesh defines the mesh to be rendered
  122179. * @param fallbacks defines the current prioritized list of fallbacks
  122180. */
  122181. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122182. /**
  122183. * Initialize defines for shader compilation
  122184. * @param mesh defines the mesh to be rendered
  122185. * @param nodeMaterial defines the node material requesting the update
  122186. * @param defines defines the material defines to update
  122187. * @param useInstances specifies that instances should be used
  122188. */
  122189. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122190. /**
  122191. * Update defines for shader compilation
  122192. * @param mesh defines the mesh to be rendered
  122193. * @param nodeMaterial defines the node material requesting the update
  122194. * @param defines defines the material defines to update
  122195. * @param useInstances specifies that instances should be used
  122196. */
  122197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122198. /**
  122199. * Lets the block try to connect some inputs automatically
  122200. * @param material defines the hosting NodeMaterial
  122201. */
  122202. autoConfigure(material: NodeMaterial): void;
  122203. /**
  122204. * Function called when a block is declared as repeatable content generator
  122205. * @param vertexShaderState defines the current compilation state for the vertex shader
  122206. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122207. * @param mesh defines the mesh to be rendered
  122208. * @param defines defines the material defines to update
  122209. */
  122210. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122211. /**
  122212. * Checks if the block is ready
  122213. * @param mesh defines the mesh to be rendered
  122214. * @param nodeMaterial defines the node material requesting the update
  122215. * @param defines defines the material defines to update
  122216. * @param useInstances specifies that instances should be used
  122217. * @returns true if the block is ready
  122218. */
  122219. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122220. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122221. private _processBuild;
  122222. /**
  122223. * Compile the current node and generate the shader code
  122224. * @param state defines the current compilation state (uniforms, samplers, current string)
  122225. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122226. * @returns true if already built
  122227. */
  122228. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122229. protected _inputRename(name: string): string;
  122230. protected _outputRename(name: string): string;
  122231. protected _dumpPropertiesCode(): string;
  122232. /** @hidden */
  122233. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122234. /** @hidden */
  122235. _dumpCodeForOutputConnections(): string;
  122236. /**
  122237. * Clone the current block to a new identical block
  122238. * @param scene defines the hosting scene
  122239. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122240. * @returns a copy of the current block
  122241. */
  122242. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122243. /**
  122244. * Serializes this block in a JSON representation
  122245. * @returns the serialized block object
  122246. */
  122247. serialize(): any;
  122248. /** @hidden */
  122249. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122250. /**
  122251. * Release resources
  122252. */
  122253. dispose(): void;
  122254. }
  122255. }
  122256. declare module BABYLON {
  122257. /**
  122258. * Enum defining the type of animations supported by InputBlock
  122259. */
  122260. export enum AnimatedInputBlockTypes {
  122261. /** No animation */
  122262. None = 0,
  122263. /** Time based animation. Will only work for floats */
  122264. Time = 1
  122265. }
  122266. }
  122267. declare module BABYLON {
  122268. /**
  122269. * Block used to expose an input value
  122270. */
  122271. export class InputBlock extends NodeMaterialBlock {
  122272. private _mode;
  122273. private _associatedVariableName;
  122274. private _storedValue;
  122275. private _valueCallback;
  122276. private _type;
  122277. private _animationType;
  122278. /** Gets or set a value used to limit the range of float values */
  122279. min: number;
  122280. /** Gets or set a value used to limit the range of float values */
  122281. max: number;
  122282. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122283. matrixMode: number;
  122284. /** @hidden */
  122285. _systemValue: Nullable<NodeMaterialSystemValues>;
  122286. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122287. visibleInInspector: boolean;
  122288. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122289. isConstant: boolean;
  122290. /**
  122291. * Gets or sets the connection point type (default is float)
  122292. */
  122293. readonly type: NodeMaterialBlockConnectionPointTypes;
  122294. /**
  122295. * Creates a new InputBlock
  122296. * @param name defines the block name
  122297. * @param target defines the target of that block (Vertex by default)
  122298. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122299. */
  122300. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122301. /**
  122302. * Gets the output component
  122303. */
  122304. readonly output: NodeMaterialConnectionPoint;
  122305. /**
  122306. * Set the source of this connection point to a vertex attribute
  122307. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122308. * @returns the current connection point
  122309. */
  122310. setAsAttribute(attributeName?: string): InputBlock;
  122311. /**
  122312. * Set the source of this connection point to a system value
  122313. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122314. * @returns the current connection point
  122315. */
  122316. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122317. /**
  122318. * Gets or sets the value of that point.
  122319. * Please note that this value will be ignored if valueCallback is defined
  122320. */
  122321. value: any;
  122322. /**
  122323. * Gets or sets a callback used to get the value of that point.
  122324. * Please note that setting this value will force the connection point to ignore the value property
  122325. */
  122326. valueCallback: () => any;
  122327. /**
  122328. * Gets or sets the associated variable name in the shader
  122329. */
  122330. associatedVariableName: string;
  122331. /** Gets or sets the type of animation applied to the input */
  122332. animationType: AnimatedInputBlockTypes;
  122333. /**
  122334. * Gets a boolean indicating that this connection point not defined yet
  122335. */
  122336. readonly isUndefined: boolean;
  122337. /**
  122338. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122339. * In this case the connection point name must be the name of the uniform to use.
  122340. * Can only be set on inputs
  122341. */
  122342. isUniform: boolean;
  122343. /**
  122344. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122345. * In this case the connection point name must be the name of the attribute to use
  122346. * Can only be set on inputs
  122347. */
  122348. isAttribute: boolean;
  122349. /**
  122350. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122351. * Can only be set on exit points
  122352. */
  122353. isVarying: boolean;
  122354. /**
  122355. * Gets a boolean indicating that the current connection point is a system value
  122356. */
  122357. readonly isSystemValue: boolean;
  122358. /**
  122359. * Gets or sets the current well known value or null if not defined as a system value
  122360. */
  122361. systemValue: Nullable<NodeMaterialSystemValues>;
  122362. /**
  122363. * Gets the current class name
  122364. * @returns the class name
  122365. */
  122366. getClassName(): string;
  122367. /**
  122368. * Animate the input if animationType !== None
  122369. * @param scene defines the rendering scene
  122370. */
  122371. animate(scene: Scene): void;
  122372. private _emitDefine;
  122373. initialize(state: NodeMaterialBuildState): void;
  122374. /**
  122375. * Set the input block to its default value (based on its type)
  122376. */
  122377. setDefaultValue(): void;
  122378. private _emitConstant;
  122379. private _emit;
  122380. /** @hidden */
  122381. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122382. /** @hidden */
  122383. _transmit(effect: Effect, scene: Scene): void;
  122384. protected _buildBlock(state: NodeMaterialBuildState): void;
  122385. protected _dumpPropertiesCode(): string;
  122386. serialize(): any;
  122387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122388. }
  122389. }
  122390. declare module BABYLON {
  122391. /**
  122392. * Defines a connection point for a block
  122393. */
  122394. export class NodeMaterialConnectionPoint {
  122395. /** @hidden */
  122396. _ownerBlock: NodeMaterialBlock;
  122397. /** @hidden */
  122398. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122399. private _endpoints;
  122400. private _associatedVariableName;
  122401. /** @hidden */
  122402. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122403. /** @hidden */
  122404. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122405. private _type;
  122406. /** @hidden */
  122407. _enforceAssociatedVariableName: boolean;
  122408. /**
  122409. * Gets or sets the additional types supported by this connection point
  122410. */
  122411. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122412. /**
  122413. * Gets or sets the additional types excluded by this connection point
  122414. */
  122415. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122416. /**
  122417. * Observable triggered when this point is connected
  122418. */
  122419. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122420. /**
  122421. * Gets or sets the associated variable name in the shader
  122422. */
  122423. associatedVariableName: string;
  122424. /**
  122425. * Gets or sets the connection point type (default is float)
  122426. */
  122427. type: NodeMaterialBlockConnectionPointTypes;
  122428. /**
  122429. * Gets or sets the connection point name
  122430. */
  122431. name: string;
  122432. /**
  122433. * Gets or sets a boolean indicating that this connection point can be omitted
  122434. */
  122435. isOptional: boolean;
  122436. /**
  122437. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122438. */
  122439. define: string;
  122440. /** @hidden */
  122441. _prioritizeVertex: boolean;
  122442. private _target;
  122443. /** Gets or sets the target of that connection point */
  122444. target: NodeMaterialBlockTargets;
  122445. /**
  122446. * Gets a boolean indicating that the current point is connected
  122447. */
  122448. readonly isConnected: boolean;
  122449. /**
  122450. * Gets a boolean indicating that the current point is connected to an input block
  122451. */
  122452. readonly isConnectedToInputBlock: boolean;
  122453. /**
  122454. * Gets a the connected input block (if any)
  122455. */
  122456. readonly connectInputBlock: Nullable<InputBlock>;
  122457. /** Get the other side of the connection (if any) */
  122458. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122459. /** Get the block that owns this connection point */
  122460. readonly ownerBlock: NodeMaterialBlock;
  122461. /** Get the block connected on the other side of this connection (if any) */
  122462. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122463. /** Get the block connected on the endpoints of this connection (if any) */
  122464. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122465. /** Gets the list of connected endpoints */
  122466. readonly endpoints: NodeMaterialConnectionPoint[];
  122467. /** Gets a boolean indicating if that output point is connected to at least one input */
  122468. readonly hasEndpoints: boolean;
  122469. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122470. readonly isConnectedInVertexShader: boolean;
  122471. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122472. readonly isConnectedInFragmentShader: boolean;
  122473. /**
  122474. * Creates a new connection point
  122475. * @param name defines the connection point name
  122476. * @param ownerBlock defines the block hosting this connection point
  122477. */
  122478. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122479. /**
  122480. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122481. * @returns the class name
  122482. */
  122483. getClassName(): string;
  122484. /**
  122485. * Gets an boolean indicating if the current point can be connected to another point
  122486. * @param connectionPoint defines the other connection point
  122487. * @returns true if the connection is possible
  122488. */
  122489. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122490. /**
  122491. * Connect this point to another connection point
  122492. * @param connectionPoint defines the other connection point
  122493. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122494. * @returns the current connection point
  122495. */
  122496. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122497. /**
  122498. * Disconnect this point from one of his endpoint
  122499. * @param endpoint defines the other connection point
  122500. * @returns the current connection point
  122501. */
  122502. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122503. /**
  122504. * Serializes this point in a JSON representation
  122505. * @returns the serialized point object
  122506. */
  122507. serialize(): any;
  122508. /**
  122509. * Release resources
  122510. */
  122511. dispose(): void;
  122512. }
  122513. }
  122514. declare module BABYLON {
  122515. /**
  122516. * Block used to add support for vertex skinning (bones)
  122517. */
  122518. export class BonesBlock extends NodeMaterialBlock {
  122519. /**
  122520. * Creates a new BonesBlock
  122521. * @param name defines the block name
  122522. */
  122523. constructor(name: string);
  122524. /**
  122525. * Initialize the block and prepare the context for build
  122526. * @param state defines the state that will be used for the build
  122527. */
  122528. initialize(state: NodeMaterialBuildState): void;
  122529. /**
  122530. * Gets the current class name
  122531. * @returns the class name
  122532. */
  122533. getClassName(): string;
  122534. /**
  122535. * Gets the matrix indices input component
  122536. */
  122537. readonly matricesIndices: NodeMaterialConnectionPoint;
  122538. /**
  122539. * Gets the matrix weights input component
  122540. */
  122541. readonly matricesWeights: NodeMaterialConnectionPoint;
  122542. /**
  122543. * Gets the extra matrix indices input component
  122544. */
  122545. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122546. /**
  122547. * Gets the extra matrix weights input component
  122548. */
  122549. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122550. /**
  122551. * Gets the world input component
  122552. */
  122553. readonly world: NodeMaterialConnectionPoint;
  122554. /**
  122555. * Gets the output component
  122556. */
  122557. readonly output: NodeMaterialConnectionPoint;
  122558. autoConfigure(material: NodeMaterial): void;
  122559. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122562. protected _buildBlock(state: NodeMaterialBuildState): this;
  122563. }
  122564. }
  122565. declare module BABYLON {
  122566. /**
  122567. * Block used to add support for instances
  122568. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122569. */
  122570. export class InstancesBlock extends NodeMaterialBlock {
  122571. /**
  122572. * Creates a new InstancesBlock
  122573. * @param name defines the block name
  122574. */
  122575. constructor(name: string);
  122576. /**
  122577. * Gets the current class name
  122578. * @returns the class name
  122579. */
  122580. getClassName(): string;
  122581. /**
  122582. * Gets the first world row input component
  122583. */
  122584. readonly world0: NodeMaterialConnectionPoint;
  122585. /**
  122586. * Gets the second world row input component
  122587. */
  122588. readonly world1: NodeMaterialConnectionPoint;
  122589. /**
  122590. * Gets the third world row input component
  122591. */
  122592. readonly world2: NodeMaterialConnectionPoint;
  122593. /**
  122594. * Gets the forth world row input component
  122595. */
  122596. readonly world3: NodeMaterialConnectionPoint;
  122597. /**
  122598. * Gets the world input component
  122599. */
  122600. readonly world: NodeMaterialConnectionPoint;
  122601. /**
  122602. * Gets the output component
  122603. */
  122604. readonly output: NodeMaterialConnectionPoint;
  122605. autoConfigure(material: NodeMaterial): void;
  122606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122607. protected _buildBlock(state: NodeMaterialBuildState): this;
  122608. }
  122609. }
  122610. declare module BABYLON {
  122611. /**
  122612. * Block used to add morph targets support to vertex shader
  122613. */
  122614. export class MorphTargetsBlock extends NodeMaterialBlock {
  122615. private _repeatableContentAnchor;
  122616. private _repeatebleContentGenerated;
  122617. /**
  122618. * Create a new MorphTargetsBlock
  122619. * @param name defines the block name
  122620. */
  122621. constructor(name: string);
  122622. /**
  122623. * Gets the current class name
  122624. * @returns the class name
  122625. */
  122626. getClassName(): string;
  122627. /**
  122628. * Gets the position input component
  122629. */
  122630. readonly position: NodeMaterialConnectionPoint;
  122631. /**
  122632. * Gets the normal input component
  122633. */
  122634. readonly normal: NodeMaterialConnectionPoint;
  122635. /**
  122636. * Gets the tangent input component
  122637. */
  122638. readonly tangent: NodeMaterialConnectionPoint;
  122639. /**
  122640. * Gets the tangent input component
  122641. */
  122642. readonly uv: NodeMaterialConnectionPoint;
  122643. /**
  122644. * Gets the position output component
  122645. */
  122646. readonly positionOutput: NodeMaterialConnectionPoint;
  122647. /**
  122648. * Gets the normal output component
  122649. */
  122650. readonly normalOutput: NodeMaterialConnectionPoint;
  122651. /**
  122652. * Gets the tangent output component
  122653. */
  122654. readonly tangentOutput: NodeMaterialConnectionPoint;
  122655. /**
  122656. * Gets the tangent output component
  122657. */
  122658. readonly uvOutput: NodeMaterialConnectionPoint;
  122659. initialize(state: NodeMaterialBuildState): void;
  122660. autoConfigure(material: NodeMaterial): void;
  122661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122663. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122664. protected _buildBlock(state: NodeMaterialBuildState): this;
  122665. }
  122666. }
  122667. declare module BABYLON {
  122668. /**
  122669. * Block used to get data information from a light
  122670. */
  122671. export class LightInformationBlock extends NodeMaterialBlock {
  122672. private _lightDataUniformName;
  122673. private _lightColorUniformName;
  122674. private _lightTypeDefineName;
  122675. /**
  122676. * Gets or sets the light associated with this block
  122677. */
  122678. light: Nullable<Light>;
  122679. /**
  122680. * Creates a new LightInformationBlock
  122681. * @param name defines the block name
  122682. */
  122683. constructor(name: string);
  122684. /**
  122685. * Gets the current class name
  122686. * @returns the class name
  122687. */
  122688. getClassName(): string;
  122689. /**
  122690. * Gets the world position input component
  122691. */
  122692. readonly worldPosition: NodeMaterialConnectionPoint;
  122693. /**
  122694. * Gets the direction output component
  122695. */
  122696. readonly direction: NodeMaterialConnectionPoint;
  122697. /**
  122698. * Gets the direction output component
  122699. */
  122700. readonly color: NodeMaterialConnectionPoint;
  122701. /**
  122702. * Gets the direction output component
  122703. */
  122704. readonly intensity: NodeMaterialConnectionPoint;
  122705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122707. protected _buildBlock(state: NodeMaterialBuildState): this;
  122708. serialize(): any;
  122709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122710. }
  122711. }
  122712. declare module BABYLON {
  122713. /**
  122714. * Block used to add image processing support to fragment shader
  122715. */
  122716. export class ImageProcessingBlock extends NodeMaterialBlock {
  122717. /**
  122718. * Create a new ImageProcessingBlock
  122719. * @param name defines the block name
  122720. */
  122721. constructor(name: string);
  122722. /**
  122723. * Gets the current class name
  122724. * @returns the class name
  122725. */
  122726. getClassName(): string;
  122727. /**
  122728. * Gets the color input component
  122729. */
  122730. readonly color: NodeMaterialConnectionPoint;
  122731. /**
  122732. * Gets the output component
  122733. */
  122734. readonly output: NodeMaterialConnectionPoint;
  122735. /**
  122736. * Initialize the block and prepare the context for build
  122737. * @param state defines the state that will be used for the build
  122738. */
  122739. initialize(state: NodeMaterialBuildState): void;
  122740. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122743. protected _buildBlock(state: NodeMaterialBuildState): this;
  122744. }
  122745. }
  122746. declare module BABYLON {
  122747. /**
  122748. * Block used to pertub normals based on a normal map
  122749. */
  122750. export class PerturbNormalBlock extends NodeMaterialBlock {
  122751. private _tangentSpaceParameterName;
  122752. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122753. invertX: boolean;
  122754. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122755. invertY: boolean;
  122756. /**
  122757. * Create a new PerturbNormalBlock
  122758. * @param name defines the block name
  122759. */
  122760. constructor(name: string);
  122761. /**
  122762. * Gets the current class name
  122763. * @returns the class name
  122764. */
  122765. getClassName(): string;
  122766. /**
  122767. * Gets the world position input component
  122768. */
  122769. readonly worldPosition: NodeMaterialConnectionPoint;
  122770. /**
  122771. * Gets the world normal input component
  122772. */
  122773. readonly worldNormal: NodeMaterialConnectionPoint;
  122774. /**
  122775. * Gets the uv input component
  122776. */
  122777. readonly uv: NodeMaterialConnectionPoint;
  122778. /**
  122779. * Gets the normal map color input component
  122780. */
  122781. readonly normalMapColor: NodeMaterialConnectionPoint;
  122782. /**
  122783. * Gets the strength input component
  122784. */
  122785. readonly strength: NodeMaterialConnectionPoint;
  122786. /**
  122787. * Gets the output component
  122788. */
  122789. readonly output: NodeMaterialConnectionPoint;
  122790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122791. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122792. autoConfigure(material: NodeMaterial): void;
  122793. protected _buildBlock(state: NodeMaterialBuildState): this;
  122794. protected _dumpPropertiesCode(): string;
  122795. serialize(): any;
  122796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122797. }
  122798. }
  122799. declare module BABYLON {
  122800. /**
  122801. * Block used to discard a pixel if a value is smaller than a cutoff
  122802. */
  122803. export class DiscardBlock extends NodeMaterialBlock {
  122804. /**
  122805. * Create a new DiscardBlock
  122806. * @param name defines the block name
  122807. */
  122808. constructor(name: string);
  122809. /**
  122810. * Gets the current class name
  122811. * @returns the class name
  122812. */
  122813. getClassName(): string;
  122814. /**
  122815. * Gets the color input component
  122816. */
  122817. readonly value: NodeMaterialConnectionPoint;
  122818. /**
  122819. * Gets the cutoff input component
  122820. */
  122821. readonly cutoff: NodeMaterialConnectionPoint;
  122822. protected _buildBlock(state: NodeMaterialBuildState): this;
  122823. }
  122824. }
  122825. declare module BABYLON {
  122826. /**
  122827. * Block used to add support for scene fog
  122828. */
  122829. export class FogBlock extends NodeMaterialBlock {
  122830. private _fogDistanceName;
  122831. private _fogParameters;
  122832. /**
  122833. * Create a new FogBlock
  122834. * @param name defines the block name
  122835. */
  122836. constructor(name: string);
  122837. /**
  122838. * Gets the current class name
  122839. * @returns the class name
  122840. */
  122841. getClassName(): string;
  122842. /**
  122843. * Gets the world position input component
  122844. */
  122845. readonly worldPosition: NodeMaterialConnectionPoint;
  122846. /**
  122847. * Gets the view input component
  122848. */
  122849. readonly view: NodeMaterialConnectionPoint;
  122850. /**
  122851. * Gets the color input component
  122852. */
  122853. readonly input: NodeMaterialConnectionPoint;
  122854. /**
  122855. * Gets the fog color input component
  122856. */
  122857. readonly fogColor: NodeMaterialConnectionPoint;
  122858. /**
  122859. * Gets the output component
  122860. */
  122861. readonly output: NodeMaterialConnectionPoint;
  122862. autoConfigure(material: NodeMaterial): void;
  122863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122865. protected _buildBlock(state: NodeMaterialBuildState): this;
  122866. }
  122867. }
  122868. declare module BABYLON {
  122869. /**
  122870. * Block used to add light in the fragment shader
  122871. */
  122872. export class LightBlock extends NodeMaterialBlock {
  122873. private _lightId;
  122874. /**
  122875. * Gets or sets the light associated with this block
  122876. */
  122877. light: Nullable<Light>;
  122878. /**
  122879. * Create a new LightBlock
  122880. * @param name defines the block name
  122881. */
  122882. constructor(name: string);
  122883. /**
  122884. * Gets the current class name
  122885. * @returns the class name
  122886. */
  122887. getClassName(): string;
  122888. /**
  122889. * Gets the world position input component
  122890. */
  122891. readonly worldPosition: NodeMaterialConnectionPoint;
  122892. /**
  122893. * Gets the world normal input component
  122894. */
  122895. readonly worldNormal: NodeMaterialConnectionPoint;
  122896. /**
  122897. * Gets the camera (or eye) position component
  122898. */
  122899. readonly cameraPosition: NodeMaterialConnectionPoint;
  122900. /**
  122901. * Gets the glossiness component
  122902. */
  122903. readonly glossiness: NodeMaterialConnectionPoint;
  122904. /**
  122905. * Gets the glossinness power component
  122906. */
  122907. readonly glossPower: NodeMaterialConnectionPoint;
  122908. /**
  122909. * Gets the diffuse color component
  122910. */
  122911. readonly diffuseColor: NodeMaterialConnectionPoint;
  122912. /**
  122913. * Gets the specular color component
  122914. */
  122915. readonly specularColor: NodeMaterialConnectionPoint;
  122916. /**
  122917. * Gets the diffuse output component
  122918. */
  122919. readonly diffuseOutput: NodeMaterialConnectionPoint;
  122920. /**
  122921. * Gets the specular output component
  122922. */
  122923. readonly specularOutput: NodeMaterialConnectionPoint;
  122924. autoConfigure(material: NodeMaterial): void;
  122925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122926. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122928. private _injectVertexCode;
  122929. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122930. serialize(): any;
  122931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122932. }
  122933. }
  122934. declare module BABYLON {
  122935. /**
  122936. * Block used to multiply 2 values
  122937. */
  122938. export class MultiplyBlock extends NodeMaterialBlock {
  122939. /**
  122940. * Creates a new MultiplyBlock
  122941. * @param name defines the block name
  122942. */
  122943. constructor(name: string);
  122944. /**
  122945. * Gets the current class name
  122946. * @returns the class name
  122947. */
  122948. getClassName(): string;
  122949. /**
  122950. * Gets the left operand input component
  122951. */
  122952. readonly left: NodeMaterialConnectionPoint;
  122953. /**
  122954. * Gets the right operand input component
  122955. */
  122956. readonly right: NodeMaterialConnectionPoint;
  122957. /**
  122958. * Gets the output component
  122959. */
  122960. readonly output: NodeMaterialConnectionPoint;
  122961. protected _buildBlock(state: NodeMaterialBuildState): this;
  122962. }
  122963. }
  122964. declare module BABYLON {
  122965. /**
  122966. * Block used to add 2 vectors
  122967. */
  122968. export class AddBlock extends NodeMaterialBlock {
  122969. /**
  122970. * Creates a new AddBlock
  122971. * @param name defines the block name
  122972. */
  122973. constructor(name: string);
  122974. /**
  122975. * Gets the current class name
  122976. * @returns the class name
  122977. */
  122978. getClassName(): string;
  122979. /**
  122980. * Gets the left operand input component
  122981. */
  122982. readonly left: NodeMaterialConnectionPoint;
  122983. /**
  122984. * Gets the right operand input component
  122985. */
  122986. readonly right: NodeMaterialConnectionPoint;
  122987. /**
  122988. * Gets the output component
  122989. */
  122990. readonly output: NodeMaterialConnectionPoint;
  122991. protected _buildBlock(state: NodeMaterialBuildState): this;
  122992. }
  122993. }
  122994. declare module BABYLON {
  122995. /**
  122996. * Block used to scale a vector by a float
  122997. */
  122998. export class ScaleBlock extends NodeMaterialBlock {
  122999. /**
  123000. * Creates a new ScaleBlock
  123001. * @param name defines the block name
  123002. */
  123003. constructor(name: string);
  123004. /**
  123005. * Gets the current class name
  123006. * @returns the class name
  123007. */
  123008. getClassName(): string;
  123009. /**
  123010. * Gets the input component
  123011. */
  123012. readonly input: NodeMaterialConnectionPoint;
  123013. /**
  123014. * Gets the factor input component
  123015. */
  123016. readonly factor: NodeMaterialConnectionPoint;
  123017. /**
  123018. * Gets the output component
  123019. */
  123020. readonly output: NodeMaterialConnectionPoint;
  123021. protected _buildBlock(state: NodeMaterialBuildState): this;
  123022. }
  123023. }
  123024. declare module BABYLON {
  123025. /**
  123026. * Block used to clamp a float
  123027. */
  123028. export class ClampBlock extends NodeMaterialBlock {
  123029. /** Gets or sets the minimum range */
  123030. minimum: number;
  123031. /** Gets or sets the maximum range */
  123032. maximum: number;
  123033. /**
  123034. * Creates a new ClampBlock
  123035. * @param name defines the block name
  123036. */
  123037. constructor(name: string);
  123038. /**
  123039. * Gets the current class name
  123040. * @returns the class name
  123041. */
  123042. getClassName(): string;
  123043. /**
  123044. * Gets the value input component
  123045. */
  123046. readonly value: NodeMaterialConnectionPoint;
  123047. /**
  123048. * Gets the output component
  123049. */
  123050. readonly output: NodeMaterialConnectionPoint;
  123051. protected _buildBlock(state: NodeMaterialBuildState): this;
  123052. protected _dumpPropertiesCode(): string;
  123053. serialize(): any;
  123054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123055. }
  123056. }
  123057. declare module BABYLON {
  123058. /**
  123059. * Block used to apply a cross product between 2 vectors
  123060. */
  123061. export class CrossBlock extends NodeMaterialBlock {
  123062. /**
  123063. * Creates a new CrossBlock
  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 apply a dot product between 2 vectors
  123090. */
  123091. export class DotBlock extends NodeMaterialBlock {
  123092. /**
  123093. * Creates a new DotBlock
  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 left operand input component
  123104. */
  123105. readonly left: NodeMaterialConnectionPoint;
  123106. /**
  123107. * Gets the right operand input component
  123108. */
  123109. readonly right: 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 remap a float from a range to a new one
  123120. */
  123121. export class RemapBlock extends NodeMaterialBlock {
  123122. /**
  123123. * Gets or sets the source range
  123124. */
  123125. sourceRange: Vector2;
  123126. /**
  123127. * Gets or sets the target range
  123128. */
  123129. targetRange: Vector2;
  123130. /**
  123131. * Creates a new RemapBlock
  123132. * @param name defines the block name
  123133. */
  123134. constructor(name: string);
  123135. /**
  123136. * Gets the current class name
  123137. * @returns the class name
  123138. */
  123139. getClassName(): string;
  123140. /**
  123141. * Gets the input component
  123142. */
  123143. readonly input: NodeMaterialConnectionPoint;
  123144. /**
  123145. * Gets the source min input component
  123146. */
  123147. readonly sourceMin: NodeMaterialConnectionPoint;
  123148. /**
  123149. * Gets the source max input component
  123150. */
  123151. readonly sourceMax: NodeMaterialConnectionPoint;
  123152. /**
  123153. * Gets the target min input component
  123154. */
  123155. readonly targetMin: NodeMaterialConnectionPoint;
  123156. /**
  123157. * Gets the target max input component
  123158. */
  123159. readonly targetMax: NodeMaterialConnectionPoint;
  123160. /**
  123161. * Gets the output component
  123162. */
  123163. readonly output: NodeMaterialConnectionPoint;
  123164. protected _buildBlock(state: NodeMaterialBuildState): this;
  123165. protected _dumpPropertiesCode(): string;
  123166. serialize(): any;
  123167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123168. }
  123169. }
  123170. declare module BABYLON {
  123171. /**
  123172. * Block used to normalize a vector
  123173. */
  123174. export class NormalizeBlock extends NodeMaterialBlock {
  123175. /**
  123176. * Creates a new NormalizeBlock
  123177. * @param name defines the block name
  123178. */
  123179. constructor(name: string);
  123180. /**
  123181. * Gets the current class name
  123182. * @returns the class name
  123183. */
  123184. getClassName(): string;
  123185. /**
  123186. * Gets the input component
  123187. */
  123188. readonly input: NodeMaterialConnectionPoint;
  123189. /**
  123190. * Gets the output component
  123191. */
  123192. readonly output: NodeMaterialConnectionPoint;
  123193. protected _buildBlock(state: NodeMaterialBuildState): this;
  123194. }
  123195. }
  123196. declare module BABYLON {
  123197. /**
  123198. * Operations supported by the Trigonometry block
  123199. */
  123200. export enum TrigonometryBlockOperations {
  123201. /** Cos */
  123202. Cos = 0,
  123203. /** Sin */
  123204. Sin = 1,
  123205. /** Abs */
  123206. Abs = 2,
  123207. /** Exp */
  123208. Exp = 3,
  123209. /** Exp2 */
  123210. Exp2 = 4,
  123211. /** Round */
  123212. Round = 5,
  123213. /** Floor */
  123214. Floor = 6,
  123215. /** Ceiling */
  123216. Ceiling = 7,
  123217. /** Square root */
  123218. Sqrt = 8,
  123219. /** Log */
  123220. Log = 9,
  123221. /** Tangent */
  123222. Tan = 10,
  123223. /** Arc tangent */
  123224. ArcTan = 11,
  123225. /** Arc cosinus */
  123226. ArcCos = 12,
  123227. /** Arc sinus */
  123228. ArcSin = 13,
  123229. /** Fraction */
  123230. Fract = 14,
  123231. /** Sign */
  123232. Sign = 15,
  123233. /** To radians (from degrees) */
  123234. Radians = 16,
  123235. /** To degrees (from radians) */
  123236. Degrees = 17
  123237. }
  123238. /**
  123239. * Block used to apply trigonometry operation to floats
  123240. */
  123241. export class TrigonometryBlock extends NodeMaterialBlock {
  123242. /**
  123243. * Gets or sets the operation applied by the block
  123244. */
  123245. operation: TrigonometryBlockOperations;
  123246. /**
  123247. * Creates a new TrigonometryBlock
  123248. * @param name defines the block name
  123249. */
  123250. constructor(name: string);
  123251. /**
  123252. * Gets the current class name
  123253. * @returns the class name
  123254. */
  123255. getClassName(): string;
  123256. /**
  123257. * Gets the input component
  123258. */
  123259. readonly input: NodeMaterialConnectionPoint;
  123260. /**
  123261. * Gets the output component
  123262. */
  123263. readonly output: NodeMaterialConnectionPoint;
  123264. protected _buildBlock(state: NodeMaterialBuildState): this;
  123265. serialize(): any;
  123266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123267. }
  123268. }
  123269. declare module BABYLON {
  123270. /**
  123271. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123272. */
  123273. export class ColorMergerBlock extends NodeMaterialBlock {
  123274. /**
  123275. * Create a new ColorMergerBlock
  123276. * @param name defines the block name
  123277. */
  123278. constructor(name: string);
  123279. /**
  123280. * Gets the current class name
  123281. * @returns the class name
  123282. */
  123283. getClassName(): string;
  123284. /**
  123285. * Gets the r component (input)
  123286. */
  123287. readonly r: NodeMaterialConnectionPoint;
  123288. /**
  123289. * Gets the g component (input)
  123290. */
  123291. readonly g: NodeMaterialConnectionPoint;
  123292. /**
  123293. * Gets the b component (input)
  123294. */
  123295. readonly b: NodeMaterialConnectionPoint;
  123296. /**
  123297. * Gets the a component (input)
  123298. */
  123299. readonly a: NodeMaterialConnectionPoint;
  123300. /**
  123301. * Gets the rgba component (output)
  123302. */
  123303. readonly rgba: NodeMaterialConnectionPoint;
  123304. /**
  123305. * Gets the rgb component (output)
  123306. */
  123307. readonly rgb: NodeMaterialConnectionPoint;
  123308. protected _buildBlock(state: NodeMaterialBuildState): this;
  123309. }
  123310. }
  123311. declare module BABYLON {
  123312. /**
  123313. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123314. */
  123315. export class VectorMergerBlock extends NodeMaterialBlock {
  123316. /**
  123317. * Create a new VectorMergerBlock
  123318. * @param name defines the block name
  123319. */
  123320. constructor(name: string);
  123321. /**
  123322. * Gets the current class name
  123323. * @returns the class name
  123324. */
  123325. getClassName(): string;
  123326. /**
  123327. * Gets the x component (input)
  123328. */
  123329. readonly x: NodeMaterialConnectionPoint;
  123330. /**
  123331. * Gets the y component (input)
  123332. */
  123333. readonly y: NodeMaterialConnectionPoint;
  123334. /**
  123335. * Gets the z component (input)
  123336. */
  123337. readonly z: NodeMaterialConnectionPoint;
  123338. /**
  123339. * Gets the w component (input)
  123340. */
  123341. readonly w: NodeMaterialConnectionPoint;
  123342. /**
  123343. * Gets the xyzw component (output)
  123344. */
  123345. readonly xyzw: NodeMaterialConnectionPoint;
  123346. /**
  123347. * Gets the xyz component (output)
  123348. */
  123349. readonly xyz: NodeMaterialConnectionPoint;
  123350. /**
  123351. * Gets the xy component (output)
  123352. */
  123353. readonly xy: NodeMaterialConnectionPoint;
  123354. protected _buildBlock(state: NodeMaterialBuildState): this;
  123355. }
  123356. }
  123357. declare module BABYLON {
  123358. /**
  123359. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123360. */
  123361. export class ColorSplitterBlock extends NodeMaterialBlock {
  123362. /**
  123363. * Create a new ColorSplitterBlock
  123364. * @param name defines the block name
  123365. */
  123366. constructor(name: string);
  123367. /**
  123368. * Gets the current class name
  123369. * @returns the class name
  123370. */
  123371. getClassName(): string;
  123372. /**
  123373. * Gets the rgba component (input)
  123374. */
  123375. readonly rgba: NodeMaterialConnectionPoint;
  123376. /**
  123377. * Gets the rgb component (input)
  123378. */
  123379. readonly rgbIn: NodeMaterialConnectionPoint;
  123380. /**
  123381. * Gets the rgb component (output)
  123382. */
  123383. readonly rgbOut: NodeMaterialConnectionPoint;
  123384. /**
  123385. * Gets the r component (output)
  123386. */
  123387. readonly r: NodeMaterialConnectionPoint;
  123388. /**
  123389. * Gets the g component (output)
  123390. */
  123391. readonly g: NodeMaterialConnectionPoint;
  123392. /**
  123393. * Gets the b component (output)
  123394. */
  123395. readonly b: NodeMaterialConnectionPoint;
  123396. /**
  123397. * Gets the a component (output)
  123398. */
  123399. readonly a: NodeMaterialConnectionPoint;
  123400. protected _inputRename(name: string): string;
  123401. protected _outputRename(name: string): string;
  123402. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123403. }
  123404. }
  123405. declare module BABYLON {
  123406. /**
  123407. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123408. */
  123409. export class VectorSplitterBlock extends NodeMaterialBlock {
  123410. /**
  123411. * Create a new VectorSplitterBlock
  123412. * @param name defines the block name
  123413. */
  123414. constructor(name: string);
  123415. /**
  123416. * Gets the current class name
  123417. * @returns the class name
  123418. */
  123419. getClassName(): string;
  123420. /**
  123421. * Gets the xyzw component (input)
  123422. */
  123423. readonly xyzw: NodeMaterialConnectionPoint;
  123424. /**
  123425. * Gets the xyz component (input)
  123426. */
  123427. readonly xyzIn: NodeMaterialConnectionPoint;
  123428. /**
  123429. * Gets the xy component (input)
  123430. */
  123431. readonly xyIn: NodeMaterialConnectionPoint;
  123432. /**
  123433. * Gets the xyz component (output)
  123434. */
  123435. readonly xyzOut: NodeMaterialConnectionPoint;
  123436. /**
  123437. * Gets the xy component (output)
  123438. */
  123439. readonly xyOut: NodeMaterialConnectionPoint;
  123440. /**
  123441. * Gets the x component (output)
  123442. */
  123443. readonly x: NodeMaterialConnectionPoint;
  123444. /**
  123445. * Gets the y component (output)
  123446. */
  123447. readonly y: NodeMaterialConnectionPoint;
  123448. /**
  123449. * Gets the z component (output)
  123450. */
  123451. readonly z: NodeMaterialConnectionPoint;
  123452. /**
  123453. * Gets the w component (output)
  123454. */
  123455. readonly w: NodeMaterialConnectionPoint;
  123456. protected _inputRename(name: string): string;
  123457. protected _outputRename(name: string): string;
  123458. protected _buildBlock(state: NodeMaterialBuildState): this;
  123459. }
  123460. }
  123461. declare module BABYLON {
  123462. /**
  123463. * Block used to lerp between 2 values
  123464. */
  123465. export class LerpBlock extends NodeMaterialBlock {
  123466. /**
  123467. * Creates a new LerpBlock
  123468. * @param name defines the block name
  123469. */
  123470. constructor(name: string);
  123471. /**
  123472. * Gets the current class name
  123473. * @returns the class name
  123474. */
  123475. getClassName(): string;
  123476. /**
  123477. * Gets the left operand input component
  123478. */
  123479. readonly left: NodeMaterialConnectionPoint;
  123480. /**
  123481. * Gets the right operand input component
  123482. */
  123483. readonly right: NodeMaterialConnectionPoint;
  123484. /**
  123485. * Gets the gradient operand input component
  123486. */
  123487. readonly gradient: NodeMaterialConnectionPoint;
  123488. /**
  123489. * Gets the output component
  123490. */
  123491. readonly output: NodeMaterialConnectionPoint;
  123492. protected _buildBlock(state: NodeMaterialBuildState): this;
  123493. }
  123494. }
  123495. declare module BABYLON {
  123496. /**
  123497. * Block used to divide 2 vectors
  123498. */
  123499. export class DivideBlock extends NodeMaterialBlock {
  123500. /**
  123501. * Creates a new DivideBlock
  123502. * @param name defines the block name
  123503. */
  123504. constructor(name: string);
  123505. /**
  123506. * Gets the current class name
  123507. * @returns the class name
  123508. */
  123509. getClassName(): string;
  123510. /**
  123511. * Gets the left operand input component
  123512. */
  123513. readonly left: NodeMaterialConnectionPoint;
  123514. /**
  123515. * Gets the right operand input component
  123516. */
  123517. readonly right: NodeMaterialConnectionPoint;
  123518. /**
  123519. * Gets the output component
  123520. */
  123521. readonly output: NodeMaterialConnectionPoint;
  123522. protected _buildBlock(state: NodeMaterialBuildState): this;
  123523. }
  123524. }
  123525. declare module BABYLON {
  123526. /**
  123527. * Block used to subtract 2 vectors
  123528. */
  123529. export class SubtractBlock extends NodeMaterialBlock {
  123530. /**
  123531. * Creates a new SubtractBlock
  123532. * @param name defines the block name
  123533. */
  123534. constructor(name: string);
  123535. /**
  123536. * Gets the current class name
  123537. * @returns the class name
  123538. */
  123539. getClassName(): string;
  123540. /**
  123541. * Gets the left operand input component
  123542. */
  123543. readonly left: NodeMaterialConnectionPoint;
  123544. /**
  123545. * Gets the right operand input component
  123546. */
  123547. readonly right: NodeMaterialConnectionPoint;
  123548. /**
  123549. * Gets the output component
  123550. */
  123551. readonly output: NodeMaterialConnectionPoint;
  123552. protected _buildBlock(state: NodeMaterialBuildState): this;
  123553. }
  123554. }
  123555. declare module BABYLON {
  123556. /**
  123557. * Block used to step a value
  123558. */
  123559. export class StepBlock extends NodeMaterialBlock {
  123560. /**
  123561. * Creates a new StepBlock
  123562. * @param name defines the block name
  123563. */
  123564. constructor(name: string);
  123565. /**
  123566. * Gets the current class name
  123567. * @returns the class name
  123568. */
  123569. getClassName(): string;
  123570. /**
  123571. * Gets the value operand input component
  123572. */
  123573. readonly value: NodeMaterialConnectionPoint;
  123574. /**
  123575. * Gets the edge operand input component
  123576. */
  123577. readonly edge: NodeMaterialConnectionPoint;
  123578. /**
  123579. * Gets the output component
  123580. */
  123581. readonly output: NodeMaterialConnectionPoint;
  123582. protected _buildBlock(state: NodeMaterialBuildState): this;
  123583. }
  123584. }
  123585. declare module BABYLON {
  123586. /**
  123587. * Block used to get the opposite (1 - x) of a value
  123588. */
  123589. export class OneMinusBlock extends NodeMaterialBlock {
  123590. /**
  123591. * Creates a new OneMinusBlock
  123592. * @param name defines the block name
  123593. */
  123594. constructor(name: string);
  123595. /**
  123596. * Gets the current class name
  123597. * @returns the class name
  123598. */
  123599. getClassName(): string;
  123600. /**
  123601. * Gets the input component
  123602. */
  123603. readonly input: NodeMaterialConnectionPoint;
  123604. /**
  123605. * Gets the output component
  123606. */
  123607. readonly output: NodeMaterialConnectionPoint;
  123608. protected _buildBlock(state: NodeMaterialBuildState): this;
  123609. }
  123610. }
  123611. declare module BABYLON {
  123612. /**
  123613. * Block used to get the view direction
  123614. */
  123615. export class ViewDirectionBlock extends NodeMaterialBlock {
  123616. /**
  123617. * Creates a new ViewDirectionBlock
  123618. * @param name defines the block name
  123619. */
  123620. constructor(name: string);
  123621. /**
  123622. * Gets the current class name
  123623. * @returns the class name
  123624. */
  123625. getClassName(): string;
  123626. /**
  123627. * Gets the world position component
  123628. */
  123629. readonly worldPosition: NodeMaterialConnectionPoint;
  123630. /**
  123631. * Gets the camera position component
  123632. */
  123633. readonly cameraPosition: NodeMaterialConnectionPoint;
  123634. /**
  123635. * Gets the output component
  123636. */
  123637. readonly output: NodeMaterialConnectionPoint;
  123638. autoConfigure(material: NodeMaterial): void;
  123639. protected _buildBlock(state: NodeMaterialBuildState): this;
  123640. }
  123641. }
  123642. declare module BABYLON {
  123643. /**
  123644. * Block used to compute fresnel value
  123645. */
  123646. export class FresnelBlock extends NodeMaterialBlock {
  123647. /**
  123648. * Create a new FresnelBlock
  123649. * @param name defines the block name
  123650. */
  123651. constructor(name: string);
  123652. /**
  123653. * Gets the current class name
  123654. * @returns the class name
  123655. */
  123656. getClassName(): string;
  123657. /**
  123658. * Gets the world normal input component
  123659. */
  123660. readonly worldNormal: NodeMaterialConnectionPoint;
  123661. /**
  123662. * Gets the view direction input component
  123663. */
  123664. readonly viewDirection: NodeMaterialConnectionPoint;
  123665. /**
  123666. * Gets the bias input component
  123667. */
  123668. readonly bias: NodeMaterialConnectionPoint;
  123669. /**
  123670. * Gets the camera (or eye) position component
  123671. */
  123672. readonly power: NodeMaterialConnectionPoint;
  123673. /**
  123674. * Gets the fresnel output component
  123675. */
  123676. readonly fresnel: NodeMaterialConnectionPoint;
  123677. autoConfigure(material: NodeMaterial): void;
  123678. protected _buildBlock(state: NodeMaterialBuildState): this;
  123679. }
  123680. }
  123681. declare module BABYLON {
  123682. /**
  123683. * Block used to get the max of 2 values
  123684. */
  123685. export class MaxBlock extends NodeMaterialBlock {
  123686. /**
  123687. * Creates a new MaxBlock
  123688. * @param name defines the block name
  123689. */
  123690. constructor(name: string);
  123691. /**
  123692. * Gets the current class name
  123693. * @returns the class name
  123694. */
  123695. getClassName(): string;
  123696. /**
  123697. * Gets the left operand input component
  123698. */
  123699. readonly left: NodeMaterialConnectionPoint;
  123700. /**
  123701. * Gets the right operand input component
  123702. */
  123703. readonly right: NodeMaterialConnectionPoint;
  123704. /**
  123705. * Gets the output component
  123706. */
  123707. readonly output: NodeMaterialConnectionPoint;
  123708. protected _buildBlock(state: NodeMaterialBuildState): this;
  123709. }
  123710. }
  123711. declare module BABYLON {
  123712. /**
  123713. * Block used to get the min of 2 values
  123714. */
  123715. export class MinBlock extends NodeMaterialBlock {
  123716. /**
  123717. * Creates a new MinBlock
  123718. * @param name defines the block name
  123719. */
  123720. constructor(name: string);
  123721. /**
  123722. * Gets the current class name
  123723. * @returns the class name
  123724. */
  123725. getClassName(): string;
  123726. /**
  123727. * Gets the left operand input component
  123728. */
  123729. readonly left: NodeMaterialConnectionPoint;
  123730. /**
  123731. * Gets the right operand input component
  123732. */
  123733. readonly right: NodeMaterialConnectionPoint;
  123734. /**
  123735. * Gets the output component
  123736. */
  123737. readonly output: NodeMaterialConnectionPoint;
  123738. protected _buildBlock(state: NodeMaterialBuildState): this;
  123739. }
  123740. }
  123741. declare module BABYLON {
  123742. /**
  123743. * Block used to get the distance between 2 values
  123744. */
  123745. export class DistanceBlock extends NodeMaterialBlock {
  123746. /**
  123747. * Creates a new DistanceBlock
  123748. * @param name defines the block name
  123749. */
  123750. constructor(name: string);
  123751. /**
  123752. * Gets the current class name
  123753. * @returns the class name
  123754. */
  123755. getClassName(): string;
  123756. /**
  123757. * Gets the left operand input component
  123758. */
  123759. readonly left: NodeMaterialConnectionPoint;
  123760. /**
  123761. * Gets the right operand input component
  123762. */
  123763. readonly right: NodeMaterialConnectionPoint;
  123764. /**
  123765. * Gets the output component
  123766. */
  123767. readonly output: NodeMaterialConnectionPoint;
  123768. protected _buildBlock(state: NodeMaterialBuildState): this;
  123769. }
  123770. }
  123771. declare module BABYLON {
  123772. /**
  123773. * Block used to get the length of a vector
  123774. */
  123775. export class LengthBlock extends NodeMaterialBlock {
  123776. /**
  123777. * Creates a new LengthBlock
  123778. * @param name defines the block name
  123779. */
  123780. constructor(name: string);
  123781. /**
  123782. * Gets the current class name
  123783. * @returns the class name
  123784. */
  123785. getClassName(): string;
  123786. /**
  123787. * Gets the value input component
  123788. */
  123789. readonly value: NodeMaterialConnectionPoint;
  123790. /**
  123791. * Gets the output component
  123792. */
  123793. readonly output: NodeMaterialConnectionPoint;
  123794. protected _buildBlock(state: NodeMaterialBuildState): this;
  123795. }
  123796. }
  123797. declare module BABYLON {
  123798. /**
  123799. * Block used to get negative version of a value (i.e. x * -1)
  123800. */
  123801. export class NegateBlock extends NodeMaterialBlock {
  123802. /**
  123803. * Creates a new NegateBlock
  123804. * @param name defines the block name
  123805. */
  123806. constructor(name: string);
  123807. /**
  123808. * Gets the current class name
  123809. * @returns the class name
  123810. */
  123811. getClassName(): string;
  123812. /**
  123813. * Gets the value input component
  123814. */
  123815. readonly value: NodeMaterialConnectionPoint;
  123816. /**
  123817. * Gets the output component
  123818. */
  123819. readonly output: NodeMaterialConnectionPoint;
  123820. protected _buildBlock(state: NodeMaterialBuildState): this;
  123821. }
  123822. }
  123823. declare module BABYLON {
  123824. /**
  123825. * Block used to get the value of the first parameter raised to the power of the second
  123826. */
  123827. export class PowBlock extends NodeMaterialBlock {
  123828. /**
  123829. * Creates a new PowBlock
  123830. * @param name defines the block name
  123831. */
  123832. constructor(name: string);
  123833. /**
  123834. * Gets the current class name
  123835. * @returns the class name
  123836. */
  123837. getClassName(): string;
  123838. /**
  123839. * Gets the value operand input component
  123840. */
  123841. readonly value: NodeMaterialConnectionPoint;
  123842. /**
  123843. * Gets the power operand input component
  123844. */
  123845. readonly power: NodeMaterialConnectionPoint;
  123846. /**
  123847. * Gets the output component
  123848. */
  123849. readonly output: NodeMaterialConnectionPoint;
  123850. protected _buildBlock(state: NodeMaterialBuildState): this;
  123851. }
  123852. }
  123853. declare module BABYLON {
  123854. /**
  123855. * Block used to get a random number
  123856. */
  123857. export class RandomNumberBlock extends NodeMaterialBlock {
  123858. /**
  123859. * Creates a new RandomNumberBlock
  123860. * @param name defines the block name
  123861. */
  123862. constructor(name: string);
  123863. /**
  123864. * Gets the current class name
  123865. * @returns the class name
  123866. */
  123867. getClassName(): string;
  123868. /**
  123869. * Gets the seed input component
  123870. */
  123871. readonly seed: NodeMaterialConnectionPoint;
  123872. /**
  123873. * Gets the output component
  123874. */
  123875. readonly output: NodeMaterialConnectionPoint;
  123876. protected _buildBlock(state: NodeMaterialBuildState): this;
  123877. }
  123878. }
  123879. declare module BABYLON {
  123880. /**
  123881. * Block used to compute arc tangent of 2 values
  123882. */
  123883. export class ArcTan2Block extends NodeMaterialBlock {
  123884. /**
  123885. * Creates a new ArcTan2Block
  123886. * @param name defines the block name
  123887. */
  123888. constructor(name: string);
  123889. /**
  123890. * Gets the current class name
  123891. * @returns the class name
  123892. */
  123893. getClassName(): string;
  123894. /**
  123895. * Gets the x operand input component
  123896. */
  123897. readonly x: NodeMaterialConnectionPoint;
  123898. /**
  123899. * Gets the y operand input component
  123900. */
  123901. readonly y: NodeMaterialConnectionPoint;
  123902. /**
  123903. * Gets the output component
  123904. */
  123905. readonly output: NodeMaterialConnectionPoint;
  123906. protected _buildBlock(state: NodeMaterialBuildState): this;
  123907. }
  123908. }
  123909. declare module BABYLON {
  123910. /**
  123911. * Block used to smooth step a value
  123912. */
  123913. export class SmoothStepBlock extends NodeMaterialBlock {
  123914. /**
  123915. * Creates a new SmoothStepBlock
  123916. * @param name defines the block name
  123917. */
  123918. constructor(name: string);
  123919. /**
  123920. * Gets the current class name
  123921. * @returns the class name
  123922. */
  123923. getClassName(): string;
  123924. /**
  123925. * Gets the value operand input component
  123926. */
  123927. readonly value: NodeMaterialConnectionPoint;
  123928. /**
  123929. * Gets the first edge operand input component
  123930. */
  123931. readonly edge0: NodeMaterialConnectionPoint;
  123932. /**
  123933. * Gets the second edge operand input component
  123934. */
  123935. readonly edge1: NodeMaterialConnectionPoint;
  123936. /**
  123937. * Gets the output component
  123938. */
  123939. readonly output: NodeMaterialConnectionPoint;
  123940. protected _buildBlock(state: NodeMaterialBuildState): this;
  123941. }
  123942. }
  123943. declare module BABYLON {
  123944. /**
  123945. * Block used to get the reciprocal (1 / x) of a value
  123946. */
  123947. export class ReciprocalBlock extends NodeMaterialBlock {
  123948. /**
  123949. * Creates a new ReciprocalBlock
  123950. * @param name defines the block name
  123951. */
  123952. constructor(name: string);
  123953. /**
  123954. * Gets the current class name
  123955. * @returns the class name
  123956. */
  123957. getClassName(): string;
  123958. /**
  123959. * Gets the input component
  123960. */
  123961. readonly input: NodeMaterialConnectionPoint;
  123962. /**
  123963. * Gets the output component
  123964. */
  123965. readonly output: NodeMaterialConnectionPoint;
  123966. protected _buildBlock(state: NodeMaterialBuildState): this;
  123967. }
  123968. }
  123969. declare module BABYLON {
  123970. /**
  123971. * Block used to replace a color by another one
  123972. */
  123973. export class ReplaceColorBlock extends NodeMaterialBlock {
  123974. /**
  123975. * Creates a new ReplaceColorBlock
  123976. * @param name defines the block name
  123977. */
  123978. constructor(name: string);
  123979. /**
  123980. * Gets the current class name
  123981. * @returns the class name
  123982. */
  123983. getClassName(): string;
  123984. /**
  123985. * Gets the value input component
  123986. */
  123987. readonly value: NodeMaterialConnectionPoint;
  123988. /**
  123989. * Gets the reference input component
  123990. */
  123991. readonly reference: NodeMaterialConnectionPoint;
  123992. /**
  123993. * Gets the distance input component
  123994. */
  123995. readonly distance: NodeMaterialConnectionPoint;
  123996. /**
  123997. * Gets the replacement input component
  123998. */
  123999. readonly replacement: NodeMaterialConnectionPoint;
  124000. /**
  124001. * Gets the output component
  124002. */
  124003. readonly output: NodeMaterialConnectionPoint;
  124004. protected _buildBlock(state: NodeMaterialBuildState): this;
  124005. }
  124006. }
  124007. declare module BABYLON {
  124008. /**
  124009. * Block used to posterize a value
  124010. * @see https://en.wikipedia.org/wiki/Posterization
  124011. */
  124012. export class PosterizeBlock extends NodeMaterialBlock {
  124013. /**
  124014. * Creates a new PosterizeBlock
  124015. * @param name defines the block name
  124016. */
  124017. constructor(name: string);
  124018. /**
  124019. * Gets the current class name
  124020. * @returns the class name
  124021. */
  124022. getClassName(): string;
  124023. /**
  124024. * Gets the value input component
  124025. */
  124026. readonly value: NodeMaterialConnectionPoint;
  124027. /**
  124028. * Gets the steps input component
  124029. */
  124030. readonly steps: NodeMaterialConnectionPoint;
  124031. /**
  124032. * Gets the output component
  124033. */
  124034. readonly output: NodeMaterialConnectionPoint;
  124035. protected _buildBlock(state: NodeMaterialBuildState): this;
  124036. }
  124037. }
  124038. declare module BABYLON {
  124039. /**
  124040. * Operations supported by the Wave block
  124041. */
  124042. export enum WaveBlockKind {
  124043. /** SawTooth */
  124044. SawTooth = 0,
  124045. /** Square */
  124046. Square = 1,
  124047. /** Triangle */
  124048. Triangle = 2
  124049. }
  124050. /**
  124051. * Block used to apply wave operation to floats
  124052. */
  124053. export class WaveBlock extends NodeMaterialBlock {
  124054. /**
  124055. * Gets or sets the kibnd of wave to be applied by the block
  124056. */
  124057. kind: WaveBlockKind;
  124058. /**
  124059. * Creates a new WaveBlock
  124060. * @param name defines the block name
  124061. */
  124062. constructor(name: string);
  124063. /**
  124064. * Gets the current class name
  124065. * @returns the class name
  124066. */
  124067. getClassName(): string;
  124068. /**
  124069. * Gets the input component
  124070. */
  124071. readonly input: NodeMaterialConnectionPoint;
  124072. /**
  124073. * Gets the output component
  124074. */
  124075. readonly output: NodeMaterialConnectionPoint;
  124076. protected _buildBlock(state: NodeMaterialBuildState): this;
  124077. serialize(): any;
  124078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124079. }
  124080. }
  124081. declare module BABYLON {
  124082. /**
  124083. * Class used to store a color step for the GradientBlock
  124084. */
  124085. export class GradientBlockColorStep {
  124086. /**
  124087. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124088. */
  124089. step: number;
  124090. /**
  124091. * Gets or sets the color associated with this step
  124092. */
  124093. color: Color3;
  124094. /**
  124095. * Creates a new GradientBlockColorStep
  124096. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124097. * @param color defines the color associated with this step
  124098. */
  124099. constructor(
  124100. /**
  124101. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124102. */
  124103. step: number,
  124104. /**
  124105. * Gets or sets the color associated with this step
  124106. */
  124107. color: Color3);
  124108. }
  124109. /**
  124110. * Block used to return a color from a gradient based on an input value between 0 and 1
  124111. */
  124112. export class GradientBlock extends NodeMaterialBlock {
  124113. /**
  124114. * Gets or sets the list of color steps
  124115. */
  124116. colorSteps: GradientBlockColorStep[];
  124117. /**
  124118. * Creates a new GradientBlock
  124119. * @param name defines the block name
  124120. */
  124121. constructor(name: string);
  124122. /**
  124123. * Gets the current class name
  124124. * @returns the class name
  124125. */
  124126. getClassName(): string;
  124127. /**
  124128. * Gets the gradient input component
  124129. */
  124130. readonly gradient: NodeMaterialConnectionPoint;
  124131. /**
  124132. * Gets the output component
  124133. */
  124134. readonly output: NodeMaterialConnectionPoint;
  124135. private _writeColorConstant;
  124136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124137. serialize(): any;
  124138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124139. protected _dumpPropertiesCode(): string;
  124140. }
  124141. }
  124142. declare module BABYLON {
  124143. /**
  124144. * Block used to normalize lerp between 2 values
  124145. */
  124146. export class NLerpBlock extends NodeMaterialBlock {
  124147. /**
  124148. * Creates a new NLerpBlock
  124149. * @param name defines the block name
  124150. */
  124151. constructor(name: string);
  124152. /**
  124153. * Gets the current class name
  124154. * @returns the class name
  124155. */
  124156. getClassName(): string;
  124157. /**
  124158. * Gets the left operand input component
  124159. */
  124160. readonly left: NodeMaterialConnectionPoint;
  124161. /**
  124162. * Gets the right operand input component
  124163. */
  124164. readonly right: NodeMaterialConnectionPoint;
  124165. /**
  124166. * Gets the gradient operand input component
  124167. */
  124168. readonly gradient: NodeMaterialConnectionPoint;
  124169. /**
  124170. * Gets the output component
  124171. */
  124172. readonly output: NodeMaterialConnectionPoint;
  124173. protected _buildBlock(state: NodeMaterialBuildState): this;
  124174. }
  124175. }
  124176. declare module BABYLON {
  124177. /**
  124178. * Block used to test if the fragment shader is front facing
  124179. */
  124180. export class FrontFacingBlock extends NodeMaterialBlock {
  124181. /**
  124182. * Creates a new FrontFacingBlock
  124183. * @param name defines the block name
  124184. */
  124185. constructor(name: string);
  124186. /**
  124187. * Gets the current class name
  124188. * @returns the class name
  124189. */
  124190. getClassName(): string;
  124191. /**
  124192. * Gets the output component
  124193. */
  124194. readonly output: NodeMaterialConnectionPoint;
  124195. protected _buildBlock(state: NodeMaterialBuildState): this;
  124196. }
  124197. }
  124198. declare module BABYLON {
  124199. /**
  124200. * Effect Render Options
  124201. */
  124202. export interface IEffectRendererOptions {
  124203. /**
  124204. * Defines the vertices positions.
  124205. */
  124206. positions?: number[];
  124207. /**
  124208. * Defines the indices.
  124209. */
  124210. indices?: number[];
  124211. }
  124212. /**
  124213. * Helper class to render one or more effects
  124214. */
  124215. export class EffectRenderer {
  124216. private engine;
  124217. private static _DefaultOptions;
  124218. private _vertexBuffers;
  124219. private _indexBuffer;
  124220. private _ringBufferIndex;
  124221. private _ringScreenBuffer;
  124222. private _fullscreenViewport;
  124223. private _getNextFrameBuffer;
  124224. /**
  124225. * Creates an effect renderer
  124226. * @param engine the engine to use for rendering
  124227. * @param options defines the options of the effect renderer
  124228. */
  124229. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124230. /**
  124231. * Sets the current viewport in normalized coordinates 0-1
  124232. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124233. */
  124234. setViewport(viewport?: Viewport): void;
  124235. /**
  124236. * Binds the embedded attributes buffer to the effect.
  124237. * @param effect Defines the effect to bind the attributes for
  124238. */
  124239. bindBuffers(effect: Effect): void;
  124240. /**
  124241. * Sets the current effect wrapper to use during draw.
  124242. * The effect needs to be ready before calling this api.
  124243. * This also sets the default full screen position attribute.
  124244. * @param effectWrapper Defines the effect to draw with
  124245. */
  124246. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124247. /**
  124248. * Draws a full screen quad.
  124249. */
  124250. draw(): void;
  124251. /**
  124252. * renders one or more effects to a specified texture
  124253. * @param effectWrappers list of effects to renderer
  124254. * @param outputTexture texture to draw to, if null it will render to the screen
  124255. */
  124256. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124257. /**
  124258. * Disposes of the effect renderer
  124259. */
  124260. dispose(): void;
  124261. }
  124262. /**
  124263. * Options to create an EffectWrapper
  124264. */
  124265. interface EffectWrapperCreationOptions {
  124266. /**
  124267. * Engine to use to create the effect
  124268. */
  124269. engine: ThinEngine;
  124270. /**
  124271. * Fragment shader for the effect
  124272. */
  124273. fragmentShader: string;
  124274. /**
  124275. * Vertex shader for the effect
  124276. */
  124277. vertexShader?: string;
  124278. /**
  124279. * Attributes to use in the shader
  124280. */
  124281. attributeNames?: Array<string>;
  124282. /**
  124283. * Uniforms to use in the shader
  124284. */
  124285. uniformNames?: Array<string>;
  124286. /**
  124287. * Texture sampler names to use in the shader
  124288. */
  124289. samplerNames?: Array<string>;
  124290. /**
  124291. * The friendly name of the effect displayed in Spector.
  124292. */
  124293. name?: string;
  124294. }
  124295. /**
  124296. * Wraps an effect to be used for rendering
  124297. */
  124298. export class EffectWrapper {
  124299. /**
  124300. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124301. */
  124302. onApplyObservable: Observable<{}>;
  124303. /**
  124304. * The underlying effect
  124305. */
  124306. effect: Effect;
  124307. /**
  124308. * Creates an effect to be renderer
  124309. * @param creationOptions options to create the effect
  124310. */
  124311. constructor(creationOptions: EffectWrapperCreationOptions);
  124312. /**
  124313. * Disposes of the effect wrapper
  124314. */
  124315. dispose(): void;
  124316. }
  124317. }
  124318. declare module BABYLON {
  124319. /**
  124320. * Helper class to push actions to a pool of workers.
  124321. */
  124322. export class WorkerPool implements IDisposable {
  124323. private _workerInfos;
  124324. private _pendingActions;
  124325. /**
  124326. * Constructor
  124327. * @param workers Array of workers to use for actions
  124328. */
  124329. constructor(workers: Array<Worker>);
  124330. /**
  124331. * Terminates all workers and clears any pending actions.
  124332. */
  124333. dispose(): void;
  124334. /**
  124335. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124336. * pended until a worker has completed its action.
  124337. * @param action The action to perform. Call onComplete when the action is complete.
  124338. */
  124339. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124340. private _execute;
  124341. }
  124342. }
  124343. declare module BABYLON {
  124344. /**
  124345. * Configuration for Draco compression
  124346. */
  124347. export interface IDracoCompressionConfiguration {
  124348. /**
  124349. * Configuration for the decoder.
  124350. */
  124351. decoder: {
  124352. /**
  124353. * The url to the WebAssembly module.
  124354. */
  124355. wasmUrl?: string;
  124356. /**
  124357. * The url to the WebAssembly binary.
  124358. */
  124359. wasmBinaryUrl?: string;
  124360. /**
  124361. * The url to the fallback JavaScript module.
  124362. */
  124363. fallbackUrl?: string;
  124364. };
  124365. }
  124366. /**
  124367. * Draco compression (https://google.github.io/draco/)
  124368. *
  124369. * This class wraps the Draco module.
  124370. *
  124371. * **Encoder**
  124372. *
  124373. * The encoder is not currently implemented.
  124374. *
  124375. * **Decoder**
  124376. *
  124377. * 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.
  124378. *
  124379. * To update the configuration, use the following code:
  124380. * ```javascript
  124381. * DracoCompression.Configuration = {
  124382. * decoder: {
  124383. * wasmUrl: "<url to the WebAssembly library>",
  124384. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124385. * fallbackUrl: "<url to the fallback JavaScript library>",
  124386. * }
  124387. * };
  124388. * ```
  124389. *
  124390. * 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.
  124391. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124392. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124393. *
  124394. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124395. * ```javascript
  124396. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124397. * ```
  124398. *
  124399. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124400. */
  124401. export class DracoCompression implements IDisposable {
  124402. private _workerPoolPromise?;
  124403. private _decoderModulePromise?;
  124404. /**
  124405. * The configuration. Defaults to the following urls:
  124406. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124407. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124408. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124409. */
  124410. static Configuration: IDracoCompressionConfiguration;
  124411. /**
  124412. * Returns true if the decoder configuration is available.
  124413. */
  124414. static readonly DecoderAvailable: boolean;
  124415. /**
  124416. * Default number of workers to create when creating the draco compression object.
  124417. */
  124418. static DefaultNumWorkers: number;
  124419. private static GetDefaultNumWorkers;
  124420. private static _Default;
  124421. /**
  124422. * Default instance for the draco compression object.
  124423. */
  124424. static readonly Default: DracoCompression;
  124425. /**
  124426. * Constructor
  124427. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124428. */
  124429. constructor(numWorkers?: number);
  124430. /**
  124431. * Stop all async operations and release resources.
  124432. */
  124433. dispose(): void;
  124434. /**
  124435. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124436. * @returns a promise that resolves when ready
  124437. */
  124438. whenReadyAsync(): Promise<void>;
  124439. /**
  124440. * Decode Draco compressed mesh data to vertex data.
  124441. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124442. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124443. * @returns A promise that resolves with the decoded vertex data
  124444. */
  124445. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124446. [kind: string]: number;
  124447. }): Promise<VertexData>;
  124448. }
  124449. }
  124450. declare module BABYLON {
  124451. /**
  124452. * Class for building Constructive Solid Geometry
  124453. */
  124454. export class CSG {
  124455. private polygons;
  124456. /**
  124457. * The world matrix
  124458. */
  124459. matrix: Matrix;
  124460. /**
  124461. * Stores the position
  124462. */
  124463. position: Vector3;
  124464. /**
  124465. * Stores the rotation
  124466. */
  124467. rotation: Vector3;
  124468. /**
  124469. * Stores the rotation quaternion
  124470. */
  124471. rotationQuaternion: Nullable<Quaternion>;
  124472. /**
  124473. * Stores the scaling vector
  124474. */
  124475. scaling: Vector3;
  124476. /**
  124477. * Convert the Mesh to CSG
  124478. * @param mesh The Mesh to convert to CSG
  124479. * @returns A new CSG from the Mesh
  124480. */
  124481. static FromMesh(mesh: Mesh): CSG;
  124482. /**
  124483. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124484. * @param polygons Polygons used to construct a CSG solid
  124485. */
  124486. private static FromPolygons;
  124487. /**
  124488. * Clones, or makes a deep copy, of the CSG
  124489. * @returns A new CSG
  124490. */
  124491. clone(): CSG;
  124492. /**
  124493. * Unions this CSG with another CSG
  124494. * @param csg The CSG to union against this CSG
  124495. * @returns The unioned CSG
  124496. */
  124497. union(csg: CSG): CSG;
  124498. /**
  124499. * Unions this CSG with another CSG in place
  124500. * @param csg The CSG to union against this CSG
  124501. */
  124502. unionInPlace(csg: CSG): void;
  124503. /**
  124504. * Subtracts this CSG with another CSG
  124505. * @param csg The CSG to subtract against this CSG
  124506. * @returns A new CSG
  124507. */
  124508. subtract(csg: CSG): CSG;
  124509. /**
  124510. * Subtracts this CSG with another CSG in place
  124511. * @param csg The CSG to subtact against this CSG
  124512. */
  124513. subtractInPlace(csg: CSG): void;
  124514. /**
  124515. * Intersect this CSG with another CSG
  124516. * @param csg The CSG to intersect against this CSG
  124517. * @returns A new CSG
  124518. */
  124519. intersect(csg: CSG): CSG;
  124520. /**
  124521. * Intersects this CSG with another CSG in place
  124522. * @param csg The CSG to intersect against this CSG
  124523. */
  124524. intersectInPlace(csg: CSG): void;
  124525. /**
  124526. * Return a new CSG solid with solid and empty space switched. This solid is
  124527. * not modified.
  124528. * @returns A new CSG solid with solid and empty space switched
  124529. */
  124530. inverse(): CSG;
  124531. /**
  124532. * Inverses the CSG in place
  124533. */
  124534. inverseInPlace(): void;
  124535. /**
  124536. * This is used to keep meshes transformations so they can be restored
  124537. * when we build back a Babylon Mesh
  124538. * NB : All CSG operations are performed in world coordinates
  124539. * @param csg The CSG to copy the transform attributes from
  124540. * @returns This CSG
  124541. */
  124542. copyTransformAttributes(csg: CSG): CSG;
  124543. /**
  124544. * Build Raw mesh from CSG
  124545. * Coordinates here are in world space
  124546. * @param name The name of the mesh geometry
  124547. * @param scene The Scene
  124548. * @param keepSubMeshes Specifies if the submeshes should be kept
  124549. * @returns A new Mesh
  124550. */
  124551. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124552. /**
  124553. * Build Mesh from CSG taking material and transforms into account
  124554. * @param name The name of the Mesh
  124555. * @param material The material of the Mesh
  124556. * @param scene The Scene
  124557. * @param keepSubMeshes Specifies if submeshes should be kept
  124558. * @returns The new Mesh
  124559. */
  124560. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124561. }
  124562. }
  124563. declare module BABYLON {
  124564. /**
  124565. * Class used to create a trail following a mesh
  124566. */
  124567. export class TrailMesh extends Mesh {
  124568. private _generator;
  124569. private _autoStart;
  124570. private _running;
  124571. private _diameter;
  124572. private _length;
  124573. private _sectionPolygonPointsCount;
  124574. private _sectionVectors;
  124575. private _sectionNormalVectors;
  124576. private _beforeRenderObserver;
  124577. /**
  124578. * @constructor
  124579. * @param name The value used by scene.getMeshByName() to do a lookup.
  124580. * @param generator The mesh to generate a trail.
  124581. * @param scene The scene to add this mesh to.
  124582. * @param diameter Diameter of trailing mesh. Default is 1.
  124583. * @param length Length of trailing mesh. Default is 60.
  124584. * @param autoStart Automatically start trailing mesh. Default true.
  124585. */
  124586. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124587. /**
  124588. * "TrailMesh"
  124589. * @returns "TrailMesh"
  124590. */
  124591. getClassName(): string;
  124592. private _createMesh;
  124593. /**
  124594. * Start trailing mesh.
  124595. */
  124596. start(): void;
  124597. /**
  124598. * Stop trailing mesh.
  124599. */
  124600. stop(): void;
  124601. /**
  124602. * Update trailing mesh geometry.
  124603. */
  124604. update(): void;
  124605. /**
  124606. * Returns a new TrailMesh object.
  124607. * @param name is a string, the name given to the new mesh
  124608. * @param newGenerator use new generator object for cloned trail mesh
  124609. * @returns a new mesh
  124610. */
  124611. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124612. /**
  124613. * Serializes this trail mesh
  124614. * @param serializationObject object to write serialization to
  124615. */
  124616. serialize(serializationObject: any): void;
  124617. /**
  124618. * Parses a serialized trail mesh
  124619. * @param parsedMesh the serialized mesh
  124620. * @param scene the scene to create the trail mesh in
  124621. * @returns the created trail mesh
  124622. */
  124623. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124624. }
  124625. }
  124626. declare module BABYLON {
  124627. /**
  124628. * Class containing static functions to help procedurally build meshes
  124629. */
  124630. export class TiledBoxBuilder {
  124631. /**
  124632. * Creates a box mesh
  124633. * 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)
  124634. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124638. * @param name defines the name of the mesh
  124639. * @param options defines the options used to create the mesh
  124640. * @param scene defines the hosting scene
  124641. * @returns the box mesh
  124642. */
  124643. static CreateTiledBox(name: string, options: {
  124644. pattern?: number;
  124645. width?: number;
  124646. height?: number;
  124647. depth?: number;
  124648. tileSize?: number;
  124649. tileWidth?: number;
  124650. tileHeight?: number;
  124651. alignHorizontal?: number;
  124652. alignVertical?: number;
  124653. faceUV?: Vector4[];
  124654. faceColors?: Color4[];
  124655. sideOrientation?: number;
  124656. updatable?: boolean;
  124657. }, scene?: Nullable<Scene>): Mesh;
  124658. }
  124659. }
  124660. declare module BABYLON {
  124661. /**
  124662. * Class containing static functions to help procedurally build meshes
  124663. */
  124664. export class TorusKnotBuilder {
  124665. /**
  124666. * Creates a torus knot mesh
  124667. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124668. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124669. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124670. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124674. * @param name defines the name of the mesh
  124675. * @param options defines the options used to create the mesh
  124676. * @param scene defines the hosting scene
  124677. * @returns the torus knot mesh
  124678. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124679. */
  124680. static CreateTorusKnot(name: string, options: {
  124681. radius?: number;
  124682. tube?: number;
  124683. radialSegments?: number;
  124684. tubularSegments?: number;
  124685. p?: number;
  124686. q?: number;
  124687. updatable?: boolean;
  124688. sideOrientation?: number;
  124689. frontUVs?: Vector4;
  124690. backUVs?: Vector4;
  124691. }, scene: any): Mesh;
  124692. }
  124693. }
  124694. declare module BABYLON {
  124695. /**
  124696. * Polygon
  124697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124698. */
  124699. export class Polygon {
  124700. /**
  124701. * Creates a rectangle
  124702. * @param xmin bottom X coord
  124703. * @param ymin bottom Y coord
  124704. * @param xmax top X coord
  124705. * @param ymax top Y coord
  124706. * @returns points that make the resulting rectation
  124707. */
  124708. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124709. /**
  124710. * Creates a circle
  124711. * @param radius radius of circle
  124712. * @param cx scale in x
  124713. * @param cy scale in y
  124714. * @param numberOfSides number of sides that make up the circle
  124715. * @returns points that make the resulting circle
  124716. */
  124717. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124718. /**
  124719. * Creates a polygon from input string
  124720. * @param input Input polygon data
  124721. * @returns the parsed points
  124722. */
  124723. static Parse(input: string): Vector2[];
  124724. /**
  124725. * Starts building a polygon from x and y coordinates
  124726. * @param x x coordinate
  124727. * @param y y coordinate
  124728. * @returns the started path2
  124729. */
  124730. static StartingAt(x: number, y: number): Path2;
  124731. }
  124732. /**
  124733. * Builds a polygon
  124734. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124735. */
  124736. export class PolygonMeshBuilder {
  124737. private _points;
  124738. private _outlinepoints;
  124739. private _holes;
  124740. private _name;
  124741. private _scene;
  124742. private _epoints;
  124743. private _eholes;
  124744. private _addToepoint;
  124745. /**
  124746. * Babylon reference to the earcut plugin.
  124747. */
  124748. bjsEarcut: any;
  124749. /**
  124750. * Creates a PolygonMeshBuilder
  124751. * @param name name of the builder
  124752. * @param contours Path of the polygon
  124753. * @param scene scene to add to when creating the mesh
  124754. * @param earcutInjection can be used to inject your own earcut reference
  124755. */
  124756. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124757. /**
  124758. * Adds a whole within the polygon
  124759. * @param hole Array of points defining the hole
  124760. * @returns this
  124761. */
  124762. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124763. /**
  124764. * Creates the polygon
  124765. * @param updatable If the mesh should be updatable
  124766. * @param depth The depth of the mesh created
  124767. * @returns the created mesh
  124768. */
  124769. build(updatable?: boolean, depth?: number): Mesh;
  124770. /**
  124771. * Creates the polygon
  124772. * @param depth The depth of the mesh created
  124773. * @returns the created VertexData
  124774. */
  124775. buildVertexData(depth?: number): VertexData;
  124776. /**
  124777. * Adds a side to the polygon
  124778. * @param positions points that make the polygon
  124779. * @param normals normals of the polygon
  124780. * @param uvs uvs of the polygon
  124781. * @param indices indices of the polygon
  124782. * @param bounds bounds of the polygon
  124783. * @param points points of the polygon
  124784. * @param depth depth of the polygon
  124785. * @param flip flip of the polygon
  124786. */
  124787. private addSide;
  124788. }
  124789. }
  124790. declare module BABYLON {
  124791. /**
  124792. * Class containing static functions to help procedurally build meshes
  124793. */
  124794. export class PolygonBuilder {
  124795. /**
  124796. * Creates a polygon mesh
  124797. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124798. * * 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
  124799. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124802. * * Remember you can only change the shape positions, not their number when updating a polygon
  124803. * @param name defines the name of the mesh
  124804. * @param options defines the options used to create the mesh
  124805. * @param scene defines the hosting scene
  124806. * @param earcutInjection can be used to inject your own earcut reference
  124807. * @returns the polygon mesh
  124808. */
  124809. static CreatePolygon(name: string, options: {
  124810. shape: Vector3[];
  124811. holes?: Vector3[][];
  124812. depth?: number;
  124813. faceUV?: Vector4[];
  124814. faceColors?: Color4[];
  124815. updatable?: boolean;
  124816. sideOrientation?: number;
  124817. frontUVs?: Vector4;
  124818. backUVs?: Vector4;
  124819. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124820. /**
  124821. * Creates an extruded polygon mesh, with depth in the Y direction.
  124822. * * 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)
  124823. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124824. * @param name defines the name of the mesh
  124825. * @param options defines the options used to create the mesh
  124826. * @param scene defines the hosting scene
  124827. * @param earcutInjection can be used to inject your own earcut reference
  124828. * @returns the polygon mesh
  124829. */
  124830. static ExtrudePolygon(name: string, options: {
  124831. shape: Vector3[];
  124832. holes?: Vector3[][];
  124833. depth?: number;
  124834. faceUV?: Vector4[];
  124835. faceColors?: Color4[];
  124836. updatable?: boolean;
  124837. sideOrientation?: number;
  124838. frontUVs?: Vector4;
  124839. backUVs?: Vector4;
  124840. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124841. }
  124842. }
  124843. declare module BABYLON {
  124844. /**
  124845. * Class containing static functions to help procedurally build meshes
  124846. */
  124847. export class LatheBuilder {
  124848. /**
  124849. * Creates lathe mesh.
  124850. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124851. * * 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
  124852. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124853. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124854. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124855. * * 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
  124856. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124857. * * 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
  124858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124860. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124862. * @param name defines the name of the mesh
  124863. * @param options defines the options used to create the mesh
  124864. * @param scene defines the hosting scene
  124865. * @returns the lathe mesh
  124866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124867. */
  124868. static CreateLathe(name: string, options: {
  124869. shape: Vector3[];
  124870. radius?: number;
  124871. tessellation?: number;
  124872. clip?: number;
  124873. arc?: number;
  124874. closed?: boolean;
  124875. updatable?: boolean;
  124876. sideOrientation?: number;
  124877. frontUVs?: Vector4;
  124878. backUVs?: Vector4;
  124879. cap?: number;
  124880. invertUV?: boolean;
  124881. }, scene?: Nullable<Scene>): Mesh;
  124882. }
  124883. }
  124884. declare module BABYLON {
  124885. /**
  124886. * Class containing static functions to help procedurally build meshes
  124887. */
  124888. export class TiledPlaneBuilder {
  124889. /**
  124890. * Creates a tiled plane mesh
  124891. * * The parameter `pattern` will, depending on value, do nothing or
  124892. * * * flip (reflect about central vertical) alternate tiles across and up
  124893. * * * flip every tile on alternate rows
  124894. * * * rotate (180 degs) alternate tiles across and up
  124895. * * * rotate every tile on alternate rows
  124896. * * * flip and rotate alternate tiles across and up
  124897. * * * flip and rotate every tile on alternate rows
  124898. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124899. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124901. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124902. * * 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)
  124903. * * 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)
  124904. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124905. * @param name defines the name of the mesh
  124906. * @param options defines the options used to create the mesh
  124907. * @param scene defines the hosting scene
  124908. * @returns the box mesh
  124909. */
  124910. static CreateTiledPlane(name: string, options: {
  124911. pattern?: number;
  124912. tileSize?: number;
  124913. tileWidth?: number;
  124914. tileHeight?: number;
  124915. size?: number;
  124916. width?: number;
  124917. height?: number;
  124918. alignHorizontal?: number;
  124919. alignVertical?: number;
  124920. sideOrientation?: number;
  124921. frontUVs?: Vector4;
  124922. backUVs?: Vector4;
  124923. updatable?: boolean;
  124924. }, scene?: Nullable<Scene>): Mesh;
  124925. }
  124926. }
  124927. declare module BABYLON {
  124928. /**
  124929. * Class containing static functions to help procedurally build meshes
  124930. */
  124931. export class TubeBuilder {
  124932. /**
  124933. * Creates a tube mesh.
  124934. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124935. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124936. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124937. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124938. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124939. * * 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)
  124940. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124941. * * 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
  124942. * * 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
  124943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124947. * @param name defines the name of the mesh
  124948. * @param options defines the options used to create the mesh
  124949. * @param scene defines the hosting scene
  124950. * @returns the tube mesh
  124951. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124952. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124953. */
  124954. static CreateTube(name: string, options: {
  124955. path: Vector3[];
  124956. radius?: number;
  124957. tessellation?: number;
  124958. radiusFunction?: {
  124959. (i: number, distance: number): number;
  124960. };
  124961. cap?: number;
  124962. arc?: number;
  124963. updatable?: boolean;
  124964. sideOrientation?: number;
  124965. frontUVs?: Vector4;
  124966. backUVs?: Vector4;
  124967. instance?: Mesh;
  124968. invertUV?: boolean;
  124969. }, scene?: Nullable<Scene>): Mesh;
  124970. }
  124971. }
  124972. declare module BABYLON {
  124973. /**
  124974. * Class containing static functions to help procedurally build meshes
  124975. */
  124976. export class IcoSphereBuilder {
  124977. /**
  124978. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124979. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124980. * * 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`)
  124981. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124982. * * 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
  124983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124986. * @param name defines the name of the mesh
  124987. * @param options defines the options used to create the mesh
  124988. * @param scene defines the hosting scene
  124989. * @returns the icosahedron mesh
  124990. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124991. */
  124992. static CreateIcoSphere(name: string, options: {
  124993. radius?: number;
  124994. radiusX?: number;
  124995. radiusY?: number;
  124996. radiusZ?: number;
  124997. flat?: boolean;
  124998. subdivisions?: number;
  124999. sideOrientation?: number;
  125000. frontUVs?: Vector4;
  125001. backUVs?: Vector4;
  125002. updatable?: boolean;
  125003. }, scene?: Nullable<Scene>): Mesh;
  125004. }
  125005. }
  125006. declare module BABYLON {
  125007. /**
  125008. * Class containing static functions to help procedurally build meshes
  125009. */
  125010. export class DecalBuilder {
  125011. /**
  125012. * Creates a decal mesh.
  125013. * 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
  125014. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125015. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125016. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125017. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125018. * @param name defines the name of the mesh
  125019. * @param sourceMesh defines the mesh where the decal must be applied
  125020. * @param options defines the options used to create the mesh
  125021. * @param scene defines the hosting scene
  125022. * @returns the decal mesh
  125023. * @see https://doc.babylonjs.com/how_to/decals
  125024. */
  125025. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125026. position?: Vector3;
  125027. normal?: Vector3;
  125028. size?: Vector3;
  125029. angle?: number;
  125030. }): Mesh;
  125031. }
  125032. }
  125033. declare module BABYLON {
  125034. /**
  125035. * Class containing static functions to help procedurally build meshes
  125036. */
  125037. export class MeshBuilder {
  125038. /**
  125039. * Creates a box mesh
  125040. * * The parameter `size` sets the size (float) of each box side (default 1)
  125041. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125042. * * 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)
  125043. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125047. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125048. * @param name defines the name of the mesh
  125049. * @param options defines the options used to create the mesh
  125050. * @param scene defines the hosting scene
  125051. * @returns the box mesh
  125052. */
  125053. static CreateBox(name: string, options: {
  125054. size?: number;
  125055. width?: number;
  125056. height?: number;
  125057. depth?: number;
  125058. faceUV?: Vector4[];
  125059. faceColors?: Color4[];
  125060. sideOrientation?: number;
  125061. frontUVs?: Vector4;
  125062. backUVs?: Vector4;
  125063. updatable?: boolean;
  125064. }, scene?: Nullable<Scene>): Mesh;
  125065. /**
  125066. * Creates a tiled box mesh
  125067. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125069. * @param name defines the name of the mesh
  125070. * @param options defines the options used to create the mesh
  125071. * @param scene defines the hosting scene
  125072. * @returns the tiled box mesh
  125073. */
  125074. static CreateTiledBox(name: string, options: {
  125075. pattern?: number;
  125076. size?: number;
  125077. width?: number;
  125078. height?: number;
  125079. depth: number;
  125080. tileSize?: number;
  125081. tileWidth?: number;
  125082. tileHeight?: number;
  125083. faceUV?: Vector4[];
  125084. faceColors?: Color4[];
  125085. alignHorizontal?: number;
  125086. alignVertical?: number;
  125087. sideOrientation?: number;
  125088. updatable?: boolean;
  125089. }, scene?: Nullable<Scene>): Mesh;
  125090. /**
  125091. * Creates a sphere mesh
  125092. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125093. * * 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`)
  125094. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125095. * * 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
  125096. * * 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)
  125097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125100. * @param name defines the name of the mesh
  125101. * @param options defines the options used to create the mesh
  125102. * @param scene defines the hosting scene
  125103. * @returns the sphere mesh
  125104. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125105. */
  125106. static CreateSphere(name: string, options: {
  125107. segments?: number;
  125108. diameter?: number;
  125109. diameterX?: number;
  125110. diameterY?: number;
  125111. diameterZ?: number;
  125112. arc?: number;
  125113. slice?: number;
  125114. sideOrientation?: number;
  125115. frontUVs?: Vector4;
  125116. backUVs?: Vector4;
  125117. updatable?: boolean;
  125118. }, scene?: Nullable<Scene>): Mesh;
  125119. /**
  125120. * Creates a plane polygonal mesh. By default, this is a disc
  125121. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125122. * * 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
  125123. * * 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
  125124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125127. * @param name defines the name of the mesh
  125128. * @param options defines the options used to create the mesh
  125129. * @param scene defines the hosting scene
  125130. * @returns the plane polygonal mesh
  125131. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125132. */
  125133. static CreateDisc(name: string, options: {
  125134. radius?: number;
  125135. tessellation?: number;
  125136. arc?: number;
  125137. updatable?: boolean;
  125138. sideOrientation?: number;
  125139. frontUVs?: Vector4;
  125140. backUVs?: Vector4;
  125141. }, scene?: Nullable<Scene>): Mesh;
  125142. /**
  125143. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125144. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125145. * * 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`)
  125146. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125147. * * 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
  125148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125151. * @param name defines the name of the mesh
  125152. * @param options defines the options used to create the mesh
  125153. * @param scene defines the hosting scene
  125154. * @returns the icosahedron mesh
  125155. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125156. */
  125157. static CreateIcoSphere(name: string, options: {
  125158. radius?: number;
  125159. radiusX?: number;
  125160. radiusY?: number;
  125161. radiusZ?: number;
  125162. flat?: boolean;
  125163. subdivisions?: number;
  125164. sideOrientation?: number;
  125165. frontUVs?: Vector4;
  125166. backUVs?: Vector4;
  125167. updatable?: boolean;
  125168. }, scene?: Nullable<Scene>): Mesh;
  125169. /**
  125170. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125171. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125172. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125173. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125174. * * 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
  125175. * * 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
  125176. * * 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
  125177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125180. * * 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
  125181. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125182. * * 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
  125183. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125185. * @param name defines the name of the mesh
  125186. * @param options defines the options used to create the mesh
  125187. * @param scene defines the hosting scene
  125188. * @returns the ribbon mesh
  125189. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125191. */
  125192. static CreateRibbon(name: string, options: {
  125193. pathArray: Vector3[][];
  125194. closeArray?: boolean;
  125195. closePath?: boolean;
  125196. offset?: number;
  125197. updatable?: boolean;
  125198. sideOrientation?: number;
  125199. frontUVs?: Vector4;
  125200. backUVs?: Vector4;
  125201. instance?: Mesh;
  125202. invertUV?: boolean;
  125203. uvs?: Vector2[];
  125204. colors?: Color4[];
  125205. }, scene?: Nullable<Scene>): Mesh;
  125206. /**
  125207. * Creates a cylinder or a cone mesh
  125208. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125209. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125210. * * 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.
  125211. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125212. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125213. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125214. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125215. * * 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).
  125216. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125217. * * 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).
  125218. * * 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
  125219. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125220. * * 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
  125221. * * 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.
  125222. * * If `enclose` is false, a ring surface is one element.
  125223. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125224. * * 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
  125225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125228. * @param name defines the name of the mesh
  125229. * @param options defines the options used to create the mesh
  125230. * @param scene defines the hosting scene
  125231. * @returns the cylinder mesh
  125232. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125233. */
  125234. static CreateCylinder(name: string, options: {
  125235. height?: number;
  125236. diameterTop?: number;
  125237. diameterBottom?: number;
  125238. diameter?: number;
  125239. tessellation?: number;
  125240. subdivisions?: number;
  125241. arc?: number;
  125242. faceColors?: Color4[];
  125243. faceUV?: Vector4[];
  125244. updatable?: boolean;
  125245. hasRings?: boolean;
  125246. enclose?: boolean;
  125247. cap?: number;
  125248. sideOrientation?: number;
  125249. frontUVs?: Vector4;
  125250. backUVs?: Vector4;
  125251. }, scene?: Nullable<Scene>): Mesh;
  125252. /**
  125253. * Creates a torus mesh
  125254. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125255. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125256. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125260. * @param name defines the name of the mesh
  125261. * @param options defines the options used to create the mesh
  125262. * @param scene defines the hosting scene
  125263. * @returns the torus mesh
  125264. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125265. */
  125266. static CreateTorus(name: string, options: {
  125267. diameter?: number;
  125268. thickness?: number;
  125269. tessellation?: number;
  125270. updatable?: boolean;
  125271. sideOrientation?: number;
  125272. frontUVs?: Vector4;
  125273. backUVs?: Vector4;
  125274. }, scene?: Nullable<Scene>): Mesh;
  125275. /**
  125276. * Creates a torus knot mesh
  125277. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125278. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125279. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125280. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125284. * @param name defines the name of the mesh
  125285. * @param options defines the options used to create the mesh
  125286. * @param scene defines the hosting scene
  125287. * @returns the torus knot mesh
  125288. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125289. */
  125290. static CreateTorusKnot(name: string, options: {
  125291. radius?: number;
  125292. tube?: number;
  125293. radialSegments?: number;
  125294. tubularSegments?: number;
  125295. p?: number;
  125296. q?: number;
  125297. updatable?: boolean;
  125298. sideOrientation?: number;
  125299. frontUVs?: Vector4;
  125300. backUVs?: Vector4;
  125301. }, scene?: Nullable<Scene>): Mesh;
  125302. /**
  125303. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125304. * * 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
  125305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125306. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125307. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125308. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125310. * * 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
  125311. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125314. * @param name defines the name of the new line system
  125315. * @param options defines the options used to create the line system
  125316. * @param scene defines the hosting scene
  125317. * @returns a new line system mesh
  125318. */
  125319. static CreateLineSystem(name: string, options: {
  125320. lines: Vector3[][];
  125321. updatable?: boolean;
  125322. instance?: Nullable<LinesMesh>;
  125323. colors?: Nullable<Color4[][]>;
  125324. useVertexAlpha?: boolean;
  125325. }, scene: Nullable<Scene>): LinesMesh;
  125326. /**
  125327. * Creates a line mesh
  125328. * 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
  125329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125330. * * The parameter `points` is an array successive Vector3
  125331. * * 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
  125332. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125334. * * When updating an instance, remember that only point positions can change, not the number of points
  125335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125337. * @param name defines the name of the new line system
  125338. * @param options defines the options used to create the line system
  125339. * @param scene defines the hosting scene
  125340. * @returns a new line mesh
  125341. */
  125342. static CreateLines(name: string, options: {
  125343. points: Vector3[];
  125344. updatable?: boolean;
  125345. instance?: Nullable<LinesMesh>;
  125346. colors?: Color4[];
  125347. useVertexAlpha?: boolean;
  125348. }, scene?: Nullable<Scene>): LinesMesh;
  125349. /**
  125350. * Creates a dashed line mesh
  125351. * * 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
  125352. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125353. * * The parameter `points` is an array successive Vector3
  125354. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125355. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125356. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125357. * * 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
  125358. * * When updating an instance, remember that only point positions can change, not the number of points
  125359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125360. * @param name defines the name of the mesh
  125361. * @param options defines the options used to create the mesh
  125362. * @param scene defines the hosting scene
  125363. * @returns the dashed line mesh
  125364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125365. */
  125366. static CreateDashedLines(name: string, options: {
  125367. points: Vector3[];
  125368. dashSize?: number;
  125369. gapSize?: number;
  125370. dashNb?: number;
  125371. updatable?: boolean;
  125372. instance?: LinesMesh;
  125373. }, scene?: Nullable<Scene>): LinesMesh;
  125374. /**
  125375. * 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.
  125376. * * 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.
  125377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125378. * * 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.
  125379. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125380. * * 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
  125381. * * 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
  125382. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125387. * @param name defines the name of the mesh
  125388. * @param options defines the options used to create the mesh
  125389. * @param scene defines the hosting scene
  125390. * @returns the extruded shape mesh
  125391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125393. */
  125394. static ExtrudeShape(name: string, options: {
  125395. shape: Vector3[];
  125396. path: Vector3[];
  125397. scale?: number;
  125398. rotation?: number;
  125399. cap?: number;
  125400. updatable?: boolean;
  125401. sideOrientation?: number;
  125402. frontUVs?: Vector4;
  125403. backUVs?: Vector4;
  125404. instance?: Mesh;
  125405. invertUV?: boolean;
  125406. }, scene?: Nullable<Scene>): Mesh;
  125407. /**
  125408. * Creates an custom extruded shape mesh.
  125409. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125410. * * 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.
  125411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125412. * * 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
  125413. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125414. * * 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
  125415. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125416. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125417. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125418. * * 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
  125419. * * 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
  125420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125425. * @param name defines the name of the mesh
  125426. * @param options defines the options used to create the mesh
  125427. * @param scene defines the hosting scene
  125428. * @returns the custom extruded shape mesh
  125429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125432. */
  125433. static ExtrudeShapeCustom(name: string, options: {
  125434. shape: Vector3[];
  125435. path: Vector3[];
  125436. scaleFunction?: any;
  125437. rotationFunction?: any;
  125438. ribbonCloseArray?: boolean;
  125439. ribbonClosePath?: boolean;
  125440. cap?: number;
  125441. updatable?: boolean;
  125442. sideOrientation?: number;
  125443. frontUVs?: Vector4;
  125444. backUVs?: Vector4;
  125445. instance?: Mesh;
  125446. invertUV?: boolean;
  125447. }, scene?: Nullable<Scene>): Mesh;
  125448. /**
  125449. * Creates lathe mesh.
  125450. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125451. * * 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
  125452. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125453. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125454. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125455. * * 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
  125456. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125457. * * 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
  125458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125462. * @param name defines the name of the mesh
  125463. * @param options defines the options used to create the mesh
  125464. * @param scene defines the hosting scene
  125465. * @returns the lathe mesh
  125466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125467. */
  125468. static CreateLathe(name: string, options: {
  125469. shape: Vector3[];
  125470. radius?: number;
  125471. tessellation?: number;
  125472. clip?: number;
  125473. arc?: number;
  125474. closed?: boolean;
  125475. updatable?: boolean;
  125476. sideOrientation?: number;
  125477. frontUVs?: Vector4;
  125478. backUVs?: Vector4;
  125479. cap?: number;
  125480. invertUV?: boolean;
  125481. }, scene?: Nullable<Scene>): Mesh;
  125482. /**
  125483. * Creates a tiled plane mesh
  125484. * * You can set a limited pattern arrangement with the tiles
  125485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125488. * @param name defines the name of the mesh
  125489. * @param options defines the options used to create the mesh
  125490. * @param scene defines the hosting scene
  125491. * @returns the plane mesh
  125492. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125493. */
  125494. static CreateTiledPlane(name: string, options: {
  125495. pattern?: number;
  125496. tileSize?: number;
  125497. tileWidth?: number;
  125498. tileHeight?: number;
  125499. size?: number;
  125500. width?: number;
  125501. height?: number;
  125502. alignHorizontal?: number;
  125503. alignVertical?: number;
  125504. sideOrientation?: number;
  125505. frontUVs?: Vector4;
  125506. backUVs?: Vector4;
  125507. updatable?: boolean;
  125508. }, scene?: Nullable<Scene>): Mesh;
  125509. /**
  125510. * Creates a plane mesh
  125511. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125512. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125513. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125517. * @param name defines the name of the mesh
  125518. * @param options defines the options used to create the mesh
  125519. * @param scene defines the hosting scene
  125520. * @returns the plane mesh
  125521. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125522. */
  125523. static CreatePlane(name: string, options: {
  125524. size?: number;
  125525. width?: number;
  125526. height?: number;
  125527. sideOrientation?: number;
  125528. frontUVs?: Vector4;
  125529. backUVs?: Vector4;
  125530. updatable?: boolean;
  125531. sourcePlane?: Plane;
  125532. }, scene?: Nullable<Scene>): Mesh;
  125533. /**
  125534. * Creates a ground mesh
  125535. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125536. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125538. * @param name defines the name of the mesh
  125539. * @param options defines the options used to create the mesh
  125540. * @param scene defines the hosting scene
  125541. * @returns the ground mesh
  125542. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125543. */
  125544. static CreateGround(name: string, options: {
  125545. width?: number;
  125546. height?: number;
  125547. subdivisions?: number;
  125548. subdivisionsX?: number;
  125549. subdivisionsY?: number;
  125550. updatable?: boolean;
  125551. }, scene?: Nullable<Scene>): Mesh;
  125552. /**
  125553. * Creates a tiled ground mesh
  125554. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125555. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125556. * * 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
  125557. * * 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
  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 tiled ground mesh
  125563. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125564. */
  125565. static CreateTiledGround(name: string, options: {
  125566. xmin: number;
  125567. zmin: number;
  125568. xmax: number;
  125569. zmax: number;
  125570. subdivisions?: {
  125571. w: number;
  125572. h: number;
  125573. };
  125574. precision?: {
  125575. w: number;
  125576. h: number;
  125577. };
  125578. updatable?: boolean;
  125579. }, scene?: Nullable<Scene>): Mesh;
  125580. /**
  125581. * Creates a ground mesh from a height map
  125582. * * The parameter `url` sets the URL of the height map image resource.
  125583. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125584. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125585. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125586. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125587. * * 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.
  125588. * * 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).
  125589. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125591. * @param name defines the name of the mesh
  125592. * @param url defines the url to the height map
  125593. * @param options defines the options used to create the mesh
  125594. * @param scene defines the hosting scene
  125595. * @returns the ground mesh
  125596. * @see https://doc.babylonjs.com/babylon101/height_map
  125597. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125598. */
  125599. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125600. width?: number;
  125601. height?: number;
  125602. subdivisions?: number;
  125603. minHeight?: number;
  125604. maxHeight?: number;
  125605. colorFilter?: Color3;
  125606. alphaFilter?: number;
  125607. updatable?: boolean;
  125608. onReady?: (mesh: GroundMesh) => void;
  125609. }, scene?: Nullable<Scene>): GroundMesh;
  125610. /**
  125611. * Creates a polygon mesh
  125612. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125613. * * 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
  125614. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125617. * * Remember you can only change the shape positions, not their number when updating a polygon
  125618. * @param name defines the name of the mesh
  125619. * @param options defines the options used to create the mesh
  125620. * @param scene defines the hosting scene
  125621. * @param earcutInjection can be used to inject your own earcut reference
  125622. * @returns the polygon mesh
  125623. */
  125624. static CreatePolygon(name: string, options: {
  125625. shape: Vector3[];
  125626. holes?: Vector3[][];
  125627. depth?: number;
  125628. faceUV?: Vector4[];
  125629. faceColors?: Color4[];
  125630. updatable?: boolean;
  125631. sideOrientation?: number;
  125632. frontUVs?: Vector4;
  125633. backUVs?: Vector4;
  125634. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125635. /**
  125636. * Creates an extruded polygon mesh, with depth in the Y direction.
  125637. * * 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)
  125638. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125639. * @param name defines the name of the mesh
  125640. * @param options defines the options used to create the mesh
  125641. * @param scene defines the hosting scene
  125642. * @param earcutInjection can be used to inject your own earcut reference
  125643. * @returns the polygon mesh
  125644. */
  125645. static ExtrudePolygon(name: string, options: {
  125646. shape: Vector3[];
  125647. holes?: Vector3[][];
  125648. depth?: number;
  125649. faceUV?: Vector4[];
  125650. faceColors?: Color4[];
  125651. updatable?: boolean;
  125652. sideOrientation?: number;
  125653. frontUVs?: Vector4;
  125654. backUVs?: Vector4;
  125655. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125656. /**
  125657. * Creates a tube mesh.
  125658. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125659. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125660. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125661. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125662. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125663. * * 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)
  125664. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125665. * * 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
  125666. * * 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
  125667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125671. * @param name defines the name of the mesh
  125672. * @param options defines the options used to create the mesh
  125673. * @param scene defines the hosting scene
  125674. * @returns the tube mesh
  125675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125676. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125677. */
  125678. static CreateTube(name: string, options: {
  125679. path: Vector3[];
  125680. radius?: number;
  125681. tessellation?: number;
  125682. radiusFunction?: {
  125683. (i: number, distance: number): number;
  125684. };
  125685. cap?: number;
  125686. arc?: number;
  125687. updatable?: boolean;
  125688. sideOrientation?: number;
  125689. frontUVs?: Vector4;
  125690. backUVs?: Vector4;
  125691. instance?: Mesh;
  125692. invertUV?: boolean;
  125693. }, scene?: Nullable<Scene>): Mesh;
  125694. /**
  125695. * Creates a polyhedron mesh
  125696. * * 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
  125697. * * The parameter `size` (positive float, default 1) sets the polygon size
  125698. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125699. * * 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`
  125700. * * 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
  125701. * * 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)`)
  125702. * * 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
  125703. * * 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
  125704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125707. * @param name defines the name of the mesh
  125708. * @param options defines the options used to create the mesh
  125709. * @param scene defines the hosting scene
  125710. * @returns the polyhedron mesh
  125711. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125712. */
  125713. static CreatePolyhedron(name: string, options: {
  125714. type?: number;
  125715. size?: number;
  125716. sizeX?: number;
  125717. sizeY?: number;
  125718. sizeZ?: number;
  125719. custom?: any;
  125720. faceUV?: Vector4[];
  125721. faceColors?: Color4[];
  125722. flat?: boolean;
  125723. updatable?: boolean;
  125724. sideOrientation?: number;
  125725. frontUVs?: Vector4;
  125726. backUVs?: Vector4;
  125727. }, scene?: Nullable<Scene>): Mesh;
  125728. /**
  125729. * Creates a decal mesh.
  125730. * 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
  125731. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125732. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125733. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125734. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125735. * @param name defines the name of the mesh
  125736. * @param sourceMesh defines the mesh where the decal must be applied
  125737. * @param options defines the options used to create the mesh
  125738. * @param scene defines the hosting scene
  125739. * @returns the decal mesh
  125740. * @see https://doc.babylonjs.com/how_to/decals
  125741. */
  125742. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125743. position?: Vector3;
  125744. normal?: Vector3;
  125745. size?: Vector3;
  125746. angle?: number;
  125747. }): Mesh;
  125748. }
  125749. }
  125750. declare module BABYLON {
  125751. /**
  125752. * A simplifier interface for future simplification implementations
  125753. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125754. */
  125755. export interface ISimplifier {
  125756. /**
  125757. * Simplification of a given mesh according to the given settings.
  125758. * Since this requires computation, it is assumed that the function runs async.
  125759. * @param settings The settings of the simplification, including quality and distance
  125760. * @param successCallback A callback that will be called after the mesh was simplified.
  125761. * @param errorCallback in case of an error, this callback will be called. optional.
  125762. */
  125763. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125764. }
  125765. /**
  125766. * Expected simplification settings.
  125767. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125768. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125769. */
  125770. export interface ISimplificationSettings {
  125771. /**
  125772. * Gets or sets the expected quality
  125773. */
  125774. quality: number;
  125775. /**
  125776. * Gets or sets the distance when this optimized version should be used
  125777. */
  125778. distance: number;
  125779. /**
  125780. * Gets an already optimized mesh
  125781. */
  125782. optimizeMesh?: boolean;
  125783. }
  125784. /**
  125785. * Class used to specify simplification options
  125786. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125787. */
  125788. export class SimplificationSettings implements ISimplificationSettings {
  125789. /** expected quality */
  125790. quality: number;
  125791. /** distance when this optimized version should be used */
  125792. distance: number;
  125793. /** already optimized mesh */
  125794. optimizeMesh?: boolean | undefined;
  125795. /**
  125796. * Creates a SimplificationSettings
  125797. * @param quality expected quality
  125798. * @param distance distance when this optimized version should be used
  125799. * @param optimizeMesh already optimized mesh
  125800. */
  125801. constructor(
  125802. /** expected quality */
  125803. quality: number,
  125804. /** distance when this optimized version should be used */
  125805. distance: number,
  125806. /** already optimized mesh */
  125807. optimizeMesh?: boolean | undefined);
  125808. }
  125809. /**
  125810. * Interface used to define a simplification task
  125811. */
  125812. export interface ISimplificationTask {
  125813. /**
  125814. * Array of settings
  125815. */
  125816. settings: Array<ISimplificationSettings>;
  125817. /**
  125818. * Simplification type
  125819. */
  125820. simplificationType: SimplificationType;
  125821. /**
  125822. * Mesh to simplify
  125823. */
  125824. mesh: Mesh;
  125825. /**
  125826. * Callback called on success
  125827. */
  125828. successCallback?: () => void;
  125829. /**
  125830. * Defines if parallel processing can be used
  125831. */
  125832. parallelProcessing: boolean;
  125833. }
  125834. /**
  125835. * Queue used to order the simplification tasks
  125836. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125837. */
  125838. export class SimplificationQueue {
  125839. private _simplificationArray;
  125840. /**
  125841. * Gets a boolean indicating that the process is still running
  125842. */
  125843. running: boolean;
  125844. /**
  125845. * Creates a new queue
  125846. */
  125847. constructor();
  125848. /**
  125849. * Adds a new simplification task
  125850. * @param task defines a task to add
  125851. */
  125852. addTask(task: ISimplificationTask): void;
  125853. /**
  125854. * Execute next task
  125855. */
  125856. executeNext(): void;
  125857. /**
  125858. * Execute a simplification task
  125859. * @param task defines the task to run
  125860. */
  125861. runSimplification(task: ISimplificationTask): void;
  125862. private getSimplifier;
  125863. }
  125864. /**
  125865. * The implemented types of simplification
  125866. * At the moment only Quadratic Error Decimation is implemented
  125867. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125868. */
  125869. export enum SimplificationType {
  125870. /** Quadratic error decimation */
  125871. QUADRATIC = 0
  125872. }
  125873. }
  125874. declare module BABYLON {
  125875. interface Scene {
  125876. /** @hidden (Backing field) */
  125877. _simplificationQueue: SimplificationQueue;
  125878. /**
  125879. * Gets or sets the simplification queue attached to the scene
  125880. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125881. */
  125882. simplificationQueue: SimplificationQueue;
  125883. }
  125884. interface Mesh {
  125885. /**
  125886. * Simplify the mesh according to the given array of settings.
  125887. * Function will return immediately and will simplify async
  125888. * @param settings a collection of simplification settings
  125889. * @param parallelProcessing should all levels calculate parallel or one after the other
  125890. * @param simplificationType the type of simplification to run
  125891. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125892. * @returns the current mesh
  125893. */
  125894. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125895. }
  125896. /**
  125897. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125898. * created in a scene
  125899. */
  125900. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125901. /**
  125902. * The component name helpfull to identify the component in the list of scene components.
  125903. */
  125904. readonly name: string;
  125905. /**
  125906. * The scene the component belongs to.
  125907. */
  125908. scene: Scene;
  125909. /**
  125910. * Creates a new instance of the component for the given scene
  125911. * @param scene Defines the scene to register the component in
  125912. */
  125913. constructor(scene: Scene);
  125914. /**
  125915. * Registers the component in a given scene
  125916. */
  125917. register(): void;
  125918. /**
  125919. * Rebuilds the elements related to this component in case of
  125920. * context lost for instance.
  125921. */
  125922. rebuild(): void;
  125923. /**
  125924. * Disposes the component and the associated ressources
  125925. */
  125926. dispose(): void;
  125927. private _beforeCameraUpdate;
  125928. }
  125929. }
  125930. declare module BABYLON {
  125931. /**
  125932. * Navigation plugin interface to add navigation constrained by a navigation mesh
  125933. */
  125934. export interface INavigationEnginePlugin {
  125935. /**
  125936. * plugin name
  125937. */
  125938. name: string;
  125939. /**
  125940. * Creates a navigation mesh
  125941. * @param meshes array of all the geometry used to compute the navigatio mesh
  125942. * @param parameters bunch of parameters used to filter geometry
  125943. */
  125944. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125945. /**
  125946. * Create a navigation mesh debug mesh
  125947. * @param scene is where the mesh will be added
  125948. * @returns debug display mesh
  125949. */
  125950. createDebugNavMesh(scene: Scene): Mesh;
  125951. /**
  125952. * Get a navigation mesh constrained position, closest to the parameter position
  125953. * @param position world position
  125954. * @returns the closest point to position constrained by the navigation mesh
  125955. */
  125956. getClosestPoint(position: Vector3): Vector3;
  125957. /**
  125958. * Get a navigation mesh constrained position, within a particular radius
  125959. * @param position world position
  125960. * @param maxRadius the maximum distance to the constrained world position
  125961. * @returns the closest point to position constrained by the navigation mesh
  125962. */
  125963. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125964. /**
  125965. * Compute the final position from a segment made of destination-position
  125966. * @param position world position
  125967. * @param destination world position
  125968. * @returns the resulting point along the navmesh
  125969. */
  125970. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125971. /**
  125972. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125973. * @param start world position
  125974. * @param end world position
  125975. * @returns array containing world position composing the path
  125976. */
  125977. computePath(start: Vector3, end: Vector3): Vector3[];
  125978. /**
  125979. * If this plugin is supported
  125980. * @returns true if plugin is supported
  125981. */
  125982. isSupported(): boolean;
  125983. /**
  125984. * Create a new Crowd so you can add agents
  125985. * @param maxAgents the maximum agent count in the crowd
  125986. * @param maxAgentRadius the maximum radius an agent can have
  125987. * @param scene to attach the crowd to
  125988. * @returns the crowd you can add agents to
  125989. */
  125990. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125991. /**
  125992. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125993. * The queries will try to find a solution within those bounds
  125994. * default is (1,1,1)
  125995. * @param extent x,y,z value that define the extent around the queries point of reference
  125996. */
  125997. setDefaultQueryExtent(extent: Vector3): void;
  125998. /**
  125999. * Get the Bounding box extent specified by setDefaultQueryExtent
  126000. * @returns the box extent values
  126001. */
  126002. getDefaultQueryExtent(): Vector3;
  126003. /**
  126004. * Release all resources
  126005. */
  126006. dispose(): void;
  126007. }
  126008. /**
  126009. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126010. */
  126011. export interface ICrowd {
  126012. /**
  126013. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126014. * You can attach anything to that node. The node position is updated in the scene update tick.
  126015. * @param pos world position that will be constrained by the navigation mesh
  126016. * @param parameters agent parameters
  126017. * @param transform hooked to the agent that will be update by the scene
  126018. * @returns agent index
  126019. */
  126020. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126021. /**
  126022. * Returns the agent position in world space
  126023. * @param index agent index returned by addAgent
  126024. * @returns world space position
  126025. */
  126026. getAgentPosition(index: number): Vector3;
  126027. /**
  126028. * Gets the agent velocity in world space
  126029. * @param index agent index returned by addAgent
  126030. * @returns world space velocity
  126031. */
  126032. getAgentVelocity(index: number): Vector3;
  126033. /**
  126034. * remove a particular agent previously created
  126035. * @param index agent index returned by addAgent
  126036. */
  126037. removeAgent(index: number): void;
  126038. /**
  126039. * get the list of all agents attached to this crowd
  126040. * @returns list of agent indices
  126041. */
  126042. getAgents(): number[];
  126043. /**
  126044. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126045. * @param deltaTime in seconds
  126046. */
  126047. update(deltaTime: number): void;
  126048. /**
  126049. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126050. * @param index agent index returned by addAgent
  126051. * @param destination targeted world position
  126052. */
  126053. agentGoto(index: number, destination: Vector3): void;
  126054. /**
  126055. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126056. * The queries will try to find a solution within those bounds
  126057. * default is (1,1,1)
  126058. * @param extent x,y,z value that define the extent around the queries point of reference
  126059. */
  126060. setDefaultQueryExtent(extent: Vector3): void;
  126061. /**
  126062. * Get the Bounding box extent specified by setDefaultQueryExtent
  126063. * @returns the box extent values
  126064. */
  126065. getDefaultQueryExtent(): Vector3;
  126066. /**
  126067. * Release all resources
  126068. */
  126069. dispose(): void;
  126070. }
  126071. /**
  126072. * Configures an agent
  126073. */
  126074. export interface IAgentParameters {
  126075. /**
  126076. * Agent radius. [Limit: >= 0]
  126077. */
  126078. radius: number;
  126079. /**
  126080. * Agent height. [Limit: > 0]
  126081. */
  126082. height: number;
  126083. /**
  126084. * Maximum allowed acceleration. [Limit: >= 0]
  126085. */
  126086. maxAcceleration: number;
  126087. /**
  126088. * Maximum allowed speed. [Limit: >= 0]
  126089. */
  126090. maxSpeed: number;
  126091. /**
  126092. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126093. */
  126094. collisionQueryRange: number;
  126095. /**
  126096. * The path visibility optimization range. [Limit: > 0]
  126097. */
  126098. pathOptimizationRange: number;
  126099. /**
  126100. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126101. */
  126102. separationWeight: number;
  126103. }
  126104. /**
  126105. * Configures the navigation mesh creation
  126106. */
  126107. export interface INavMeshParameters {
  126108. /**
  126109. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126110. */
  126111. cs: number;
  126112. /**
  126113. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126114. */
  126115. ch: number;
  126116. /**
  126117. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126118. */
  126119. walkableSlopeAngle: number;
  126120. /**
  126121. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126122. * be considered walkable. [Limit: >= 3] [Units: vx]
  126123. */
  126124. walkableHeight: number;
  126125. /**
  126126. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126127. */
  126128. walkableClimb: number;
  126129. /**
  126130. * The distance to erode/shrink the walkable area of the heightfield away from
  126131. * obstructions. [Limit: >=0] [Units: vx]
  126132. */
  126133. walkableRadius: number;
  126134. /**
  126135. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126136. */
  126137. maxEdgeLen: number;
  126138. /**
  126139. * The maximum distance a simplfied contour's border edges should deviate
  126140. * the original raw contour. [Limit: >=0] [Units: vx]
  126141. */
  126142. maxSimplificationError: number;
  126143. /**
  126144. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126145. */
  126146. minRegionArea: number;
  126147. /**
  126148. * Any regions with a span count smaller than this value will, if possible,
  126149. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126150. */
  126151. mergeRegionArea: number;
  126152. /**
  126153. * The maximum number of vertices allowed for polygons generated during the
  126154. * contour to polygon conversion process. [Limit: >= 3]
  126155. */
  126156. maxVertsPerPoly: number;
  126157. /**
  126158. * Sets the sampling distance to use when generating the detail mesh.
  126159. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126160. */
  126161. detailSampleDist: number;
  126162. /**
  126163. * The maximum distance the detail mesh surface should deviate from heightfield
  126164. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126165. */
  126166. detailSampleMaxError: number;
  126167. }
  126168. }
  126169. declare module BABYLON {
  126170. /**
  126171. * RecastJS navigation plugin
  126172. */
  126173. export class RecastJSPlugin implements INavigationEnginePlugin {
  126174. /**
  126175. * Reference to the Recast library
  126176. */
  126177. bjsRECAST: any;
  126178. /**
  126179. * plugin name
  126180. */
  126181. name: string;
  126182. /**
  126183. * the first navmesh created. We might extend this to support multiple navmeshes
  126184. */
  126185. navMesh: any;
  126186. /**
  126187. * Initializes the recastJS plugin
  126188. * @param recastInjection can be used to inject your own recast reference
  126189. */
  126190. constructor(recastInjection?: any);
  126191. /**
  126192. * Creates a navigation mesh
  126193. * @param meshes array of all the geometry used to compute the navigatio mesh
  126194. * @param parameters bunch of parameters used to filter geometry
  126195. */
  126196. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126197. /**
  126198. * Create a navigation mesh debug mesh
  126199. * @param scene is where the mesh will be added
  126200. * @returns debug display mesh
  126201. */
  126202. createDebugNavMesh(scene: Scene): Mesh;
  126203. /**
  126204. * Get a navigation mesh constrained position, closest to the parameter position
  126205. * @param position world position
  126206. * @returns the closest point to position constrained by the navigation mesh
  126207. */
  126208. getClosestPoint(position: Vector3): Vector3;
  126209. /**
  126210. * Get a navigation mesh constrained position, within a particular radius
  126211. * @param position world position
  126212. * @param maxRadius the maximum distance to the constrained world position
  126213. * @returns the closest point to position constrained by the navigation mesh
  126214. */
  126215. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126216. /**
  126217. * Compute the final position from a segment made of destination-position
  126218. * @param position world position
  126219. * @param destination world position
  126220. * @returns the resulting point along the navmesh
  126221. */
  126222. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126223. /**
  126224. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126225. * @param start world position
  126226. * @param end world position
  126227. * @returns array containing world position composing the path
  126228. */
  126229. computePath(start: Vector3, end: Vector3): Vector3[];
  126230. /**
  126231. * Create a new Crowd so you can add agents
  126232. * @param maxAgents the maximum agent count in the crowd
  126233. * @param maxAgentRadius the maximum radius an agent can have
  126234. * @param scene to attach the crowd to
  126235. * @returns the crowd you can add agents to
  126236. */
  126237. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126238. /**
  126239. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126240. * The queries will try to find a solution within those bounds
  126241. * default is (1,1,1)
  126242. * @param extent x,y,z value that define the extent around the queries point of reference
  126243. */
  126244. setDefaultQueryExtent(extent: Vector3): void;
  126245. /**
  126246. * Get the Bounding box extent specified by setDefaultQueryExtent
  126247. * @returns the box extent values
  126248. */
  126249. getDefaultQueryExtent(): Vector3;
  126250. /**
  126251. * Disposes
  126252. */
  126253. dispose(): void;
  126254. /**
  126255. * If this plugin is supported
  126256. * @returns true if plugin is supported
  126257. */
  126258. isSupported(): boolean;
  126259. }
  126260. /**
  126261. * Recast detour crowd implementation
  126262. */
  126263. export class RecastJSCrowd implements ICrowd {
  126264. /**
  126265. * Recast/detour plugin
  126266. */
  126267. bjsRECASTPlugin: RecastJSPlugin;
  126268. /**
  126269. * Link to the detour crowd
  126270. */
  126271. recastCrowd: any;
  126272. /**
  126273. * One transform per agent
  126274. */
  126275. transforms: TransformNode[];
  126276. /**
  126277. * All agents created
  126278. */
  126279. agents: number[];
  126280. /**
  126281. * Link to the scene is kept to unregister the crowd from the scene
  126282. */
  126283. private _scene;
  126284. /**
  126285. * Observer for crowd updates
  126286. */
  126287. private _onBeforeAnimationsObserver;
  126288. /**
  126289. * Constructor
  126290. * @param plugin recastJS plugin
  126291. * @param maxAgents the maximum agent count in the crowd
  126292. * @param maxAgentRadius the maximum radius an agent can have
  126293. * @param scene to attach the crowd to
  126294. * @returns the crowd you can add agents to
  126295. */
  126296. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126297. /**
  126298. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126299. * You can attach anything to that node. The node position is updated in the scene update tick.
  126300. * @param pos world position that will be constrained by the navigation mesh
  126301. * @param parameters agent parameters
  126302. * @param transform hooked to the agent that will be update by the scene
  126303. * @returns agent index
  126304. */
  126305. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126306. /**
  126307. * Returns the agent position in world space
  126308. * @param index agent index returned by addAgent
  126309. * @returns world space position
  126310. */
  126311. getAgentPosition(index: number): Vector3;
  126312. /**
  126313. * Returns the agent velocity in world space
  126314. * @param index agent index returned by addAgent
  126315. * @returns world space velocity
  126316. */
  126317. getAgentVelocity(index: number): Vector3;
  126318. /**
  126319. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126320. * @param index agent index returned by addAgent
  126321. * @param destination targeted world position
  126322. */
  126323. agentGoto(index: number, destination: Vector3): void;
  126324. /**
  126325. * remove a particular agent previously created
  126326. * @param index agent index returned by addAgent
  126327. */
  126328. removeAgent(index: number): void;
  126329. /**
  126330. * get the list of all agents attached to this crowd
  126331. * @returns list of agent indices
  126332. */
  126333. getAgents(): number[];
  126334. /**
  126335. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126336. * @param deltaTime in seconds
  126337. */
  126338. update(deltaTime: number): void;
  126339. /**
  126340. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126341. * The queries will try to find a solution within those bounds
  126342. * default is (1,1,1)
  126343. * @param extent x,y,z value that define the extent around the queries point of reference
  126344. */
  126345. setDefaultQueryExtent(extent: Vector3): void;
  126346. /**
  126347. * Get the Bounding box extent specified by setDefaultQueryExtent
  126348. * @returns the box extent values
  126349. */
  126350. getDefaultQueryExtent(): Vector3;
  126351. /**
  126352. * Release all resources
  126353. */
  126354. dispose(): void;
  126355. }
  126356. }
  126357. declare module BABYLON {
  126358. /**
  126359. * Class used to enable access to IndexedDB
  126360. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126361. */
  126362. export class Database implements IOfflineProvider {
  126363. private _callbackManifestChecked;
  126364. private _currentSceneUrl;
  126365. private _db;
  126366. private _enableSceneOffline;
  126367. private _enableTexturesOffline;
  126368. private _manifestVersionFound;
  126369. private _mustUpdateRessources;
  126370. private _hasReachedQuota;
  126371. private _isSupported;
  126372. private _idbFactory;
  126373. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126374. private static IsUASupportingBlobStorage;
  126375. /**
  126376. * Gets a boolean indicating if Database storate is enabled (off by default)
  126377. */
  126378. static IDBStorageEnabled: boolean;
  126379. /**
  126380. * Gets a boolean indicating if scene must be saved in the database
  126381. */
  126382. readonly enableSceneOffline: boolean;
  126383. /**
  126384. * Gets a boolean indicating if textures must be saved in the database
  126385. */
  126386. readonly enableTexturesOffline: boolean;
  126387. /**
  126388. * Creates a new Database
  126389. * @param urlToScene defines the url to load the scene
  126390. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126391. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126392. */
  126393. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126394. private static _ParseURL;
  126395. private static _ReturnFullUrlLocation;
  126396. private _checkManifestFile;
  126397. /**
  126398. * Open the database and make it available
  126399. * @param successCallback defines the callback to call on success
  126400. * @param errorCallback defines the callback to call on error
  126401. */
  126402. open(successCallback: () => void, errorCallback: () => void): void;
  126403. /**
  126404. * Loads an image from the database
  126405. * @param url defines the url to load from
  126406. * @param image defines the target DOM image
  126407. */
  126408. loadImage(url: string, image: HTMLImageElement): void;
  126409. private _loadImageFromDBAsync;
  126410. private _saveImageIntoDBAsync;
  126411. private _checkVersionFromDB;
  126412. private _loadVersionFromDBAsync;
  126413. private _saveVersionIntoDBAsync;
  126414. /**
  126415. * Loads a file from database
  126416. * @param url defines the URL to load from
  126417. * @param sceneLoaded defines a callback to call on success
  126418. * @param progressCallBack defines a callback to call when progress changed
  126419. * @param errorCallback defines a callback to call on error
  126420. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126421. */
  126422. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126423. private _loadFileAsync;
  126424. private _saveFileAsync;
  126425. /**
  126426. * Validates if xhr data is correct
  126427. * @param xhr defines the request to validate
  126428. * @param dataType defines the expected data type
  126429. * @returns true if data is correct
  126430. */
  126431. private static _ValidateXHRData;
  126432. }
  126433. }
  126434. declare module BABYLON {
  126435. /** @hidden */
  126436. export var gpuUpdateParticlesPixelShader: {
  126437. name: string;
  126438. shader: string;
  126439. };
  126440. }
  126441. declare module BABYLON {
  126442. /** @hidden */
  126443. export var gpuUpdateParticlesVertexShader: {
  126444. name: string;
  126445. shader: string;
  126446. };
  126447. }
  126448. declare module BABYLON {
  126449. /** @hidden */
  126450. export var clipPlaneFragmentDeclaration2: {
  126451. name: string;
  126452. shader: string;
  126453. };
  126454. }
  126455. declare module BABYLON {
  126456. /** @hidden */
  126457. export var gpuRenderParticlesPixelShader: {
  126458. name: string;
  126459. shader: string;
  126460. };
  126461. }
  126462. declare module BABYLON {
  126463. /** @hidden */
  126464. export var clipPlaneVertexDeclaration2: {
  126465. name: string;
  126466. shader: string;
  126467. };
  126468. }
  126469. declare module BABYLON {
  126470. /** @hidden */
  126471. export var gpuRenderParticlesVertexShader: {
  126472. name: string;
  126473. shader: string;
  126474. };
  126475. }
  126476. declare module BABYLON {
  126477. /**
  126478. * This represents a GPU particle system in Babylon
  126479. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126480. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126481. */
  126482. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126483. /**
  126484. * The layer mask we are rendering the particles through.
  126485. */
  126486. layerMask: number;
  126487. private _capacity;
  126488. private _activeCount;
  126489. private _currentActiveCount;
  126490. private _accumulatedCount;
  126491. private _renderEffect;
  126492. private _updateEffect;
  126493. private _buffer0;
  126494. private _buffer1;
  126495. private _spriteBuffer;
  126496. private _updateVAO;
  126497. private _renderVAO;
  126498. private _targetIndex;
  126499. private _sourceBuffer;
  126500. private _targetBuffer;
  126501. private _engine;
  126502. private _currentRenderId;
  126503. private _started;
  126504. private _stopped;
  126505. private _timeDelta;
  126506. private _randomTexture;
  126507. private _randomTexture2;
  126508. private _attributesStrideSize;
  126509. private _updateEffectOptions;
  126510. private _randomTextureSize;
  126511. private _actualFrame;
  126512. private readonly _rawTextureWidth;
  126513. /**
  126514. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126515. */
  126516. static readonly IsSupported: boolean;
  126517. /**
  126518. * An event triggered when the system is disposed.
  126519. */
  126520. onDisposeObservable: Observable<GPUParticleSystem>;
  126521. /**
  126522. * Gets the maximum number of particles active at the same time.
  126523. * @returns The max number of active particles.
  126524. */
  126525. getCapacity(): number;
  126526. /**
  126527. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126528. * to override the particles.
  126529. */
  126530. forceDepthWrite: boolean;
  126531. /**
  126532. * Gets or set the number of active particles
  126533. */
  126534. activeParticleCount: number;
  126535. private _preWarmDone;
  126536. /**
  126537. * Is this system ready to be used/rendered
  126538. * @return true if the system is ready
  126539. */
  126540. isReady(): boolean;
  126541. /**
  126542. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126543. * @returns True if it has been started, otherwise false.
  126544. */
  126545. isStarted(): boolean;
  126546. /**
  126547. * Starts the particle system and begins to emit
  126548. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126549. */
  126550. start(delay?: number): void;
  126551. /**
  126552. * Stops the particle system.
  126553. */
  126554. stop(): void;
  126555. /**
  126556. * Remove all active particles
  126557. */
  126558. reset(): void;
  126559. /**
  126560. * Returns the string "GPUParticleSystem"
  126561. * @returns a string containing the class name
  126562. */
  126563. getClassName(): string;
  126564. private _colorGradientsTexture;
  126565. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126566. /**
  126567. * Adds a new color gradient
  126568. * @param gradient defines the gradient to use (between 0 and 1)
  126569. * @param color1 defines the color to affect to the specified gradient
  126570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126571. * @returns the current particle system
  126572. */
  126573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126574. /**
  126575. * Remove a specific color gradient
  126576. * @param gradient defines the gradient to remove
  126577. * @returns the current particle system
  126578. */
  126579. removeColorGradient(gradient: number): GPUParticleSystem;
  126580. private _angularSpeedGradientsTexture;
  126581. private _sizeGradientsTexture;
  126582. private _velocityGradientsTexture;
  126583. private _limitVelocityGradientsTexture;
  126584. private _dragGradientsTexture;
  126585. private _addFactorGradient;
  126586. /**
  126587. * Adds a new size gradient
  126588. * @param gradient defines the gradient to use (between 0 and 1)
  126589. * @param factor defines the size factor to affect to the specified gradient
  126590. * @returns the current particle system
  126591. */
  126592. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126593. /**
  126594. * Remove a specific size gradient
  126595. * @param gradient defines the gradient to remove
  126596. * @returns the current particle system
  126597. */
  126598. removeSizeGradient(gradient: number): GPUParticleSystem;
  126599. /**
  126600. * Adds a new angular speed gradient
  126601. * @param gradient defines the gradient to use (between 0 and 1)
  126602. * @param factor defines the angular speed to affect to the specified gradient
  126603. * @returns the current particle system
  126604. */
  126605. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126606. /**
  126607. * Remove a specific angular speed gradient
  126608. * @param gradient defines the gradient to remove
  126609. * @returns the current particle system
  126610. */
  126611. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126612. /**
  126613. * Adds a new velocity gradient
  126614. * @param gradient defines the gradient to use (between 0 and 1)
  126615. * @param factor defines the velocity to affect to the specified gradient
  126616. * @returns the current particle system
  126617. */
  126618. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126619. /**
  126620. * Remove a specific velocity gradient
  126621. * @param gradient defines the gradient to remove
  126622. * @returns the current particle system
  126623. */
  126624. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126625. /**
  126626. * Adds a new limit velocity gradient
  126627. * @param gradient defines the gradient to use (between 0 and 1)
  126628. * @param factor defines the limit velocity value to affect to the specified gradient
  126629. * @returns the current particle system
  126630. */
  126631. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126632. /**
  126633. * Remove a specific limit velocity gradient
  126634. * @param gradient defines the gradient to remove
  126635. * @returns the current particle system
  126636. */
  126637. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126638. /**
  126639. * Adds a new drag gradient
  126640. * @param gradient defines the gradient to use (between 0 and 1)
  126641. * @param factor defines the drag value to affect to the specified gradient
  126642. * @returns the current particle system
  126643. */
  126644. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126645. /**
  126646. * Remove a specific drag gradient
  126647. * @param gradient defines the gradient to remove
  126648. * @returns the current particle system
  126649. */
  126650. removeDragGradient(gradient: number): GPUParticleSystem;
  126651. /**
  126652. * Not supported by GPUParticleSystem
  126653. * @param gradient defines the gradient to use (between 0 and 1)
  126654. * @param factor defines the emit rate value to affect to the specified gradient
  126655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126656. * @returns the current particle system
  126657. */
  126658. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126659. /**
  126660. * Not supported by GPUParticleSystem
  126661. * @param gradient defines the gradient to remove
  126662. * @returns the current particle system
  126663. */
  126664. removeEmitRateGradient(gradient: number): IParticleSystem;
  126665. /**
  126666. * Not supported by GPUParticleSystem
  126667. * @param gradient defines the gradient to use (between 0 and 1)
  126668. * @param factor defines the start size value to affect to the specified gradient
  126669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126670. * @returns the current particle system
  126671. */
  126672. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126673. /**
  126674. * Not supported by GPUParticleSystem
  126675. * @param gradient defines the gradient to remove
  126676. * @returns the current particle system
  126677. */
  126678. removeStartSizeGradient(gradient: number): IParticleSystem;
  126679. /**
  126680. * Not supported by GPUParticleSystem
  126681. * @param gradient defines the gradient to use (between 0 and 1)
  126682. * @param min defines the color remap minimal range
  126683. * @param max defines the color remap maximal range
  126684. * @returns the current particle system
  126685. */
  126686. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126687. /**
  126688. * Not supported by GPUParticleSystem
  126689. * @param gradient defines the gradient to remove
  126690. * @returns the current particle system
  126691. */
  126692. removeColorRemapGradient(): IParticleSystem;
  126693. /**
  126694. * Not supported by GPUParticleSystem
  126695. * @param gradient defines the gradient to use (between 0 and 1)
  126696. * @param min defines the alpha remap minimal range
  126697. * @param max defines the alpha remap maximal range
  126698. * @returns the current particle system
  126699. */
  126700. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126701. /**
  126702. * Not supported by GPUParticleSystem
  126703. * @param gradient defines the gradient to remove
  126704. * @returns the current particle system
  126705. */
  126706. removeAlphaRemapGradient(): IParticleSystem;
  126707. /**
  126708. * Not supported by GPUParticleSystem
  126709. * @param gradient defines the gradient to use (between 0 and 1)
  126710. * @param color defines the color to affect to the specified gradient
  126711. * @returns the current particle system
  126712. */
  126713. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126714. /**
  126715. * Not supported by GPUParticleSystem
  126716. * @param gradient defines the gradient to remove
  126717. * @returns the current particle system
  126718. */
  126719. removeRampGradient(): IParticleSystem;
  126720. /**
  126721. * Not supported by GPUParticleSystem
  126722. * @returns the list of ramp gradients
  126723. */
  126724. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126725. /**
  126726. * Not supported by GPUParticleSystem
  126727. * Gets or sets a boolean indicating that ramp gradients must be used
  126728. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126729. */
  126730. useRampGradients: boolean;
  126731. /**
  126732. * Not supported by GPUParticleSystem
  126733. * @param gradient defines the gradient to use (between 0 and 1)
  126734. * @param factor defines the life time factor to affect to the specified gradient
  126735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126736. * @returns the current particle system
  126737. */
  126738. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126739. /**
  126740. * Not supported by GPUParticleSystem
  126741. * @param gradient defines the gradient to remove
  126742. * @returns the current particle system
  126743. */
  126744. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126745. /**
  126746. * Instantiates a GPU particle system.
  126747. * 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.
  126748. * @param name The name of the particle system
  126749. * @param options The options used to create the system
  126750. * @param scene The scene the particle system belongs to
  126751. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126752. */
  126753. constructor(name: string, options: Partial<{
  126754. capacity: number;
  126755. randomTextureSize: number;
  126756. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126757. protected _reset(): void;
  126758. private _createUpdateVAO;
  126759. private _createRenderVAO;
  126760. private _initialize;
  126761. /** @hidden */
  126762. _recreateUpdateEffect(): void;
  126763. /** @hidden */
  126764. _recreateRenderEffect(): void;
  126765. /**
  126766. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126767. * @param preWarm defines if we are in the pre-warmimg phase
  126768. */
  126769. animate(preWarm?: boolean): void;
  126770. private _createFactorGradientTexture;
  126771. private _createSizeGradientTexture;
  126772. private _createAngularSpeedGradientTexture;
  126773. private _createVelocityGradientTexture;
  126774. private _createLimitVelocityGradientTexture;
  126775. private _createDragGradientTexture;
  126776. private _createColorGradientTexture;
  126777. /**
  126778. * Renders the particle system in its current state
  126779. * @param preWarm defines if the system should only update the particles but not render them
  126780. * @returns the current number of particles
  126781. */
  126782. render(preWarm?: boolean): number;
  126783. /**
  126784. * Rebuilds the particle system
  126785. */
  126786. rebuild(): void;
  126787. private _releaseBuffers;
  126788. private _releaseVAOs;
  126789. /**
  126790. * Disposes the particle system and free the associated resources
  126791. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126792. */
  126793. dispose(disposeTexture?: boolean): void;
  126794. /**
  126795. * Clones the particle system.
  126796. * @param name The name of the cloned object
  126797. * @param newEmitter The new emitter to use
  126798. * @returns the cloned particle system
  126799. */
  126800. clone(name: string, newEmitter: any): GPUParticleSystem;
  126801. /**
  126802. * Serializes the particle system to a JSON object.
  126803. * @returns the JSON object
  126804. */
  126805. serialize(): any;
  126806. /**
  126807. * Parses a JSON object to create a GPU particle system.
  126808. * @param parsedParticleSystem The JSON object to parse
  126809. * @param scene The scene to create the particle system in
  126810. * @param rootUrl The root url to use to load external dependencies like texture
  126811. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126812. * @returns the parsed GPU particle system
  126813. */
  126814. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126815. }
  126816. }
  126817. declare module BABYLON {
  126818. /**
  126819. * Represents a set of particle systems working together to create a specific effect
  126820. */
  126821. export class ParticleSystemSet implements IDisposable {
  126822. /**
  126823. * Gets or sets base Assets URL
  126824. */
  126825. static BaseAssetsUrl: string;
  126826. private _emitterCreationOptions;
  126827. private _emitterNode;
  126828. /**
  126829. * Gets the particle system list
  126830. */
  126831. systems: IParticleSystem[];
  126832. /**
  126833. * Gets the emitter node used with this set
  126834. */
  126835. readonly emitterNode: Nullable<TransformNode>;
  126836. /**
  126837. * Creates a new emitter mesh as a sphere
  126838. * @param options defines the options used to create the sphere
  126839. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126840. * @param scene defines the hosting scene
  126841. */
  126842. setEmitterAsSphere(options: {
  126843. diameter: number;
  126844. segments: number;
  126845. color: Color3;
  126846. }, renderingGroupId: number, scene: Scene): void;
  126847. /**
  126848. * Starts all particle systems of the set
  126849. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126850. */
  126851. start(emitter?: AbstractMesh): void;
  126852. /**
  126853. * Release all associated resources
  126854. */
  126855. dispose(): void;
  126856. /**
  126857. * Serialize the set into a JSON compatible object
  126858. * @returns a JSON compatible representation of the set
  126859. */
  126860. serialize(): any;
  126861. /**
  126862. * Parse a new ParticleSystemSet from a serialized source
  126863. * @param data defines a JSON compatible representation of the set
  126864. * @param scene defines the hosting scene
  126865. * @param gpu defines if we want GPU particles or CPU particles
  126866. * @returns a new ParticleSystemSet
  126867. */
  126868. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126869. }
  126870. }
  126871. declare module BABYLON {
  126872. /**
  126873. * This class is made for on one-liner static method to help creating particle system set.
  126874. */
  126875. export class ParticleHelper {
  126876. /**
  126877. * Gets or sets base Assets URL
  126878. */
  126879. static BaseAssetsUrl: string;
  126880. /**
  126881. * Create a default particle system that you can tweak
  126882. * @param emitter defines the emitter to use
  126883. * @param capacity defines the system capacity (default is 500 particles)
  126884. * @param scene defines the hosting scene
  126885. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126886. * @returns the new Particle system
  126887. */
  126888. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126889. /**
  126890. * This is the main static method (one-liner) of this helper to create different particle systems
  126891. * @param type This string represents the type to the particle system to create
  126892. * @param scene The scene where the particle system should live
  126893. * @param gpu If the system will use gpu
  126894. * @returns the ParticleSystemSet created
  126895. */
  126896. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126897. /**
  126898. * Static function used to export a particle system to a ParticleSystemSet variable.
  126899. * Please note that the emitter shape is not exported
  126900. * @param systems defines the particle systems to export
  126901. * @returns the created particle system set
  126902. */
  126903. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126904. }
  126905. }
  126906. declare module BABYLON {
  126907. interface Engine {
  126908. /**
  126909. * Create an effect to use with particle systems.
  126910. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126911. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126912. * @param uniformsNames defines a list of attribute names
  126913. * @param samplers defines an array of string used to represent textures
  126914. * @param defines defines the string containing the defines to use to compile the shaders
  126915. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126916. * @param onCompiled defines a function to call when the effect creation is successful
  126917. * @param onError defines a function to call when the effect creation has failed
  126918. * @returns the new Effect
  126919. */
  126920. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126921. }
  126922. interface Mesh {
  126923. /**
  126924. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126925. * @returns an array of IParticleSystem
  126926. */
  126927. getEmittedParticleSystems(): IParticleSystem[];
  126928. /**
  126929. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  126930. * @returns an array of IParticleSystem
  126931. */
  126932. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  126933. }
  126934. /**
  126935. * @hidden
  126936. */
  126937. export var _IDoNeedToBeInTheBuild: number;
  126938. }
  126939. declare module BABYLON {
  126940. /** Defines the 4 color options */
  126941. export enum PointColor {
  126942. /** color value */
  126943. Color = 2,
  126944. /** uv value */
  126945. UV = 1,
  126946. /** random value */
  126947. Random = 0,
  126948. /** stated value */
  126949. Stated = 3
  126950. }
  126951. /**
  126952. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  126953. * 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.
  126954. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  126955. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  126956. *
  126957. * Full documentation here : TO BE ENTERED
  126958. */
  126959. export class PointsCloudSystem implements IDisposable {
  126960. /**
  126961. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  126962. * Example : var p = SPS.particles[i];
  126963. */
  126964. particles: CloudPoint[];
  126965. /**
  126966. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  126967. */
  126968. nbParticles: number;
  126969. /**
  126970. * This a counter for your own usage. It's not set by any SPS functions.
  126971. */
  126972. counter: number;
  126973. /**
  126974. * The PCS name. This name is also given to the underlying mesh.
  126975. */
  126976. name: string;
  126977. /**
  126978. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  126979. */
  126980. mesh: Mesh;
  126981. /**
  126982. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  126983. * Please read :
  126984. */
  126985. vars: any;
  126986. /**
  126987. * @hidden
  126988. */
  126989. _size: number;
  126990. private _scene;
  126991. private _promises;
  126992. private _positions;
  126993. private _indices;
  126994. private _normals;
  126995. private _colors;
  126996. private _uvs;
  126997. private _indices32;
  126998. private _positions32;
  126999. private _colors32;
  127000. private _uvs32;
  127001. private _updatable;
  127002. private _isVisibilityBoxLocked;
  127003. private _alwaysVisible;
  127004. private _groups;
  127005. private _groupCounter;
  127006. private _computeParticleColor;
  127007. private _computeParticleTexture;
  127008. private _computeParticleRotation;
  127009. private _computeBoundingBox;
  127010. private _isReady;
  127011. /**
  127012. * Creates a PCS (Points Cloud System) object
  127013. * @param name (String) is the PCS name, this will be the underlying mesh name
  127014. * @param pointSize (number) is the size for each point
  127015. * @param scene (Scene) is the scene in which the PCS is added
  127016. * @param options defines the options of the PCS e.g.
  127017. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127018. */
  127019. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127020. updatable?: boolean;
  127021. });
  127022. /**
  127023. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127024. * If no points were added to the PCS, the returned mesh is just a single point.
  127025. * @returns a promise for the created mesh
  127026. */
  127027. buildMeshAsync(): Promise<Mesh>;
  127028. /**
  127029. * @hidden
  127030. */
  127031. private _buildMesh;
  127032. private _addParticle;
  127033. private _randomUnitVector;
  127034. private _getColorIndicesForCoord;
  127035. private _setPointsColorOrUV;
  127036. private _colorFromTexture;
  127037. private _calculateDensity;
  127038. /**
  127039. * Adds points to the PCS in random positions within a unit sphere
  127040. * @param nb (positive integer) the number of particles to be created from this model
  127041. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127042. * @returns the number of groups in the system
  127043. */
  127044. addPoints(nb: number, pointFunction?: any): number;
  127045. /**
  127046. * Adds points to the PCS from the surface of the model shape
  127047. * @param mesh is any Mesh object that will be used as a surface model for the points
  127048. * @param nb (positive integer) the number of particles to be created from this model
  127049. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127050. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127051. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127052. * @returns the number of groups in the system
  127053. */
  127054. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127055. /**
  127056. * Adds points to the PCS inside the model shape
  127057. * @param mesh is any Mesh object that will be used as a surface model for the points
  127058. * @param nb (positive integer) the number of particles to be created from this model
  127059. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127060. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127061. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127062. * @returns the number of groups in the system
  127063. */
  127064. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127065. /**
  127066. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127067. * This method calls `updateParticle()` for each particle of the SPS.
  127068. * For an animated SPS, it is usually called within the render loop.
  127069. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127070. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127071. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127072. * @returns the PCS.
  127073. */
  127074. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127075. /**
  127076. * Disposes the PCS.
  127077. */
  127078. dispose(): void;
  127079. /**
  127080. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127081. * doc :
  127082. * @returns the PCS.
  127083. */
  127084. refreshVisibleSize(): PointsCloudSystem;
  127085. /**
  127086. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127087. * @param size the size (float) of the visibility box
  127088. * note : this doesn't lock the PCS mesh bounding box.
  127089. * doc :
  127090. */
  127091. setVisibilityBox(size: number): void;
  127092. /**
  127093. * Gets whether the PCS is always visible or not
  127094. * doc :
  127095. */
  127096. /**
  127097. * Sets the PCS as always visible or not
  127098. * doc :
  127099. */
  127100. isAlwaysVisible: boolean;
  127101. /**
  127102. * Tells to `setParticles()` to compute the particle rotations or not
  127103. * Default value : false. The PCS is faster when it's set to false
  127104. * Note : particle rotations are only applied to parent particles
  127105. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127106. */
  127107. computeParticleRotation: boolean;
  127108. /**
  127109. * Tells to `setParticles()` to compute the particle colors or not.
  127110. * Default value : true. The PCS is faster when it's set to false.
  127111. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127112. */
  127113. /**
  127114. * Gets if `setParticles()` computes the particle colors or not.
  127115. * Default value : false. The PCS is faster when it's set to false.
  127116. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127117. */
  127118. computeParticleColor: boolean;
  127119. /**
  127120. * Gets if `setParticles()` computes the particle textures or not.
  127121. * Default value : false. The PCS is faster when it's set to false.
  127122. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127123. */
  127124. computeParticleTexture: boolean;
  127125. /**
  127126. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127127. */
  127128. /**
  127129. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127130. */
  127131. computeBoundingBox: boolean;
  127132. /**
  127133. * This function does nothing. It may be overwritten to set all the particle first values.
  127134. * The PCS doesn't call this function, you may have to call it by your own.
  127135. * doc :
  127136. */
  127137. initParticles(): void;
  127138. /**
  127139. * This function does nothing. It may be overwritten to recycle a particle
  127140. * The PCS doesn't call this function, you can to call it
  127141. * doc :
  127142. * @param particle The particle to recycle
  127143. * @returns the recycled particle
  127144. */
  127145. recycleParticle(particle: CloudPoint): CloudPoint;
  127146. /**
  127147. * Updates a particle : this function should be overwritten by the user.
  127148. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127149. * doc :
  127150. * @example : just set a particle position or velocity and recycle conditions
  127151. * @param particle The particle to update
  127152. * @returns the updated particle
  127153. */
  127154. updateParticle(particle: CloudPoint): CloudPoint;
  127155. /**
  127156. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127157. * This does nothing and may be overwritten by the user.
  127158. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127159. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127160. * @param update the boolean update value actually passed to setParticles()
  127161. */
  127162. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127163. /**
  127164. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127165. * This will be passed three parameters.
  127166. * This does nothing and may be overwritten by the user.
  127167. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127168. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127169. * @param update the boolean update value actually passed to setParticles()
  127170. */
  127171. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127172. }
  127173. }
  127174. declare module BABYLON {
  127175. /**
  127176. * Represents one particle of a points cloud system.
  127177. */
  127178. export class CloudPoint {
  127179. /**
  127180. * particle global index
  127181. */
  127182. idx: number;
  127183. /**
  127184. * The color of the particle
  127185. */
  127186. color: Nullable<Color4>;
  127187. /**
  127188. * The world space position of the particle.
  127189. */
  127190. position: Vector3;
  127191. /**
  127192. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127193. */
  127194. rotation: Vector3;
  127195. /**
  127196. * The world space rotation quaternion of the particle.
  127197. */
  127198. rotationQuaternion: Nullable<Quaternion>;
  127199. /**
  127200. * The uv of the particle.
  127201. */
  127202. uv: Nullable<Vector2>;
  127203. /**
  127204. * The current speed of the particle.
  127205. */
  127206. velocity: Vector3;
  127207. /**
  127208. * The pivot point in the particle local space.
  127209. */
  127210. pivot: Vector3;
  127211. /**
  127212. * Must the particle be translated from its pivot point in its local space ?
  127213. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127214. * Default : false
  127215. */
  127216. translateFromPivot: boolean;
  127217. /**
  127218. * Index of this particle in the global "positions" array (Internal use)
  127219. * @hidden
  127220. */
  127221. _pos: number;
  127222. /**
  127223. * @hidden Index of this particle in the global "indices" array (Internal use)
  127224. */
  127225. _ind: number;
  127226. /**
  127227. * Group this particle belongs to
  127228. */
  127229. _group: PointsGroup;
  127230. /**
  127231. * Group id of this particle
  127232. */
  127233. groupId: number;
  127234. /**
  127235. * Index of the particle in its group id (Internal use)
  127236. */
  127237. idxInGroup: number;
  127238. /**
  127239. * @hidden Particle BoundingInfo object (Internal use)
  127240. */
  127241. _boundingInfo: BoundingInfo;
  127242. /**
  127243. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127244. */
  127245. _pcs: PointsCloudSystem;
  127246. /**
  127247. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127248. */
  127249. _stillInvisible: boolean;
  127250. /**
  127251. * @hidden Last computed particle rotation matrix
  127252. */
  127253. _rotationMatrix: number[];
  127254. /**
  127255. * Parent particle Id, if any.
  127256. * Default null.
  127257. */
  127258. parentId: Nullable<number>;
  127259. /**
  127260. * @hidden Internal global position in the PCS.
  127261. */
  127262. _globalPosition: Vector3;
  127263. /**
  127264. * Creates a Point Cloud object.
  127265. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127266. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127267. * @param group (PointsGroup) is the group the particle belongs to
  127268. * @param groupId (integer) is the group identifier in the PCS.
  127269. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127270. * @param pcs defines the PCS it is associated to
  127271. */
  127272. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127273. /**
  127274. * get point size
  127275. */
  127276. /**
  127277. * Set point size
  127278. */
  127279. size: Vector3;
  127280. /**
  127281. * Legacy support, changed quaternion to rotationQuaternion
  127282. */
  127283. /**
  127284. * Legacy support, changed quaternion to rotationQuaternion
  127285. */
  127286. quaternion: Nullable<Quaternion>;
  127287. /**
  127288. * Returns a boolean. True if the particle intersects a mesh, else false
  127289. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127290. * @param target is the object (point or mesh) what the intersection is computed against
  127291. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127292. * @returns true if it intersects
  127293. */
  127294. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127295. /**
  127296. * get the rotation matrix of the particle
  127297. * @hidden
  127298. */
  127299. getRotationMatrix(m: Matrix): void;
  127300. }
  127301. /**
  127302. * Represents a group of points in a points cloud system
  127303. * * PCS internal tool, don't use it manually.
  127304. */
  127305. export class PointsGroup {
  127306. /**
  127307. * The group id
  127308. * @hidden
  127309. */
  127310. groupID: number;
  127311. /**
  127312. * image data for group (internal use)
  127313. * @hidden
  127314. */
  127315. _groupImageData: Nullable<ArrayBufferView>;
  127316. /**
  127317. * Image Width (internal use)
  127318. * @hidden
  127319. */
  127320. _groupImgWidth: number;
  127321. /**
  127322. * Image Height (internal use)
  127323. * @hidden
  127324. */
  127325. _groupImgHeight: number;
  127326. /**
  127327. * Custom position function (internal use)
  127328. * @hidden
  127329. */
  127330. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127331. /**
  127332. * density per facet for surface points
  127333. * @hidden
  127334. */
  127335. _groupDensity: number[];
  127336. /**
  127337. * Only when points are colored by texture carries pointer to texture list array
  127338. * @hidden
  127339. */
  127340. _textureNb: number;
  127341. /**
  127342. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127343. * PCS internal tool, don't use it manually.
  127344. * @hidden
  127345. */
  127346. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127347. }
  127348. }
  127349. declare module BABYLON {
  127350. interface Scene {
  127351. /** @hidden (Backing field) */
  127352. _physicsEngine: Nullable<IPhysicsEngine>;
  127353. /**
  127354. * Gets the current physics engine
  127355. * @returns a IPhysicsEngine or null if none attached
  127356. */
  127357. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127358. /**
  127359. * Enables physics to the current scene
  127360. * @param gravity defines the scene's gravity for the physics engine
  127361. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127362. * @return a boolean indicating if the physics engine was initialized
  127363. */
  127364. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127365. /**
  127366. * Disables and disposes the physics engine associated with the scene
  127367. */
  127368. disablePhysicsEngine(): void;
  127369. /**
  127370. * Gets a boolean indicating if there is an active physics engine
  127371. * @returns a boolean indicating if there is an active physics engine
  127372. */
  127373. isPhysicsEnabled(): boolean;
  127374. /**
  127375. * Deletes a physics compound impostor
  127376. * @param compound defines the compound to delete
  127377. */
  127378. deleteCompoundImpostor(compound: any): void;
  127379. /**
  127380. * An event triggered when physic simulation is about to be run
  127381. */
  127382. onBeforePhysicsObservable: Observable<Scene>;
  127383. /**
  127384. * An event triggered when physic simulation has been done
  127385. */
  127386. onAfterPhysicsObservable: Observable<Scene>;
  127387. }
  127388. interface AbstractMesh {
  127389. /** @hidden */
  127390. _physicsImpostor: Nullable<PhysicsImpostor>;
  127391. /**
  127392. * Gets or sets impostor used for physic simulation
  127393. * @see http://doc.babylonjs.com/features/physics_engine
  127394. */
  127395. physicsImpostor: Nullable<PhysicsImpostor>;
  127396. /**
  127397. * Gets the current physics impostor
  127398. * @see http://doc.babylonjs.com/features/physics_engine
  127399. * @returns a physics impostor or null
  127400. */
  127401. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127402. /** Apply a physic impulse to the mesh
  127403. * @param force defines the force to apply
  127404. * @param contactPoint defines where to apply the force
  127405. * @returns the current mesh
  127406. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127407. */
  127408. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127409. /**
  127410. * Creates a physic joint between two meshes
  127411. * @param otherMesh defines the other mesh to use
  127412. * @param pivot1 defines the pivot to use on this mesh
  127413. * @param pivot2 defines the pivot to use on the other mesh
  127414. * @param options defines additional options (can be plugin dependent)
  127415. * @returns the current mesh
  127416. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127417. */
  127418. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127419. /** @hidden */
  127420. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127421. }
  127422. /**
  127423. * Defines the physics engine scene component responsible to manage a physics engine
  127424. */
  127425. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127426. /**
  127427. * The component name helpful to identify the component in the list of scene components.
  127428. */
  127429. readonly name: string;
  127430. /**
  127431. * The scene the component belongs to.
  127432. */
  127433. scene: Scene;
  127434. /**
  127435. * Creates a new instance of the component for the given scene
  127436. * @param scene Defines the scene to register the component in
  127437. */
  127438. constructor(scene: Scene);
  127439. /**
  127440. * Registers the component in a given scene
  127441. */
  127442. register(): void;
  127443. /**
  127444. * Rebuilds the elements related to this component in case of
  127445. * context lost for instance.
  127446. */
  127447. rebuild(): void;
  127448. /**
  127449. * Disposes the component and the associated ressources
  127450. */
  127451. dispose(): void;
  127452. }
  127453. }
  127454. declare module BABYLON {
  127455. /**
  127456. * A helper for physics simulations
  127457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127458. */
  127459. export class PhysicsHelper {
  127460. private _scene;
  127461. private _physicsEngine;
  127462. /**
  127463. * Initializes the Physics helper
  127464. * @param scene Babylon.js scene
  127465. */
  127466. constructor(scene: Scene);
  127467. /**
  127468. * Applies a radial explosion impulse
  127469. * @param origin the origin of the explosion
  127470. * @param radiusOrEventOptions the radius or the options of radial explosion
  127471. * @param strength the explosion strength
  127472. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127473. * @returns A physics radial explosion event, or null
  127474. */
  127475. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127476. /**
  127477. * Applies a radial explosion force
  127478. * @param origin the origin of the explosion
  127479. * @param radiusOrEventOptions the radius or the options of radial explosion
  127480. * @param strength the explosion strength
  127481. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127482. * @returns A physics radial explosion event, or null
  127483. */
  127484. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127485. /**
  127486. * Creates a gravitational field
  127487. * @param origin the origin of the explosion
  127488. * @param radiusOrEventOptions the radius or the options of radial explosion
  127489. * @param strength the explosion strength
  127490. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127491. * @returns A physics gravitational field event, or null
  127492. */
  127493. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127494. /**
  127495. * Creates a physics updraft event
  127496. * @param origin the origin of the updraft
  127497. * @param radiusOrEventOptions the radius or the options of the updraft
  127498. * @param strength the strength of the updraft
  127499. * @param height the height of the updraft
  127500. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127501. * @returns A physics updraft event, or null
  127502. */
  127503. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127504. /**
  127505. * Creates a physics vortex event
  127506. * @param origin the of the vortex
  127507. * @param radiusOrEventOptions the radius or the options of the vortex
  127508. * @param strength the strength of the vortex
  127509. * @param height the height of the vortex
  127510. * @returns a Physics vortex event, or null
  127511. * A physics vortex event or null
  127512. */
  127513. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127514. }
  127515. /**
  127516. * Represents a physics radial explosion event
  127517. */
  127518. class PhysicsRadialExplosionEvent {
  127519. private _scene;
  127520. private _options;
  127521. private _sphere;
  127522. private _dataFetched;
  127523. /**
  127524. * Initializes a radial explosioin event
  127525. * @param _scene BabylonJS scene
  127526. * @param _options The options for the vortex event
  127527. */
  127528. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127529. /**
  127530. * Returns the data related to the radial explosion event (sphere).
  127531. * @returns The radial explosion event data
  127532. */
  127533. getData(): PhysicsRadialExplosionEventData;
  127534. /**
  127535. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127536. * @param impostor A physics imposter
  127537. * @param origin the origin of the explosion
  127538. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127539. */
  127540. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127541. /**
  127542. * Triggers affecterd impostors callbacks
  127543. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127544. */
  127545. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127546. /**
  127547. * Disposes the sphere.
  127548. * @param force Specifies if the sphere should be disposed by force
  127549. */
  127550. dispose(force?: boolean): void;
  127551. /*** Helpers ***/
  127552. private _prepareSphere;
  127553. private _intersectsWithSphere;
  127554. }
  127555. /**
  127556. * Represents a gravitational field event
  127557. */
  127558. class PhysicsGravitationalFieldEvent {
  127559. private _physicsHelper;
  127560. private _scene;
  127561. private _origin;
  127562. private _options;
  127563. private _tickCallback;
  127564. private _sphere;
  127565. private _dataFetched;
  127566. /**
  127567. * Initializes the physics gravitational field event
  127568. * @param _physicsHelper A physics helper
  127569. * @param _scene BabylonJS scene
  127570. * @param _origin The origin position of the gravitational field event
  127571. * @param _options The options for the vortex event
  127572. */
  127573. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127574. /**
  127575. * Returns the data related to the gravitational field event (sphere).
  127576. * @returns A gravitational field event
  127577. */
  127578. getData(): PhysicsGravitationalFieldEventData;
  127579. /**
  127580. * Enables the gravitational field.
  127581. */
  127582. enable(): void;
  127583. /**
  127584. * Disables the gravitational field.
  127585. */
  127586. disable(): void;
  127587. /**
  127588. * Disposes the sphere.
  127589. * @param force The force to dispose from the gravitational field event
  127590. */
  127591. dispose(force?: boolean): void;
  127592. private _tick;
  127593. }
  127594. /**
  127595. * Represents a physics updraft event
  127596. */
  127597. class PhysicsUpdraftEvent {
  127598. private _scene;
  127599. private _origin;
  127600. private _options;
  127601. private _physicsEngine;
  127602. private _originTop;
  127603. private _originDirection;
  127604. private _tickCallback;
  127605. private _cylinder;
  127606. private _cylinderPosition;
  127607. private _dataFetched;
  127608. /**
  127609. * Initializes the physics updraft event
  127610. * @param _scene BabylonJS scene
  127611. * @param _origin The origin position of the updraft
  127612. * @param _options The options for the updraft event
  127613. */
  127614. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127615. /**
  127616. * Returns the data related to the updraft event (cylinder).
  127617. * @returns A physics updraft event
  127618. */
  127619. getData(): PhysicsUpdraftEventData;
  127620. /**
  127621. * Enables the updraft.
  127622. */
  127623. enable(): void;
  127624. /**
  127625. * Disables the updraft.
  127626. */
  127627. disable(): void;
  127628. /**
  127629. * Disposes the cylinder.
  127630. * @param force Specifies if the updraft should be disposed by force
  127631. */
  127632. dispose(force?: boolean): void;
  127633. private getImpostorHitData;
  127634. private _tick;
  127635. /*** Helpers ***/
  127636. private _prepareCylinder;
  127637. private _intersectsWithCylinder;
  127638. }
  127639. /**
  127640. * Represents a physics vortex event
  127641. */
  127642. class PhysicsVortexEvent {
  127643. private _scene;
  127644. private _origin;
  127645. private _options;
  127646. private _physicsEngine;
  127647. private _originTop;
  127648. private _tickCallback;
  127649. private _cylinder;
  127650. private _cylinderPosition;
  127651. private _dataFetched;
  127652. /**
  127653. * Initializes the physics vortex event
  127654. * @param _scene The BabylonJS scene
  127655. * @param _origin The origin position of the vortex
  127656. * @param _options The options for the vortex event
  127657. */
  127658. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127659. /**
  127660. * Returns the data related to the vortex event (cylinder).
  127661. * @returns The physics vortex event data
  127662. */
  127663. getData(): PhysicsVortexEventData;
  127664. /**
  127665. * Enables the vortex.
  127666. */
  127667. enable(): void;
  127668. /**
  127669. * Disables the cortex.
  127670. */
  127671. disable(): void;
  127672. /**
  127673. * Disposes the sphere.
  127674. * @param force
  127675. */
  127676. dispose(force?: boolean): void;
  127677. private getImpostorHitData;
  127678. private _tick;
  127679. /*** Helpers ***/
  127680. private _prepareCylinder;
  127681. private _intersectsWithCylinder;
  127682. }
  127683. /**
  127684. * Options fot the radial explosion event
  127685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127686. */
  127687. export class PhysicsRadialExplosionEventOptions {
  127688. /**
  127689. * The radius of the sphere for the radial explosion.
  127690. */
  127691. radius: number;
  127692. /**
  127693. * The strenth of the explosion.
  127694. */
  127695. strength: number;
  127696. /**
  127697. * The strenght of the force in correspondence to the distance of the affected object
  127698. */
  127699. falloff: PhysicsRadialImpulseFalloff;
  127700. /**
  127701. * Sphere options for the radial explosion.
  127702. */
  127703. sphere: {
  127704. segments: number;
  127705. diameter: number;
  127706. };
  127707. /**
  127708. * Sphere options for the radial explosion.
  127709. */
  127710. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127711. }
  127712. /**
  127713. * Options fot the updraft event
  127714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127715. */
  127716. export class PhysicsUpdraftEventOptions {
  127717. /**
  127718. * The radius of the cylinder for the vortex
  127719. */
  127720. radius: number;
  127721. /**
  127722. * The strenth of the updraft.
  127723. */
  127724. strength: number;
  127725. /**
  127726. * The height of the cylinder for the updraft.
  127727. */
  127728. height: number;
  127729. /**
  127730. * The mode for the the updraft.
  127731. */
  127732. updraftMode: PhysicsUpdraftMode;
  127733. }
  127734. /**
  127735. * Options fot the vortex event
  127736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127737. */
  127738. export class PhysicsVortexEventOptions {
  127739. /**
  127740. * The radius of the cylinder for the vortex
  127741. */
  127742. radius: number;
  127743. /**
  127744. * The strenth of the vortex.
  127745. */
  127746. strength: number;
  127747. /**
  127748. * The height of the cylinder for the vortex.
  127749. */
  127750. height: number;
  127751. /**
  127752. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127753. */
  127754. centripetalForceThreshold: number;
  127755. /**
  127756. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127757. */
  127758. centripetalForceMultiplier: number;
  127759. /**
  127760. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127761. */
  127762. centrifugalForceMultiplier: number;
  127763. /**
  127764. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127765. */
  127766. updraftForceMultiplier: number;
  127767. }
  127768. /**
  127769. * The strenght of the force in correspondence to the distance of the affected object
  127770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127771. */
  127772. export enum PhysicsRadialImpulseFalloff {
  127773. /** Defines that impulse is constant in strength across it's whole radius */
  127774. Constant = 0,
  127775. /** Defines that impulse gets weaker if it's further from the origin */
  127776. Linear = 1
  127777. }
  127778. /**
  127779. * The strength of the force in correspondence to the distance of the affected object
  127780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127781. */
  127782. export enum PhysicsUpdraftMode {
  127783. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127784. Center = 0,
  127785. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127786. Perpendicular = 1
  127787. }
  127788. /**
  127789. * Interface for a physics hit data
  127790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127791. */
  127792. export interface PhysicsHitData {
  127793. /**
  127794. * The force applied at the contact point
  127795. */
  127796. force: Vector3;
  127797. /**
  127798. * The contact point
  127799. */
  127800. contactPoint: Vector3;
  127801. /**
  127802. * The distance from the origin to the contact point
  127803. */
  127804. distanceFromOrigin: number;
  127805. }
  127806. /**
  127807. * Interface for radial explosion event data
  127808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127809. */
  127810. export interface PhysicsRadialExplosionEventData {
  127811. /**
  127812. * A sphere used for the radial explosion event
  127813. */
  127814. sphere: Mesh;
  127815. }
  127816. /**
  127817. * Interface for gravitational field event data
  127818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127819. */
  127820. export interface PhysicsGravitationalFieldEventData {
  127821. /**
  127822. * A sphere mesh used for the gravitational field event
  127823. */
  127824. sphere: Mesh;
  127825. }
  127826. /**
  127827. * Interface for updraft event data
  127828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127829. */
  127830. export interface PhysicsUpdraftEventData {
  127831. /**
  127832. * A cylinder used for the updraft event
  127833. */
  127834. cylinder: Mesh;
  127835. }
  127836. /**
  127837. * Interface for vortex event data
  127838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127839. */
  127840. export interface PhysicsVortexEventData {
  127841. /**
  127842. * A cylinder used for the vortex event
  127843. */
  127844. cylinder: Mesh;
  127845. }
  127846. /**
  127847. * Interface for an affected physics impostor
  127848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127849. */
  127850. export interface PhysicsAffectedImpostorWithData {
  127851. /**
  127852. * The impostor affected by the effect
  127853. */
  127854. impostor: PhysicsImpostor;
  127855. /**
  127856. * The data about the hit/horce from the explosion
  127857. */
  127858. hitData: PhysicsHitData;
  127859. }
  127860. }
  127861. declare module BABYLON {
  127862. /** @hidden */
  127863. export var blackAndWhitePixelShader: {
  127864. name: string;
  127865. shader: string;
  127866. };
  127867. }
  127868. declare module BABYLON {
  127869. /**
  127870. * Post process used to render in black and white
  127871. */
  127872. export class BlackAndWhitePostProcess extends PostProcess {
  127873. /**
  127874. * Linear about to convert he result to black and white (default: 1)
  127875. */
  127876. degree: number;
  127877. /**
  127878. * Creates a black and white post process
  127879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127880. * @param name The name of the effect.
  127881. * @param options The required width/height ratio to downsize to before computing the render pass.
  127882. * @param camera The camera to apply the render pass to.
  127883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127884. * @param engine The engine which the post process will be applied. (default: current engine)
  127885. * @param reusable If the post process can be reused on the same frame. (default: false)
  127886. */
  127887. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127888. }
  127889. }
  127890. declare module BABYLON {
  127891. /**
  127892. * This represents a set of one or more post processes in Babylon.
  127893. * A post process can be used to apply a shader to a texture after it is rendered.
  127894. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127895. */
  127896. export class PostProcessRenderEffect {
  127897. private _postProcesses;
  127898. private _getPostProcesses;
  127899. private _singleInstance;
  127900. private _cameras;
  127901. private _indicesForCamera;
  127902. /**
  127903. * Name of the effect
  127904. * @hidden
  127905. */
  127906. _name: string;
  127907. /**
  127908. * Instantiates a post process render effect.
  127909. * A post process can be used to apply a shader to a texture after it is rendered.
  127910. * @param engine The engine the effect is tied to
  127911. * @param name The name of the effect
  127912. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127913. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127914. */
  127915. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127916. /**
  127917. * Checks if all the post processes in the effect are supported.
  127918. */
  127919. readonly isSupported: boolean;
  127920. /**
  127921. * Updates the current state of the effect
  127922. * @hidden
  127923. */
  127924. _update(): void;
  127925. /**
  127926. * Attaches the effect on cameras
  127927. * @param cameras The camera to attach to.
  127928. * @hidden
  127929. */
  127930. _attachCameras(cameras: Camera): void;
  127931. /**
  127932. * Attaches the effect on cameras
  127933. * @param cameras The camera to attach to.
  127934. * @hidden
  127935. */
  127936. _attachCameras(cameras: Camera[]): void;
  127937. /**
  127938. * Detaches the effect on cameras
  127939. * @param cameras The camera to detatch from.
  127940. * @hidden
  127941. */
  127942. _detachCameras(cameras: Camera): void;
  127943. /**
  127944. * Detatches the effect on cameras
  127945. * @param cameras The camera to detatch from.
  127946. * @hidden
  127947. */
  127948. _detachCameras(cameras: Camera[]): void;
  127949. /**
  127950. * Enables the effect on given cameras
  127951. * @param cameras The camera to enable.
  127952. * @hidden
  127953. */
  127954. _enable(cameras: Camera): void;
  127955. /**
  127956. * Enables the effect on given cameras
  127957. * @param cameras The camera to enable.
  127958. * @hidden
  127959. */
  127960. _enable(cameras: Nullable<Camera[]>): void;
  127961. /**
  127962. * Disables the effect on the given cameras
  127963. * @param cameras The camera to disable.
  127964. * @hidden
  127965. */
  127966. _disable(cameras: Camera): void;
  127967. /**
  127968. * Disables the effect on the given cameras
  127969. * @param cameras The camera to disable.
  127970. * @hidden
  127971. */
  127972. _disable(cameras: Nullable<Camera[]>): void;
  127973. /**
  127974. * Gets a list of the post processes contained in the effect.
  127975. * @param camera The camera to get the post processes on.
  127976. * @returns The list of the post processes in the effect.
  127977. */
  127978. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  127979. }
  127980. }
  127981. declare module BABYLON {
  127982. /** @hidden */
  127983. export var extractHighlightsPixelShader: {
  127984. name: string;
  127985. shader: string;
  127986. };
  127987. }
  127988. declare module BABYLON {
  127989. /**
  127990. * 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.
  127991. */
  127992. export class ExtractHighlightsPostProcess extends PostProcess {
  127993. /**
  127994. * The luminance threshold, pixels below this value will be set to black.
  127995. */
  127996. threshold: number;
  127997. /** @hidden */
  127998. _exposure: number;
  127999. /**
  128000. * Post process which has the input texture to be used when performing highlight extraction
  128001. * @hidden
  128002. */
  128003. _inputPostProcess: Nullable<PostProcess>;
  128004. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128005. }
  128006. }
  128007. declare module BABYLON {
  128008. /** @hidden */
  128009. export var bloomMergePixelShader: {
  128010. name: string;
  128011. shader: string;
  128012. };
  128013. }
  128014. declare module BABYLON {
  128015. /**
  128016. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128017. */
  128018. export class BloomMergePostProcess extends PostProcess {
  128019. /** Weight of the bloom to be added to the original input. */
  128020. weight: number;
  128021. /**
  128022. * Creates a new instance of @see BloomMergePostProcess
  128023. * @param name The name of the effect.
  128024. * @param originalFromInput Post process which's input will be used for the merge.
  128025. * @param blurred Blurred highlights post process which's output will be used.
  128026. * @param weight Weight of the bloom to be added to the original input.
  128027. * @param options The required width/height ratio to downsize to before computing the render pass.
  128028. * @param camera The camera to apply the render pass to.
  128029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128030. * @param engine The engine which the post process will be applied. (default: current engine)
  128031. * @param reusable If the post process can be reused on the same frame. (default: false)
  128032. * @param textureType Type of textures used when performing the post process. (default: 0)
  128033. * @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)
  128034. */
  128035. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128036. /** Weight of the bloom to be added to the original input. */
  128037. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128038. }
  128039. }
  128040. declare module BABYLON {
  128041. /**
  128042. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128043. */
  128044. export class BloomEffect extends PostProcessRenderEffect {
  128045. private bloomScale;
  128046. /**
  128047. * @hidden Internal
  128048. */
  128049. _effects: Array<PostProcess>;
  128050. /**
  128051. * @hidden Internal
  128052. */
  128053. _downscale: ExtractHighlightsPostProcess;
  128054. private _blurX;
  128055. private _blurY;
  128056. private _merge;
  128057. /**
  128058. * The luminance threshold to find bright areas of the image to bloom.
  128059. */
  128060. threshold: number;
  128061. /**
  128062. * The strength of the bloom.
  128063. */
  128064. weight: number;
  128065. /**
  128066. * Specifies the size of the bloom blur kernel, relative to the final output size
  128067. */
  128068. kernel: number;
  128069. /**
  128070. * Creates a new instance of @see BloomEffect
  128071. * @param scene The scene the effect belongs to.
  128072. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128073. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128074. * @param bloomWeight The the strength of bloom.
  128075. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128076. * @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)
  128077. */
  128078. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128079. /**
  128080. * Disposes each of the internal effects for a given camera.
  128081. * @param camera The camera to dispose the effect on.
  128082. */
  128083. disposeEffects(camera: Camera): void;
  128084. /**
  128085. * @hidden Internal
  128086. */
  128087. _updateEffects(): void;
  128088. /**
  128089. * Internal
  128090. * @returns if all the contained post processes are ready.
  128091. * @hidden
  128092. */
  128093. _isReady(): boolean;
  128094. }
  128095. }
  128096. declare module BABYLON {
  128097. /** @hidden */
  128098. export var chromaticAberrationPixelShader: {
  128099. name: string;
  128100. shader: string;
  128101. };
  128102. }
  128103. declare module BABYLON {
  128104. /**
  128105. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128106. */
  128107. export class ChromaticAberrationPostProcess extends PostProcess {
  128108. /**
  128109. * The amount of seperation of rgb channels (default: 30)
  128110. */
  128111. aberrationAmount: number;
  128112. /**
  128113. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128114. */
  128115. radialIntensity: number;
  128116. /**
  128117. * 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))
  128118. */
  128119. direction: Vector2;
  128120. /**
  128121. * 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))
  128122. */
  128123. centerPosition: Vector2;
  128124. /**
  128125. * Creates a new instance ChromaticAberrationPostProcess
  128126. * @param name The name of the effect.
  128127. * @param screenWidth The width of the screen to apply the effect on.
  128128. * @param screenHeight The height of the screen to apply the effect on.
  128129. * @param options The required width/height ratio to downsize to before computing the render pass.
  128130. * @param camera The camera to apply the render pass to.
  128131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128132. * @param engine The engine which the post process will be applied. (default: current engine)
  128133. * @param reusable If the post process can be reused on the same frame. (default: false)
  128134. * @param textureType Type of textures used when performing the post process. (default: 0)
  128135. * @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)
  128136. */
  128137. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128138. }
  128139. }
  128140. declare module BABYLON {
  128141. /** @hidden */
  128142. export var circleOfConfusionPixelShader: {
  128143. name: string;
  128144. shader: string;
  128145. };
  128146. }
  128147. declare module BABYLON {
  128148. /**
  128149. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128150. */
  128151. export class CircleOfConfusionPostProcess extends PostProcess {
  128152. /**
  128153. * 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.
  128154. */
  128155. lensSize: number;
  128156. /**
  128157. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128158. */
  128159. fStop: number;
  128160. /**
  128161. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128162. */
  128163. focusDistance: number;
  128164. /**
  128165. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128166. */
  128167. focalLength: number;
  128168. private _depthTexture;
  128169. /**
  128170. * Creates a new instance CircleOfConfusionPostProcess
  128171. * @param name The name of the effect.
  128172. * @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.
  128173. * @param options The required width/height ratio to downsize to before computing the render pass.
  128174. * @param camera The camera to apply the render pass to.
  128175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128176. * @param engine The engine which the post process will be applied. (default: current engine)
  128177. * @param reusable If the post process can be reused on the same frame. (default: false)
  128178. * @param textureType Type of textures used when performing the post process. (default: 0)
  128179. * @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)
  128180. */
  128181. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128182. /**
  128183. * 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.
  128184. */
  128185. depthTexture: RenderTargetTexture;
  128186. }
  128187. }
  128188. declare module BABYLON {
  128189. /** @hidden */
  128190. export var colorCorrectionPixelShader: {
  128191. name: string;
  128192. shader: string;
  128193. };
  128194. }
  128195. declare module BABYLON {
  128196. /**
  128197. *
  128198. * This post-process allows the modification of rendered colors by using
  128199. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128200. *
  128201. * The object needs to be provided an url to a texture containing the color
  128202. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128203. * Use an image editing software to tweak the LUT to match your needs.
  128204. *
  128205. * For an example of a color LUT, see here:
  128206. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128207. * For explanations on color grading, see here:
  128208. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128209. *
  128210. */
  128211. export class ColorCorrectionPostProcess extends PostProcess {
  128212. private _colorTableTexture;
  128213. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128214. }
  128215. }
  128216. declare module BABYLON {
  128217. /** @hidden */
  128218. export var convolutionPixelShader: {
  128219. name: string;
  128220. shader: string;
  128221. };
  128222. }
  128223. declare module BABYLON {
  128224. /**
  128225. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128226. * input texture to perform effects such as edge detection or sharpening
  128227. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128228. */
  128229. export class ConvolutionPostProcess extends PostProcess {
  128230. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128231. kernel: number[];
  128232. /**
  128233. * Creates a new instance ConvolutionPostProcess
  128234. * @param name The name of the effect.
  128235. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128236. * @param options The required width/height ratio to downsize to before computing the render pass.
  128237. * @param camera The camera to apply the render pass to.
  128238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128239. * @param engine The engine which the post process will be applied. (default: current engine)
  128240. * @param reusable If the post process can be reused on the same frame. (default: false)
  128241. * @param textureType Type of textures used when performing the post process. (default: 0)
  128242. */
  128243. constructor(name: string,
  128244. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128245. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128246. /**
  128247. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128248. */
  128249. static EdgeDetect0Kernel: number[];
  128250. /**
  128251. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128252. */
  128253. static EdgeDetect1Kernel: number[];
  128254. /**
  128255. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128256. */
  128257. static EdgeDetect2Kernel: number[];
  128258. /**
  128259. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128260. */
  128261. static SharpenKernel: number[];
  128262. /**
  128263. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128264. */
  128265. static EmbossKernel: number[];
  128266. /**
  128267. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128268. */
  128269. static GaussianKernel: number[];
  128270. }
  128271. }
  128272. declare module BABYLON {
  128273. /**
  128274. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128275. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128276. * based on samples that have a large difference in distance than the center pixel.
  128277. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128278. */
  128279. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128280. direction: Vector2;
  128281. /**
  128282. * Creates a new instance CircleOfConfusionPostProcess
  128283. * @param name The name of the effect.
  128284. * @param scene The scene the effect belongs to.
  128285. * @param direction The direction the blur should be applied.
  128286. * @param kernel The size of the kernel used to blur.
  128287. * @param options The required width/height ratio to downsize to before computing the render pass.
  128288. * @param camera The camera to apply the render pass to.
  128289. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128290. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128292. * @param engine The engine which the post process will be applied. (default: current engine)
  128293. * @param reusable If the post process can be reused on the same frame. (default: false)
  128294. * @param textureType Type of textures used when performing the post process. (default: 0)
  128295. * @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)
  128296. */
  128297. 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);
  128298. }
  128299. }
  128300. declare module BABYLON {
  128301. /** @hidden */
  128302. export var depthOfFieldMergePixelShader: {
  128303. name: string;
  128304. shader: string;
  128305. };
  128306. }
  128307. declare module BABYLON {
  128308. /**
  128309. * Options to be set when merging outputs from the default pipeline.
  128310. */
  128311. export class DepthOfFieldMergePostProcessOptions {
  128312. /**
  128313. * The original image to merge on top of
  128314. */
  128315. originalFromInput: PostProcess;
  128316. /**
  128317. * Parameters to perform the merge of the depth of field effect
  128318. */
  128319. depthOfField?: {
  128320. circleOfConfusion: PostProcess;
  128321. blurSteps: Array<PostProcess>;
  128322. };
  128323. /**
  128324. * Parameters to perform the merge of bloom effect
  128325. */
  128326. bloom?: {
  128327. blurred: PostProcess;
  128328. weight: number;
  128329. };
  128330. }
  128331. /**
  128332. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128333. */
  128334. export class DepthOfFieldMergePostProcess extends PostProcess {
  128335. private blurSteps;
  128336. /**
  128337. * Creates a new instance of DepthOfFieldMergePostProcess
  128338. * @param name The name of the effect.
  128339. * @param originalFromInput Post process which's input will be used for the merge.
  128340. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128341. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128342. * @param options The required width/height ratio to downsize to before computing the render pass.
  128343. * @param camera The camera to apply the render pass to.
  128344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128345. * @param engine The engine which the post process will be applied. (default: current engine)
  128346. * @param reusable If the post process can be reused on the same frame. (default: false)
  128347. * @param textureType Type of textures used when performing the post process. (default: 0)
  128348. * @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)
  128349. */
  128350. 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);
  128351. /**
  128352. * Updates the effect with the current post process compile time values and recompiles the shader.
  128353. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128354. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128355. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128356. * @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
  128357. * @param onCompiled Called when the shader has been compiled.
  128358. * @param onError Called if there is an error when compiling a shader.
  128359. */
  128360. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128361. }
  128362. }
  128363. declare module BABYLON {
  128364. /**
  128365. * Specifies the level of max blur that should be applied when using the depth of field effect
  128366. */
  128367. export enum DepthOfFieldEffectBlurLevel {
  128368. /**
  128369. * Subtle blur
  128370. */
  128371. Low = 0,
  128372. /**
  128373. * Medium blur
  128374. */
  128375. Medium = 1,
  128376. /**
  128377. * Large blur
  128378. */
  128379. High = 2
  128380. }
  128381. /**
  128382. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128383. */
  128384. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128385. private _circleOfConfusion;
  128386. /**
  128387. * @hidden Internal, blurs from high to low
  128388. */
  128389. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128390. private _depthOfFieldBlurY;
  128391. private _dofMerge;
  128392. /**
  128393. * @hidden Internal post processes in depth of field effect
  128394. */
  128395. _effects: Array<PostProcess>;
  128396. /**
  128397. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128398. */
  128399. focalLength: number;
  128400. /**
  128401. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128402. */
  128403. fStop: number;
  128404. /**
  128405. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128406. */
  128407. focusDistance: number;
  128408. /**
  128409. * 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.
  128410. */
  128411. lensSize: number;
  128412. /**
  128413. * Creates a new instance DepthOfFieldEffect
  128414. * @param scene The scene the effect belongs to.
  128415. * @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.
  128416. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128417. * @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)
  128418. */
  128419. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128420. /**
  128421. * Get the current class name of the current effet
  128422. * @returns "DepthOfFieldEffect"
  128423. */
  128424. getClassName(): string;
  128425. /**
  128426. * 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.
  128427. */
  128428. depthTexture: RenderTargetTexture;
  128429. /**
  128430. * Disposes each of the internal effects for a given camera.
  128431. * @param camera The camera to dispose the effect on.
  128432. */
  128433. disposeEffects(camera: Camera): void;
  128434. /**
  128435. * @hidden Internal
  128436. */
  128437. _updateEffects(): void;
  128438. /**
  128439. * Internal
  128440. * @returns if all the contained post processes are ready.
  128441. * @hidden
  128442. */
  128443. _isReady(): boolean;
  128444. }
  128445. }
  128446. declare module BABYLON {
  128447. /** @hidden */
  128448. export var displayPassPixelShader: {
  128449. name: string;
  128450. shader: string;
  128451. };
  128452. }
  128453. declare module BABYLON {
  128454. /**
  128455. * DisplayPassPostProcess which produces an output the same as it's input
  128456. */
  128457. export class DisplayPassPostProcess extends PostProcess {
  128458. /**
  128459. * Creates the DisplayPassPostProcess
  128460. * @param name The name of the effect.
  128461. * @param options The required width/height ratio to downsize to before computing the render pass.
  128462. * @param camera The camera to apply the render pass to.
  128463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128464. * @param engine The engine which the post process will be applied. (default: current engine)
  128465. * @param reusable If the post process can be reused on the same frame. (default: false)
  128466. */
  128467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128468. }
  128469. }
  128470. declare module BABYLON {
  128471. /** @hidden */
  128472. export var filterPixelShader: {
  128473. name: string;
  128474. shader: string;
  128475. };
  128476. }
  128477. declare module BABYLON {
  128478. /**
  128479. * Applies a kernel filter to the image
  128480. */
  128481. export class FilterPostProcess extends PostProcess {
  128482. /** The matrix to be applied to the image */
  128483. kernelMatrix: Matrix;
  128484. /**
  128485. *
  128486. * @param name The name of the effect.
  128487. * @param kernelMatrix The matrix to be applied to the image
  128488. * @param options The required width/height ratio to downsize to before computing the render pass.
  128489. * @param camera The camera to apply the render pass to.
  128490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128491. * @param engine The engine which the post process will be applied. (default: current engine)
  128492. * @param reusable If the post process can be reused on the same frame. (default: false)
  128493. */
  128494. constructor(name: string,
  128495. /** The matrix to be applied to the image */
  128496. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128497. }
  128498. }
  128499. declare module BABYLON {
  128500. /** @hidden */
  128501. export var fxaaPixelShader: {
  128502. name: string;
  128503. shader: string;
  128504. };
  128505. }
  128506. declare module BABYLON {
  128507. /** @hidden */
  128508. export var fxaaVertexShader: {
  128509. name: string;
  128510. shader: string;
  128511. };
  128512. }
  128513. declare module BABYLON {
  128514. /**
  128515. * Fxaa post process
  128516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128517. */
  128518. export class FxaaPostProcess extends PostProcess {
  128519. /** @hidden */
  128520. texelWidth: number;
  128521. /** @hidden */
  128522. texelHeight: number;
  128523. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128524. private _getDefines;
  128525. }
  128526. }
  128527. declare module BABYLON {
  128528. /** @hidden */
  128529. export var grainPixelShader: {
  128530. name: string;
  128531. shader: string;
  128532. };
  128533. }
  128534. declare module BABYLON {
  128535. /**
  128536. * The GrainPostProcess adds noise to the image at mid luminance levels
  128537. */
  128538. export class GrainPostProcess extends PostProcess {
  128539. /**
  128540. * The intensity of the grain added (default: 30)
  128541. */
  128542. intensity: number;
  128543. /**
  128544. * If the grain should be randomized on every frame
  128545. */
  128546. animated: boolean;
  128547. /**
  128548. * Creates a new instance of @see GrainPostProcess
  128549. * @param name The name of the effect.
  128550. * @param options The required width/height ratio to downsize to before computing the render pass.
  128551. * @param camera The camera to apply the render pass to.
  128552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128553. * @param engine The engine which the post process will be applied. (default: current engine)
  128554. * @param reusable If the post process can be reused on the same frame. (default: false)
  128555. * @param textureType Type of textures used when performing the post process. (default: 0)
  128556. * @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)
  128557. */
  128558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128559. }
  128560. }
  128561. declare module BABYLON {
  128562. /** @hidden */
  128563. export var highlightsPixelShader: {
  128564. name: string;
  128565. shader: string;
  128566. };
  128567. }
  128568. declare module BABYLON {
  128569. /**
  128570. * Extracts highlights from the image
  128571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128572. */
  128573. export class HighlightsPostProcess extends PostProcess {
  128574. /**
  128575. * Extracts highlights from the image
  128576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128577. * @param name The name of the effect.
  128578. * @param options The required width/height ratio to downsize to before computing the render pass.
  128579. * @param camera The camera to apply the render pass to.
  128580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128581. * @param engine The engine which the post process will be applied. (default: current engine)
  128582. * @param reusable If the post process can be reused on the same frame. (default: false)
  128583. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128584. */
  128585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128586. }
  128587. }
  128588. declare module BABYLON {
  128589. /** @hidden */
  128590. export var mrtFragmentDeclaration: {
  128591. name: string;
  128592. shader: string;
  128593. };
  128594. }
  128595. declare module BABYLON {
  128596. /** @hidden */
  128597. export var geometryPixelShader: {
  128598. name: string;
  128599. shader: string;
  128600. };
  128601. }
  128602. declare module BABYLON {
  128603. /** @hidden */
  128604. export var geometryVertexShader: {
  128605. name: string;
  128606. shader: string;
  128607. };
  128608. }
  128609. declare module BABYLON {
  128610. /** @hidden */
  128611. interface ISavedTransformationMatrix {
  128612. world: Matrix;
  128613. viewProjection: Matrix;
  128614. }
  128615. /**
  128616. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128617. */
  128618. export class GeometryBufferRenderer {
  128619. /**
  128620. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128621. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128622. */
  128623. static readonly POSITION_TEXTURE_TYPE: number;
  128624. /**
  128625. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128626. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128627. */
  128628. static readonly VELOCITY_TEXTURE_TYPE: number;
  128629. /**
  128630. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128631. * in order to compute objects velocities when enableVelocity is set to "true"
  128632. * @hidden
  128633. */
  128634. _previousTransformationMatrices: {
  128635. [index: number]: ISavedTransformationMatrix;
  128636. };
  128637. /**
  128638. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128639. * in order to compute objects velocities when enableVelocity is set to "true"
  128640. * @hidden
  128641. */
  128642. _previousBonesTransformationMatrices: {
  128643. [index: number]: Float32Array;
  128644. };
  128645. /**
  128646. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128647. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128648. */
  128649. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128650. private _scene;
  128651. private _multiRenderTarget;
  128652. private _ratio;
  128653. private _enablePosition;
  128654. private _enableVelocity;
  128655. private _positionIndex;
  128656. private _velocityIndex;
  128657. protected _effect: Effect;
  128658. protected _cachedDefines: string;
  128659. /**
  128660. * Set the render list (meshes to be rendered) used in the G buffer.
  128661. */
  128662. renderList: Mesh[];
  128663. /**
  128664. * Gets wether or not G buffer are supported by the running hardware.
  128665. * This requires draw buffer supports
  128666. */
  128667. readonly isSupported: boolean;
  128668. /**
  128669. * Returns the index of the given texture type in the G-Buffer textures array
  128670. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128671. * @returns the index of the given texture type in the G-Buffer textures array
  128672. */
  128673. getTextureIndex(textureType: number): number;
  128674. /**
  128675. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128676. */
  128677. /**
  128678. * Sets whether or not objects positions are enabled for the G buffer.
  128679. */
  128680. enablePosition: boolean;
  128681. /**
  128682. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128683. */
  128684. /**
  128685. * Sets wether or not objects velocities are enabled for the G buffer.
  128686. */
  128687. enableVelocity: boolean;
  128688. /**
  128689. * Gets the scene associated with the buffer.
  128690. */
  128691. readonly scene: Scene;
  128692. /**
  128693. * Gets the ratio used by the buffer during its creation.
  128694. * How big is the buffer related to the main canvas.
  128695. */
  128696. readonly ratio: number;
  128697. /** @hidden */
  128698. static _SceneComponentInitialization: (scene: Scene) => void;
  128699. /**
  128700. * Creates a new G Buffer for the scene
  128701. * @param scene The scene the buffer belongs to
  128702. * @param ratio How big is the buffer related to the main canvas.
  128703. */
  128704. constructor(scene: Scene, ratio?: number);
  128705. /**
  128706. * Checks wether everything is ready to render a submesh to the G buffer.
  128707. * @param subMesh the submesh to check readiness for
  128708. * @param useInstances is the mesh drawn using instance or not
  128709. * @returns true if ready otherwise false
  128710. */
  128711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128712. /**
  128713. * Gets the current underlying G Buffer.
  128714. * @returns the buffer
  128715. */
  128716. getGBuffer(): MultiRenderTarget;
  128717. /**
  128718. * Gets the number of samples used to render the buffer (anti aliasing).
  128719. */
  128720. /**
  128721. * Sets the number of samples used to render the buffer (anti aliasing).
  128722. */
  128723. samples: number;
  128724. /**
  128725. * Disposes the renderer and frees up associated resources.
  128726. */
  128727. dispose(): void;
  128728. protected _createRenderTargets(): void;
  128729. private _copyBonesTransformationMatrices;
  128730. }
  128731. }
  128732. declare module BABYLON {
  128733. interface Scene {
  128734. /** @hidden (Backing field) */
  128735. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128736. /**
  128737. * Gets or Sets the current geometry buffer associated to the scene.
  128738. */
  128739. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128740. /**
  128741. * Enables a GeometryBufferRender and associates it with the scene
  128742. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128743. * @returns the GeometryBufferRenderer
  128744. */
  128745. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128746. /**
  128747. * Disables the GeometryBufferRender associated with the scene
  128748. */
  128749. disableGeometryBufferRenderer(): void;
  128750. }
  128751. /**
  128752. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128753. * in several rendering techniques.
  128754. */
  128755. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128756. /**
  128757. * The component name helpful to identify the component in the list of scene components.
  128758. */
  128759. readonly name: string;
  128760. /**
  128761. * The scene the component belongs to.
  128762. */
  128763. scene: Scene;
  128764. /**
  128765. * Creates a new instance of the component for the given scene
  128766. * @param scene Defines the scene to register the component in
  128767. */
  128768. constructor(scene: Scene);
  128769. /**
  128770. * Registers the component in a given scene
  128771. */
  128772. register(): void;
  128773. /**
  128774. * Rebuilds the elements related to this component in case of
  128775. * context lost for instance.
  128776. */
  128777. rebuild(): void;
  128778. /**
  128779. * Disposes the component and the associated ressources
  128780. */
  128781. dispose(): void;
  128782. private _gatherRenderTargets;
  128783. }
  128784. }
  128785. declare module BABYLON {
  128786. /** @hidden */
  128787. export var motionBlurPixelShader: {
  128788. name: string;
  128789. shader: string;
  128790. };
  128791. }
  128792. declare module BABYLON {
  128793. /**
  128794. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128795. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128796. * As an example, all you have to do is to create the post-process:
  128797. * var mb = new BABYLON.MotionBlurPostProcess(
  128798. * 'mb', // The name of the effect.
  128799. * scene, // The scene containing the objects to blur according to their velocity.
  128800. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128801. * camera // The camera to apply the render pass to.
  128802. * );
  128803. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128804. */
  128805. export class MotionBlurPostProcess extends PostProcess {
  128806. /**
  128807. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128808. */
  128809. motionStrength: number;
  128810. /**
  128811. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128812. */
  128813. /**
  128814. * Sets the number of iterations to be used for motion blur quality
  128815. */
  128816. motionBlurSamples: number;
  128817. private _motionBlurSamples;
  128818. private _geometryBufferRenderer;
  128819. /**
  128820. * Creates a new instance MotionBlurPostProcess
  128821. * @param name The name of the effect.
  128822. * @param scene The scene containing the objects to blur according to their velocity.
  128823. * @param options The required width/height ratio to downsize to before computing the render pass.
  128824. * @param camera The camera to apply the render pass to.
  128825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128826. * @param engine The engine which the post process will be applied. (default: current engine)
  128827. * @param reusable If the post process can be reused on the same frame. (default: false)
  128828. * @param textureType Type of textures used when performing the post process. (default: 0)
  128829. * @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)
  128830. */
  128831. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128832. /**
  128833. * Excludes the given skinned mesh from computing bones velocities.
  128834. * 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.
  128835. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128836. */
  128837. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128838. /**
  128839. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128840. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128841. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128842. */
  128843. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128844. /**
  128845. * Disposes the post process.
  128846. * @param camera The camera to dispose the post process on.
  128847. */
  128848. dispose(camera?: Camera): void;
  128849. }
  128850. }
  128851. declare module BABYLON {
  128852. /** @hidden */
  128853. export var refractionPixelShader: {
  128854. name: string;
  128855. shader: string;
  128856. };
  128857. }
  128858. declare module BABYLON {
  128859. /**
  128860. * Post process which applies a refractin texture
  128861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128862. */
  128863. export class RefractionPostProcess extends PostProcess {
  128864. /** the base color of the refraction (used to taint the rendering) */
  128865. color: Color3;
  128866. /** simulated refraction depth */
  128867. depth: number;
  128868. /** the coefficient of the base color (0 to remove base color tainting) */
  128869. colorLevel: number;
  128870. private _refTexture;
  128871. private _ownRefractionTexture;
  128872. /**
  128873. * Gets or sets the refraction texture
  128874. * Please note that you are responsible for disposing the texture if you set it manually
  128875. */
  128876. refractionTexture: Texture;
  128877. /**
  128878. * Initializes the RefractionPostProcess
  128879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128880. * @param name The name of the effect.
  128881. * @param refractionTextureUrl Url of the refraction texture to use
  128882. * @param color the base color of the refraction (used to taint the rendering)
  128883. * @param depth simulated refraction depth
  128884. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128885. * @param camera The camera to apply the render pass to.
  128886. * @param options The required width/height ratio to downsize to before computing the render pass.
  128887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128888. * @param engine The engine which the post process will be applied. (default: current engine)
  128889. * @param reusable If the post process can be reused on the same frame. (default: false)
  128890. */
  128891. constructor(name: string, refractionTextureUrl: string,
  128892. /** the base color of the refraction (used to taint the rendering) */
  128893. color: Color3,
  128894. /** simulated refraction depth */
  128895. depth: number,
  128896. /** the coefficient of the base color (0 to remove base color tainting) */
  128897. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128898. /**
  128899. * Disposes of the post process
  128900. * @param camera Camera to dispose post process on
  128901. */
  128902. dispose(camera: Camera): void;
  128903. }
  128904. }
  128905. declare module BABYLON {
  128906. /** @hidden */
  128907. export var sharpenPixelShader: {
  128908. name: string;
  128909. shader: string;
  128910. };
  128911. }
  128912. declare module BABYLON {
  128913. /**
  128914. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128915. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128916. */
  128917. export class SharpenPostProcess extends PostProcess {
  128918. /**
  128919. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128920. */
  128921. colorAmount: number;
  128922. /**
  128923. * How much sharpness should be applied (default: 0.3)
  128924. */
  128925. edgeAmount: number;
  128926. /**
  128927. * Creates a new instance ConvolutionPostProcess
  128928. * @param name The name of the effect.
  128929. * @param options The required width/height ratio to downsize to before computing the render pass.
  128930. * @param camera The camera to apply the render pass to.
  128931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128932. * @param engine The engine which the post process will be applied. (default: current engine)
  128933. * @param reusable If the post process can be reused on the same frame. (default: false)
  128934. * @param textureType Type of textures used when performing the post process. (default: 0)
  128935. * @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)
  128936. */
  128937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128938. }
  128939. }
  128940. declare module BABYLON {
  128941. /**
  128942. * PostProcessRenderPipeline
  128943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128944. */
  128945. export class PostProcessRenderPipeline {
  128946. private engine;
  128947. private _renderEffects;
  128948. private _renderEffectsForIsolatedPass;
  128949. /**
  128950. * List of inspectable custom properties (used by the Inspector)
  128951. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  128952. */
  128953. inspectableCustomProperties: IInspectable[];
  128954. /**
  128955. * @hidden
  128956. */
  128957. protected _cameras: Camera[];
  128958. /** @hidden */
  128959. _name: string;
  128960. /**
  128961. * Gets pipeline name
  128962. */
  128963. readonly name: string;
  128964. /** Gets the list of attached cameras */
  128965. readonly cameras: Camera[];
  128966. /**
  128967. * Initializes a PostProcessRenderPipeline
  128968. * @param engine engine to add the pipeline to
  128969. * @param name name of the pipeline
  128970. */
  128971. constructor(engine: Engine, name: string);
  128972. /**
  128973. * Gets the class name
  128974. * @returns "PostProcessRenderPipeline"
  128975. */
  128976. getClassName(): string;
  128977. /**
  128978. * If all the render effects in the pipeline are supported
  128979. */
  128980. readonly isSupported: boolean;
  128981. /**
  128982. * Adds an effect to the pipeline
  128983. * @param renderEffect the effect to add
  128984. */
  128985. addEffect(renderEffect: PostProcessRenderEffect): void;
  128986. /** @hidden */
  128987. _rebuild(): void;
  128988. /** @hidden */
  128989. _enableEffect(renderEffectName: string, cameras: Camera): void;
  128990. /** @hidden */
  128991. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  128992. /** @hidden */
  128993. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128994. /** @hidden */
  128995. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128996. /** @hidden */
  128997. _attachCameras(cameras: Camera, unique: boolean): void;
  128998. /** @hidden */
  128999. _attachCameras(cameras: Camera[], unique: boolean): void;
  129000. /** @hidden */
  129001. _detachCameras(cameras: Camera): void;
  129002. /** @hidden */
  129003. _detachCameras(cameras: Nullable<Camera[]>): void;
  129004. /** @hidden */
  129005. _update(): void;
  129006. /** @hidden */
  129007. _reset(): void;
  129008. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129009. /**
  129010. * Disposes of the pipeline
  129011. */
  129012. dispose(): void;
  129013. }
  129014. }
  129015. declare module BABYLON {
  129016. /**
  129017. * PostProcessRenderPipelineManager class
  129018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129019. */
  129020. export class PostProcessRenderPipelineManager {
  129021. private _renderPipelines;
  129022. /**
  129023. * Initializes a PostProcessRenderPipelineManager
  129024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129025. */
  129026. constructor();
  129027. /**
  129028. * Gets the list of supported render pipelines
  129029. */
  129030. readonly supportedPipelines: PostProcessRenderPipeline[];
  129031. /**
  129032. * Adds a pipeline to the manager
  129033. * @param renderPipeline The pipeline to add
  129034. */
  129035. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129036. /**
  129037. * Attaches a camera to the pipeline
  129038. * @param renderPipelineName The name of the pipeline to attach to
  129039. * @param cameras the camera to attach
  129040. * @param unique if the camera can be attached multiple times to the pipeline
  129041. */
  129042. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129043. /**
  129044. * Detaches a camera from the pipeline
  129045. * @param renderPipelineName The name of the pipeline to detach from
  129046. * @param cameras the camera to detach
  129047. */
  129048. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129049. /**
  129050. * Enables an effect by name on a pipeline
  129051. * @param renderPipelineName the name of the pipeline to enable the effect in
  129052. * @param renderEffectName the name of the effect to enable
  129053. * @param cameras the cameras that the effect should be enabled on
  129054. */
  129055. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129056. /**
  129057. * Disables an effect by name on a pipeline
  129058. * @param renderPipelineName the name of the pipeline to disable the effect in
  129059. * @param renderEffectName the name of the effect to disable
  129060. * @param cameras the cameras that the effect should be disabled on
  129061. */
  129062. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129063. /**
  129064. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129065. */
  129066. update(): void;
  129067. /** @hidden */
  129068. _rebuild(): void;
  129069. /**
  129070. * Disposes of the manager and pipelines
  129071. */
  129072. dispose(): void;
  129073. }
  129074. }
  129075. declare module BABYLON {
  129076. interface Scene {
  129077. /** @hidden (Backing field) */
  129078. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129079. /**
  129080. * Gets the postprocess render pipeline manager
  129081. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129082. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129083. */
  129084. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129085. }
  129086. /**
  129087. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129088. */
  129089. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129090. /**
  129091. * The component name helpfull to identify the component in the list of scene components.
  129092. */
  129093. readonly name: string;
  129094. /**
  129095. * The scene the component belongs to.
  129096. */
  129097. scene: Scene;
  129098. /**
  129099. * Creates a new instance of the component for the given scene
  129100. * @param scene Defines the scene to register the component in
  129101. */
  129102. constructor(scene: Scene);
  129103. /**
  129104. * Registers the component in a given scene
  129105. */
  129106. register(): void;
  129107. /**
  129108. * Rebuilds the elements related to this component in case of
  129109. * context lost for instance.
  129110. */
  129111. rebuild(): void;
  129112. /**
  129113. * Disposes the component and the associated ressources
  129114. */
  129115. dispose(): void;
  129116. private _gatherRenderTargets;
  129117. }
  129118. }
  129119. declare module BABYLON {
  129120. /**
  129121. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129122. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129123. */
  129124. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129125. private _scene;
  129126. private _camerasToBeAttached;
  129127. /**
  129128. * ID of the sharpen post process,
  129129. */
  129130. private readonly SharpenPostProcessId;
  129131. /**
  129132. * @ignore
  129133. * ID of the image processing post process;
  129134. */
  129135. readonly ImageProcessingPostProcessId: string;
  129136. /**
  129137. * @ignore
  129138. * ID of the Fast Approximate Anti-Aliasing post process;
  129139. */
  129140. readonly FxaaPostProcessId: string;
  129141. /**
  129142. * ID of the chromatic aberration post process,
  129143. */
  129144. private readonly ChromaticAberrationPostProcessId;
  129145. /**
  129146. * ID of the grain post process
  129147. */
  129148. private readonly GrainPostProcessId;
  129149. /**
  129150. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129151. */
  129152. sharpen: SharpenPostProcess;
  129153. private _sharpenEffect;
  129154. private bloom;
  129155. /**
  129156. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129157. */
  129158. depthOfField: DepthOfFieldEffect;
  129159. /**
  129160. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129161. */
  129162. fxaa: FxaaPostProcess;
  129163. /**
  129164. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129165. */
  129166. imageProcessing: ImageProcessingPostProcess;
  129167. /**
  129168. * Chromatic aberration post process which will shift rgb colors in the image
  129169. */
  129170. chromaticAberration: ChromaticAberrationPostProcess;
  129171. private _chromaticAberrationEffect;
  129172. /**
  129173. * Grain post process which add noise to the image
  129174. */
  129175. grain: GrainPostProcess;
  129176. private _grainEffect;
  129177. /**
  129178. * Glow post process which adds a glow to emissive areas of the image
  129179. */
  129180. private _glowLayer;
  129181. /**
  129182. * Animations which can be used to tweak settings over a period of time
  129183. */
  129184. animations: Animation[];
  129185. private _imageProcessingConfigurationObserver;
  129186. private _sharpenEnabled;
  129187. private _bloomEnabled;
  129188. private _depthOfFieldEnabled;
  129189. private _depthOfFieldBlurLevel;
  129190. private _fxaaEnabled;
  129191. private _imageProcessingEnabled;
  129192. private _defaultPipelineTextureType;
  129193. private _bloomScale;
  129194. private _chromaticAberrationEnabled;
  129195. private _grainEnabled;
  129196. private _buildAllowed;
  129197. /**
  129198. * Gets active scene
  129199. */
  129200. readonly scene: Scene;
  129201. /**
  129202. * Enable or disable the sharpen process from the pipeline
  129203. */
  129204. sharpenEnabled: boolean;
  129205. private _resizeObserver;
  129206. private _hardwareScaleLevel;
  129207. private _bloomKernel;
  129208. /**
  129209. * Specifies the size of the bloom blur kernel, relative to the final output size
  129210. */
  129211. bloomKernel: number;
  129212. /**
  129213. * Specifies the weight of the bloom in the final rendering
  129214. */
  129215. private _bloomWeight;
  129216. /**
  129217. * Specifies the luma threshold for the area that will be blurred by the bloom
  129218. */
  129219. private _bloomThreshold;
  129220. private _hdr;
  129221. /**
  129222. * The strength of the bloom.
  129223. */
  129224. bloomWeight: number;
  129225. /**
  129226. * The strength of the bloom.
  129227. */
  129228. bloomThreshold: number;
  129229. /**
  129230. * The scale of the bloom, lower value will provide better performance.
  129231. */
  129232. bloomScale: number;
  129233. /**
  129234. * Enable or disable the bloom from the pipeline
  129235. */
  129236. bloomEnabled: boolean;
  129237. private _rebuildBloom;
  129238. /**
  129239. * If the depth of field is enabled.
  129240. */
  129241. depthOfFieldEnabled: boolean;
  129242. /**
  129243. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129244. */
  129245. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129246. /**
  129247. * If the anti aliasing is enabled.
  129248. */
  129249. fxaaEnabled: boolean;
  129250. private _samples;
  129251. /**
  129252. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129253. */
  129254. samples: number;
  129255. /**
  129256. * If image processing is enabled.
  129257. */
  129258. imageProcessingEnabled: boolean;
  129259. /**
  129260. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129261. */
  129262. glowLayerEnabled: boolean;
  129263. /**
  129264. * Gets the glow layer (or null if not defined)
  129265. */
  129266. readonly glowLayer: Nullable<GlowLayer>;
  129267. /**
  129268. * Enable or disable the chromaticAberration process from the pipeline
  129269. */
  129270. chromaticAberrationEnabled: boolean;
  129271. /**
  129272. * Enable or disable the grain process from the pipeline
  129273. */
  129274. grainEnabled: boolean;
  129275. /**
  129276. * @constructor
  129277. * @param name - The rendering pipeline name (default: "")
  129278. * @param hdr - If high dynamic range textures should be used (default: true)
  129279. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129280. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129281. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129282. */
  129283. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129284. /**
  129285. * Get the class name
  129286. * @returns "DefaultRenderingPipeline"
  129287. */
  129288. getClassName(): string;
  129289. /**
  129290. * Force the compilation of the entire pipeline.
  129291. */
  129292. prepare(): void;
  129293. private _hasCleared;
  129294. private _prevPostProcess;
  129295. private _prevPrevPostProcess;
  129296. private _setAutoClearAndTextureSharing;
  129297. private _depthOfFieldSceneObserver;
  129298. private _buildPipeline;
  129299. private _disposePostProcesses;
  129300. /**
  129301. * Adds a camera to the pipeline
  129302. * @param camera the camera to be added
  129303. */
  129304. addCamera(camera: Camera): void;
  129305. /**
  129306. * Removes a camera from the pipeline
  129307. * @param camera the camera to remove
  129308. */
  129309. removeCamera(camera: Camera): void;
  129310. /**
  129311. * Dispose of the pipeline and stop all post processes
  129312. */
  129313. dispose(): void;
  129314. /**
  129315. * Serialize the rendering pipeline (Used when exporting)
  129316. * @returns the serialized object
  129317. */
  129318. serialize(): any;
  129319. /**
  129320. * Parse the serialized pipeline
  129321. * @param source Source pipeline.
  129322. * @param scene The scene to load the pipeline to.
  129323. * @param rootUrl The URL of the serialized pipeline.
  129324. * @returns An instantiated pipeline from the serialized object.
  129325. */
  129326. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129327. }
  129328. }
  129329. declare module BABYLON {
  129330. /** @hidden */
  129331. export var lensHighlightsPixelShader: {
  129332. name: string;
  129333. shader: string;
  129334. };
  129335. }
  129336. declare module BABYLON {
  129337. /** @hidden */
  129338. export var depthOfFieldPixelShader: {
  129339. name: string;
  129340. shader: string;
  129341. };
  129342. }
  129343. declare module BABYLON {
  129344. /**
  129345. * BABYLON.JS Chromatic Aberration GLSL Shader
  129346. * Author: Olivier Guyot
  129347. * Separates very slightly R, G and B colors on the edges of the screen
  129348. * Inspired by Francois Tarlier & Martins Upitis
  129349. */
  129350. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129351. /**
  129352. * @ignore
  129353. * The chromatic aberration PostProcess id in the pipeline
  129354. */
  129355. LensChromaticAberrationEffect: string;
  129356. /**
  129357. * @ignore
  129358. * The highlights enhancing PostProcess id in the pipeline
  129359. */
  129360. HighlightsEnhancingEffect: string;
  129361. /**
  129362. * @ignore
  129363. * The depth-of-field PostProcess id in the pipeline
  129364. */
  129365. LensDepthOfFieldEffect: string;
  129366. private _scene;
  129367. private _depthTexture;
  129368. private _grainTexture;
  129369. private _chromaticAberrationPostProcess;
  129370. private _highlightsPostProcess;
  129371. private _depthOfFieldPostProcess;
  129372. private _edgeBlur;
  129373. private _grainAmount;
  129374. private _chromaticAberration;
  129375. private _distortion;
  129376. private _highlightsGain;
  129377. private _highlightsThreshold;
  129378. private _dofDistance;
  129379. private _dofAperture;
  129380. private _dofDarken;
  129381. private _dofPentagon;
  129382. private _blurNoise;
  129383. /**
  129384. * @constructor
  129385. *
  129386. * Effect parameters are as follow:
  129387. * {
  129388. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129389. * edge_blur: number; // from 0 to x (1 for realism)
  129390. * distortion: number; // from 0 to x (1 for realism)
  129391. * grain_amount: number; // from 0 to 1
  129392. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129393. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129394. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129395. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129396. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129397. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129398. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129399. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129400. * }
  129401. * Note: if an effect parameter is unset, effect is disabled
  129402. *
  129403. * @param name The rendering pipeline name
  129404. * @param parameters - An object containing all parameters (see above)
  129405. * @param scene The scene linked to this pipeline
  129406. * @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)
  129407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129408. */
  129409. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129410. /**
  129411. * Get the class name
  129412. * @returns "LensRenderingPipeline"
  129413. */
  129414. getClassName(): string;
  129415. /**
  129416. * Gets associated scene
  129417. */
  129418. readonly scene: Scene;
  129419. /**
  129420. * Gets or sets the edge blur
  129421. */
  129422. edgeBlur: number;
  129423. /**
  129424. * Gets or sets the grain amount
  129425. */
  129426. grainAmount: number;
  129427. /**
  129428. * Gets or sets the chromatic aberration amount
  129429. */
  129430. chromaticAberration: number;
  129431. /**
  129432. * Gets or sets the depth of field aperture
  129433. */
  129434. dofAperture: number;
  129435. /**
  129436. * Gets or sets the edge distortion
  129437. */
  129438. edgeDistortion: number;
  129439. /**
  129440. * Gets or sets the depth of field distortion
  129441. */
  129442. dofDistortion: number;
  129443. /**
  129444. * Gets or sets the darken out of focus amount
  129445. */
  129446. darkenOutOfFocus: number;
  129447. /**
  129448. * Gets or sets a boolean indicating if blur noise is enabled
  129449. */
  129450. blurNoise: boolean;
  129451. /**
  129452. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129453. */
  129454. pentagonBokeh: boolean;
  129455. /**
  129456. * Gets or sets the highlight grain amount
  129457. */
  129458. highlightsGain: number;
  129459. /**
  129460. * Gets or sets the highlight threshold
  129461. */
  129462. highlightsThreshold: number;
  129463. /**
  129464. * Sets the amount of blur at the edges
  129465. * @param amount blur amount
  129466. */
  129467. setEdgeBlur(amount: number): void;
  129468. /**
  129469. * Sets edge blur to 0
  129470. */
  129471. disableEdgeBlur(): void;
  129472. /**
  129473. * Sets the amout of grain
  129474. * @param amount Amount of grain
  129475. */
  129476. setGrainAmount(amount: number): void;
  129477. /**
  129478. * Set grain amount to 0
  129479. */
  129480. disableGrain(): void;
  129481. /**
  129482. * Sets the chromatic aberration amount
  129483. * @param amount amount of chromatic aberration
  129484. */
  129485. setChromaticAberration(amount: number): void;
  129486. /**
  129487. * Sets chromatic aberration amount to 0
  129488. */
  129489. disableChromaticAberration(): void;
  129490. /**
  129491. * Sets the EdgeDistortion amount
  129492. * @param amount amount of EdgeDistortion
  129493. */
  129494. setEdgeDistortion(amount: number): void;
  129495. /**
  129496. * Sets edge distortion to 0
  129497. */
  129498. disableEdgeDistortion(): void;
  129499. /**
  129500. * Sets the FocusDistance amount
  129501. * @param amount amount of FocusDistance
  129502. */
  129503. setFocusDistance(amount: number): void;
  129504. /**
  129505. * Disables depth of field
  129506. */
  129507. disableDepthOfField(): void;
  129508. /**
  129509. * Sets the Aperture amount
  129510. * @param amount amount of Aperture
  129511. */
  129512. setAperture(amount: number): void;
  129513. /**
  129514. * Sets the DarkenOutOfFocus amount
  129515. * @param amount amount of DarkenOutOfFocus
  129516. */
  129517. setDarkenOutOfFocus(amount: number): void;
  129518. private _pentagonBokehIsEnabled;
  129519. /**
  129520. * Creates a pentagon bokeh effect
  129521. */
  129522. enablePentagonBokeh(): void;
  129523. /**
  129524. * Disables the pentagon bokeh effect
  129525. */
  129526. disablePentagonBokeh(): void;
  129527. /**
  129528. * Enables noise blur
  129529. */
  129530. enableNoiseBlur(): void;
  129531. /**
  129532. * Disables noise blur
  129533. */
  129534. disableNoiseBlur(): void;
  129535. /**
  129536. * Sets the HighlightsGain amount
  129537. * @param amount amount of HighlightsGain
  129538. */
  129539. setHighlightsGain(amount: number): void;
  129540. /**
  129541. * Sets the HighlightsThreshold amount
  129542. * @param amount amount of HighlightsThreshold
  129543. */
  129544. setHighlightsThreshold(amount: number): void;
  129545. /**
  129546. * Disables highlights
  129547. */
  129548. disableHighlights(): void;
  129549. /**
  129550. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129551. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129552. */
  129553. dispose(disableDepthRender?: boolean): void;
  129554. private _createChromaticAberrationPostProcess;
  129555. private _createHighlightsPostProcess;
  129556. private _createDepthOfFieldPostProcess;
  129557. private _createGrainTexture;
  129558. }
  129559. }
  129560. declare module BABYLON {
  129561. /** @hidden */
  129562. export var ssao2PixelShader: {
  129563. name: string;
  129564. shader: string;
  129565. };
  129566. }
  129567. declare module BABYLON {
  129568. /** @hidden */
  129569. export var ssaoCombinePixelShader: {
  129570. name: string;
  129571. shader: string;
  129572. };
  129573. }
  129574. declare module BABYLON {
  129575. /**
  129576. * Render pipeline to produce ssao effect
  129577. */
  129578. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129579. /**
  129580. * @ignore
  129581. * The PassPostProcess id in the pipeline that contains the original scene color
  129582. */
  129583. SSAOOriginalSceneColorEffect: string;
  129584. /**
  129585. * @ignore
  129586. * The SSAO PostProcess id in the pipeline
  129587. */
  129588. SSAORenderEffect: string;
  129589. /**
  129590. * @ignore
  129591. * The horizontal blur PostProcess id in the pipeline
  129592. */
  129593. SSAOBlurHRenderEffect: string;
  129594. /**
  129595. * @ignore
  129596. * The vertical blur PostProcess id in the pipeline
  129597. */
  129598. SSAOBlurVRenderEffect: string;
  129599. /**
  129600. * @ignore
  129601. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129602. */
  129603. SSAOCombineRenderEffect: string;
  129604. /**
  129605. * The output strength of the SSAO post-process. Default value is 1.0.
  129606. */
  129607. totalStrength: number;
  129608. /**
  129609. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129610. */
  129611. maxZ: number;
  129612. /**
  129613. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129614. */
  129615. minZAspect: number;
  129616. private _samples;
  129617. /**
  129618. * Number of samples used for the SSAO calculations. Default value is 8
  129619. */
  129620. samples: number;
  129621. private _textureSamples;
  129622. /**
  129623. * Number of samples to use for antialiasing
  129624. */
  129625. textureSamples: number;
  129626. /**
  129627. * Ratio object used for SSAO ratio and blur ratio
  129628. */
  129629. private _ratio;
  129630. /**
  129631. * Dynamically generated sphere sampler.
  129632. */
  129633. private _sampleSphere;
  129634. /**
  129635. * Blur filter offsets
  129636. */
  129637. private _samplerOffsets;
  129638. private _expensiveBlur;
  129639. /**
  129640. * If bilateral blur should be used
  129641. */
  129642. expensiveBlur: boolean;
  129643. /**
  129644. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129645. */
  129646. radius: number;
  129647. /**
  129648. * The base color of the SSAO post-process
  129649. * The final result is "base + ssao" between [0, 1]
  129650. */
  129651. base: number;
  129652. /**
  129653. * Support test.
  129654. */
  129655. static readonly IsSupported: boolean;
  129656. private _scene;
  129657. private _depthTexture;
  129658. private _normalTexture;
  129659. private _randomTexture;
  129660. private _originalColorPostProcess;
  129661. private _ssaoPostProcess;
  129662. private _blurHPostProcess;
  129663. private _blurVPostProcess;
  129664. private _ssaoCombinePostProcess;
  129665. private _firstUpdate;
  129666. /**
  129667. * Gets active scene
  129668. */
  129669. readonly scene: Scene;
  129670. /**
  129671. * @constructor
  129672. * @param name The rendering pipeline name
  129673. * @param scene The scene linked to this pipeline
  129674. * @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 }
  129675. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129676. */
  129677. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129678. /**
  129679. * Get the class name
  129680. * @returns "SSAO2RenderingPipeline"
  129681. */
  129682. getClassName(): string;
  129683. /**
  129684. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129685. */
  129686. dispose(disableGeometryBufferRenderer?: boolean): void;
  129687. private _createBlurPostProcess;
  129688. /** @hidden */
  129689. _rebuild(): void;
  129690. private _bits;
  129691. private _radicalInverse_VdC;
  129692. private _hammersley;
  129693. private _hemisphereSample_uniform;
  129694. private _generateHemisphere;
  129695. private _createSSAOPostProcess;
  129696. private _createSSAOCombinePostProcess;
  129697. private _createRandomTexture;
  129698. /**
  129699. * Serialize the rendering pipeline (Used when exporting)
  129700. * @returns the serialized object
  129701. */
  129702. serialize(): any;
  129703. /**
  129704. * Parse the serialized pipeline
  129705. * @param source Source pipeline.
  129706. * @param scene The scene to load the pipeline to.
  129707. * @param rootUrl The URL of the serialized pipeline.
  129708. * @returns An instantiated pipeline from the serialized object.
  129709. */
  129710. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129711. }
  129712. }
  129713. declare module BABYLON {
  129714. /** @hidden */
  129715. export var ssaoPixelShader: {
  129716. name: string;
  129717. shader: string;
  129718. };
  129719. }
  129720. declare module BABYLON {
  129721. /**
  129722. * Render pipeline to produce ssao effect
  129723. */
  129724. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129725. /**
  129726. * @ignore
  129727. * The PassPostProcess id in the pipeline that contains the original scene color
  129728. */
  129729. SSAOOriginalSceneColorEffect: string;
  129730. /**
  129731. * @ignore
  129732. * The SSAO PostProcess id in the pipeline
  129733. */
  129734. SSAORenderEffect: string;
  129735. /**
  129736. * @ignore
  129737. * The horizontal blur PostProcess id in the pipeline
  129738. */
  129739. SSAOBlurHRenderEffect: string;
  129740. /**
  129741. * @ignore
  129742. * The vertical blur PostProcess id in the pipeline
  129743. */
  129744. SSAOBlurVRenderEffect: string;
  129745. /**
  129746. * @ignore
  129747. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129748. */
  129749. SSAOCombineRenderEffect: string;
  129750. /**
  129751. * The output strength of the SSAO post-process. Default value is 1.0.
  129752. */
  129753. totalStrength: number;
  129754. /**
  129755. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129756. */
  129757. radius: number;
  129758. /**
  129759. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129760. * Must not be equal to fallOff and superior to fallOff.
  129761. * Default value is 0.0075
  129762. */
  129763. area: number;
  129764. /**
  129765. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129766. * Must not be equal to area and inferior to area.
  129767. * Default value is 0.000001
  129768. */
  129769. fallOff: number;
  129770. /**
  129771. * The base color of the SSAO post-process
  129772. * The final result is "base + ssao" between [0, 1]
  129773. */
  129774. base: number;
  129775. private _scene;
  129776. private _depthTexture;
  129777. private _randomTexture;
  129778. private _originalColorPostProcess;
  129779. private _ssaoPostProcess;
  129780. private _blurHPostProcess;
  129781. private _blurVPostProcess;
  129782. private _ssaoCombinePostProcess;
  129783. private _firstUpdate;
  129784. /**
  129785. * Gets active scene
  129786. */
  129787. readonly scene: Scene;
  129788. /**
  129789. * @constructor
  129790. * @param name - The rendering pipeline name
  129791. * @param scene - The scene linked to this pipeline
  129792. * @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 }
  129793. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129794. */
  129795. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129796. /**
  129797. * Get the class name
  129798. * @returns "SSAORenderingPipeline"
  129799. */
  129800. getClassName(): string;
  129801. /**
  129802. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129803. */
  129804. dispose(disableDepthRender?: boolean): void;
  129805. private _createBlurPostProcess;
  129806. /** @hidden */
  129807. _rebuild(): void;
  129808. private _createSSAOPostProcess;
  129809. private _createSSAOCombinePostProcess;
  129810. private _createRandomTexture;
  129811. }
  129812. }
  129813. declare module BABYLON {
  129814. /** @hidden */
  129815. export var standardPixelShader: {
  129816. name: string;
  129817. shader: string;
  129818. };
  129819. }
  129820. declare module BABYLON {
  129821. /**
  129822. * Standard rendering pipeline
  129823. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129824. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129825. */
  129826. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129827. /**
  129828. * Public members
  129829. */
  129830. /**
  129831. * Post-process which contains the original scene color before the pipeline applies all the effects
  129832. */
  129833. originalPostProcess: Nullable<PostProcess>;
  129834. /**
  129835. * Post-process used to down scale an image x4
  129836. */
  129837. downSampleX4PostProcess: Nullable<PostProcess>;
  129838. /**
  129839. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129840. */
  129841. brightPassPostProcess: Nullable<PostProcess>;
  129842. /**
  129843. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129844. */
  129845. blurHPostProcesses: PostProcess[];
  129846. /**
  129847. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129848. */
  129849. blurVPostProcesses: PostProcess[];
  129850. /**
  129851. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129852. */
  129853. textureAdderPostProcess: Nullable<PostProcess>;
  129854. /**
  129855. * Post-process used to create volumetric lighting effect
  129856. */
  129857. volumetricLightPostProcess: Nullable<PostProcess>;
  129858. /**
  129859. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129860. */
  129861. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129862. /**
  129863. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129864. */
  129865. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129866. /**
  129867. * Post-process used to merge the volumetric light effect and the real scene color
  129868. */
  129869. volumetricLightMergePostProces: Nullable<PostProcess>;
  129870. /**
  129871. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129872. */
  129873. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129874. /**
  129875. * Base post-process used to calculate the average luminance of the final image for HDR
  129876. */
  129877. luminancePostProcess: Nullable<PostProcess>;
  129878. /**
  129879. * Post-processes used to create down sample post-processes in order to get
  129880. * the average luminance of the final image for HDR
  129881. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129882. */
  129883. luminanceDownSamplePostProcesses: PostProcess[];
  129884. /**
  129885. * Post-process used to create a HDR effect (light adaptation)
  129886. */
  129887. hdrPostProcess: Nullable<PostProcess>;
  129888. /**
  129889. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129890. */
  129891. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129892. /**
  129893. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129894. */
  129895. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129896. /**
  129897. * Post-process used to merge the final HDR post-process and the real scene color
  129898. */
  129899. hdrFinalPostProcess: Nullable<PostProcess>;
  129900. /**
  129901. * Post-process used to create a lens flare effect
  129902. */
  129903. lensFlarePostProcess: Nullable<PostProcess>;
  129904. /**
  129905. * Post-process that merges the result of the lens flare post-process and the real scene color
  129906. */
  129907. lensFlareComposePostProcess: Nullable<PostProcess>;
  129908. /**
  129909. * Post-process used to create a motion blur effect
  129910. */
  129911. motionBlurPostProcess: Nullable<PostProcess>;
  129912. /**
  129913. * Post-process used to create a depth of field effect
  129914. */
  129915. depthOfFieldPostProcess: Nullable<PostProcess>;
  129916. /**
  129917. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129918. */
  129919. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129920. /**
  129921. * Represents the brightness threshold in order to configure the illuminated surfaces
  129922. */
  129923. brightThreshold: number;
  129924. /**
  129925. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129926. */
  129927. blurWidth: number;
  129928. /**
  129929. * Sets if the blur for highlighted surfaces must be only horizontal
  129930. */
  129931. horizontalBlur: boolean;
  129932. /**
  129933. * Gets the overall exposure used by the pipeline
  129934. */
  129935. /**
  129936. * Sets the overall exposure used by the pipeline
  129937. */
  129938. exposure: number;
  129939. /**
  129940. * Texture used typically to simulate "dirty" on camera lens
  129941. */
  129942. lensTexture: Nullable<Texture>;
  129943. /**
  129944. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  129945. */
  129946. volumetricLightCoefficient: number;
  129947. /**
  129948. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  129949. */
  129950. volumetricLightPower: number;
  129951. /**
  129952. * Used the set the blur intensity to smooth the volumetric lights
  129953. */
  129954. volumetricLightBlurScale: number;
  129955. /**
  129956. * Light (spot or directional) used to generate the volumetric lights rays
  129957. * The source light must have a shadow generate so the pipeline can get its
  129958. * depth map
  129959. */
  129960. sourceLight: Nullable<SpotLight | DirectionalLight>;
  129961. /**
  129962. * For eye adaptation, represents the minimum luminance the eye can see
  129963. */
  129964. hdrMinimumLuminance: number;
  129965. /**
  129966. * For eye adaptation, represents the decrease luminance speed
  129967. */
  129968. hdrDecreaseRate: number;
  129969. /**
  129970. * For eye adaptation, represents the increase luminance speed
  129971. */
  129972. hdrIncreaseRate: number;
  129973. /**
  129974. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129975. */
  129976. /**
  129977. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129978. */
  129979. hdrAutoExposure: boolean;
  129980. /**
  129981. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  129982. */
  129983. lensColorTexture: Nullable<Texture>;
  129984. /**
  129985. * The overall strengh for the lens flare effect
  129986. */
  129987. lensFlareStrength: number;
  129988. /**
  129989. * Dispersion coefficient for lens flare ghosts
  129990. */
  129991. lensFlareGhostDispersal: number;
  129992. /**
  129993. * Main lens flare halo width
  129994. */
  129995. lensFlareHaloWidth: number;
  129996. /**
  129997. * Based on the lens distortion effect, defines how much the lens flare result
  129998. * is distorted
  129999. */
  130000. lensFlareDistortionStrength: number;
  130001. /**
  130002. * Configures the blur intensity used for for lens flare (halo)
  130003. */
  130004. lensFlareBlurWidth: number;
  130005. /**
  130006. * Lens star texture must be used to simulate rays on the flares and is available
  130007. * in the documentation
  130008. */
  130009. lensStarTexture: Nullable<Texture>;
  130010. /**
  130011. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130012. * flare effect by taking account of the dirt texture
  130013. */
  130014. lensFlareDirtTexture: Nullable<Texture>;
  130015. /**
  130016. * Represents the focal length for the depth of field effect
  130017. */
  130018. depthOfFieldDistance: number;
  130019. /**
  130020. * Represents the blur intensity for the blurred part of the depth of field effect
  130021. */
  130022. depthOfFieldBlurWidth: number;
  130023. /**
  130024. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130025. */
  130026. /**
  130027. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130028. */
  130029. motionStrength: number;
  130030. /**
  130031. * Gets wether or not the motion blur post-process is object based or screen based.
  130032. */
  130033. /**
  130034. * Sets wether or not the motion blur post-process should be object based or screen based
  130035. */
  130036. objectBasedMotionBlur: boolean;
  130037. /**
  130038. * List of animations for the pipeline (IAnimatable implementation)
  130039. */
  130040. animations: Animation[];
  130041. /**
  130042. * Private members
  130043. */
  130044. private _scene;
  130045. private _currentDepthOfFieldSource;
  130046. private _basePostProcess;
  130047. private _fixedExposure;
  130048. private _currentExposure;
  130049. private _hdrAutoExposure;
  130050. private _hdrCurrentLuminance;
  130051. private _motionStrength;
  130052. private _isObjectBasedMotionBlur;
  130053. private _floatTextureType;
  130054. private _camerasToBeAttached;
  130055. private _ratio;
  130056. private _bloomEnabled;
  130057. private _depthOfFieldEnabled;
  130058. private _vlsEnabled;
  130059. private _lensFlareEnabled;
  130060. private _hdrEnabled;
  130061. private _motionBlurEnabled;
  130062. private _fxaaEnabled;
  130063. private _motionBlurSamples;
  130064. private _volumetricLightStepsCount;
  130065. private _samples;
  130066. /**
  130067. * @ignore
  130068. * Specifies if the bloom pipeline is enabled
  130069. */
  130070. BloomEnabled: boolean;
  130071. /**
  130072. * @ignore
  130073. * Specifies if the depth of field pipeline is enabed
  130074. */
  130075. DepthOfFieldEnabled: boolean;
  130076. /**
  130077. * @ignore
  130078. * Specifies if the lens flare pipeline is enabed
  130079. */
  130080. LensFlareEnabled: boolean;
  130081. /**
  130082. * @ignore
  130083. * Specifies if the HDR pipeline is enabled
  130084. */
  130085. HDREnabled: boolean;
  130086. /**
  130087. * @ignore
  130088. * Specifies if the volumetric lights scattering effect is enabled
  130089. */
  130090. VLSEnabled: boolean;
  130091. /**
  130092. * @ignore
  130093. * Specifies if the motion blur effect is enabled
  130094. */
  130095. MotionBlurEnabled: boolean;
  130096. /**
  130097. * Specifies if anti-aliasing is enabled
  130098. */
  130099. fxaaEnabled: boolean;
  130100. /**
  130101. * Specifies the number of steps used to calculate the volumetric lights
  130102. * Typically in interval [50, 200]
  130103. */
  130104. volumetricLightStepsCount: number;
  130105. /**
  130106. * Specifies the number of samples used for the motion blur effect
  130107. * Typically in interval [16, 64]
  130108. */
  130109. motionBlurSamples: number;
  130110. /**
  130111. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130112. */
  130113. samples: number;
  130114. /**
  130115. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130116. * @constructor
  130117. * @param name The rendering pipeline name
  130118. * @param scene The scene linked to this pipeline
  130119. * @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)
  130120. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130121. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130122. */
  130123. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130124. private _buildPipeline;
  130125. private _createDownSampleX4PostProcess;
  130126. private _createBrightPassPostProcess;
  130127. private _createBlurPostProcesses;
  130128. private _createTextureAdderPostProcess;
  130129. private _createVolumetricLightPostProcess;
  130130. private _createLuminancePostProcesses;
  130131. private _createHdrPostProcess;
  130132. private _createLensFlarePostProcess;
  130133. private _createDepthOfFieldPostProcess;
  130134. private _createMotionBlurPostProcess;
  130135. private _getDepthTexture;
  130136. private _disposePostProcesses;
  130137. /**
  130138. * Dispose of the pipeline and stop all post processes
  130139. */
  130140. dispose(): void;
  130141. /**
  130142. * Serialize the rendering pipeline (Used when exporting)
  130143. * @returns the serialized object
  130144. */
  130145. serialize(): any;
  130146. /**
  130147. * Parse the serialized pipeline
  130148. * @param source Source pipeline.
  130149. * @param scene The scene to load the pipeline to.
  130150. * @param rootUrl The URL of the serialized pipeline.
  130151. * @returns An instantiated pipeline from the serialized object.
  130152. */
  130153. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130154. /**
  130155. * Luminance steps
  130156. */
  130157. static LuminanceSteps: number;
  130158. }
  130159. }
  130160. declare module BABYLON {
  130161. /** @hidden */
  130162. export var tonemapPixelShader: {
  130163. name: string;
  130164. shader: string;
  130165. };
  130166. }
  130167. declare module BABYLON {
  130168. /** Defines operator used for tonemapping */
  130169. export enum TonemappingOperator {
  130170. /** Hable */
  130171. Hable = 0,
  130172. /** Reinhard */
  130173. Reinhard = 1,
  130174. /** HejiDawson */
  130175. HejiDawson = 2,
  130176. /** Photographic */
  130177. Photographic = 3
  130178. }
  130179. /**
  130180. * Defines a post process to apply tone mapping
  130181. */
  130182. export class TonemapPostProcess extends PostProcess {
  130183. private _operator;
  130184. /** Defines the required exposure adjustement */
  130185. exposureAdjustment: number;
  130186. /**
  130187. * Creates a new TonemapPostProcess
  130188. * @param name defines the name of the postprocess
  130189. * @param _operator defines the operator to use
  130190. * @param exposureAdjustment defines the required exposure adjustement
  130191. * @param camera defines the camera to use (can be null)
  130192. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130193. * @param engine defines the hosting engine (can be ignore if camera is set)
  130194. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130195. */
  130196. constructor(name: string, _operator: TonemappingOperator,
  130197. /** Defines the required exposure adjustement */
  130198. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130199. }
  130200. }
  130201. declare module BABYLON {
  130202. /** @hidden */
  130203. export var depthVertexShader: {
  130204. name: string;
  130205. shader: string;
  130206. };
  130207. }
  130208. declare module BABYLON {
  130209. /** @hidden */
  130210. export var volumetricLightScatteringPixelShader: {
  130211. name: string;
  130212. shader: string;
  130213. };
  130214. }
  130215. declare module BABYLON {
  130216. /** @hidden */
  130217. export var volumetricLightScatteringPassVertexShader: {
  130218. name: string;
  130219. shader: string;
  130220. };
  130221. }
  130222. declare module BABYLON {
  130223. /** @hidden */
  130224. export var volumetricLightScatteringPassPixelShader: {
  130225. name: string;
  130226. shader: string;
  130227. };
  130228. }
  130229. declare module BABYLON {
  130230. /**
  130231. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130232. */
  130233. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130234. private _volumetricLightScatteringPass;
  130235. private _volumetricLightScatteringRTT;
  130236. private _viewPort;
  130237. private _screenCoordinates;
  130238. private _cachedDefines;
  130239. /**
  130240. * If not undefined, the mesh position is computed from the attached node position
  130241. */
  130242. attachedNode: {
  130243. position: Vector3;
  130244. };
  130245. /**
  130246. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130247. */
  130248. customMeshPosition: Vector3;
  130249. /**
  130250. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130251. */
  130252. useCustomMeshPosition: boolean;
  130253. /**
  130254. * If the post-process should inverse the light scattering direction
  130255. */
  130256. invert: boolean;
  130257. /**
  130258. * The internal mesh used by the post-process
  130259. */
  130260. mesh: Mesh;
  130261. /**
  130262. * @hidden
  130263. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130264. */
  130265. useDiffuseColor: boolean;
  130266. /**
  130267. * Array containing the excluded meshes not rendered in the internal pass
  130268. */
  130269. excludedMeshes: AbstractMesh[];
  130270. /**
  130271. * Controls the overall intensity of the post-process
  130272. */
  130273. exposure: number;
  130274. /**
  130275. * Dissipates each sample's contribution in range [0, 1]
  130276. */
  130277. decay: number;
  130278. /**
  130279. * Controls the overall intensity of each sample
  130280. */
  130281. weight: number;
  130282. /**
  130283. * Controls the density of each sample
  130284. */
  130285. density: number;
  130286. /**
  130287. * @constructor
  130288. * @param name The post-process name
  130289. * @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)
  130290. * @param camera The camera that the post-process will be attached to
  130291. * @param mesh The mesh used to create the light scattering
  130292. * @param samples The post-process quality, default 100
  130293. * @param samplingModeThe post-process filtering mode
  130294. * @param engine The babylon engine
  130295. * @param reusable If the post-process is reusable
  130296. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130297. */
  130298. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130299. /**
  130300. * Returns the string "VolumetricLightScatteringPostProcess"
  130301. * @returns "VolumetricLightScatteringPostProcess"
  130302. */
  130303. getClassName(): string;
  130304. private _isReady;
  130305. /**
  130306. * Sets the new light position for light scattering effect
  130307. * @param position The new custom light position
  130308. */
  130309. setCustomMeshPosition(position: Vector3): void;
  130310. /**
  130311. * Returns the light position for light scattering effect
  130312. * @return Vector3 The custom light position
  130313. */
  130314. getCustomMeshPosition(): Vector3;
  130315. /**
  130316. * Disposes the internal assets and detaches the post-process from the camera
  130317. */
  130318. dispose(camera: Camera): void;
  130319. /**
  130320. * Returns the render target texture used by the post-process
  130321. * @return the render target texture used by the post-process
  130322. */
  130323. getPass(): RenderTargetTexture;
  130324. private _meshExcluded;
  130325. private _createPass;
  130326. private _updateMeshScreenCoordinates;
  130327. /**
  130328. * Creates a default mesh for the Volumeric Light Scattering post-process
  130329. * @param name The mesh name
  130330. * @param scene The scene where to create the mesh
  130331. * @return the default mesh
  130332. */
  130333. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130334. }
  130335. }
  130336. declare module BABYLON {
  130337. interface Scene {
  130338. /** @hidden (Backing field) */
  130339. _boundingBoxRenderer: BoundingBoxRenderer;
  130340. /** @hidden (Backing field) */
  130341. _forceShowBoundingBoxes: boolean;
  130342. /**
  130343. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130344. */
  130345. forceShowBoundingBoxes: boolean;
  130346. /**
  130347. * Gets the bounding box renderer associated with the scene
  130348. * @returns a BoundingBoxRenderer
  130349. */
  130350. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130351. }
  130352. interface AbstractMesh {
  130353. /** @hidden (Backing field) */
  130354. _showBoundingBox: boolean;
  130355. /**
  130356. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130357. */
  130358. showBoundingBox: boolean;
  130359. }
  130360. /**
  130361. * Component responsible of rendering the bounding box of the meshes in a scene.
  130362. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130363. */
  130364. export class BoundingBoxRenderer implements ISceneComponent {
  130365. /**
  130366. * The component name helpfull to identify the component in the list of scene components.
  130367. */
  130368. readonly name: string;
  130369. /**
  130370. * The scene the component belongs to.
  130371. */
  130372. scene: Scene;
  130373. /**
  130374. * Color of the bounding box lines placed in front of an object
  130375. */
  130376. frontColor: Color3;
  130377. /**
  130378. * Color of the bounding box lines placed behind an object
  130379. */
  130380. backColor: Color3;
  130381. /**
  130382. * Defines if the renderer should show the back lines or not
  130383. */
  130384. showBackLines: boolean;
  130385. /**
  130386. * @hidden
  130387. */
  130388. renderList: SmartArray<BoundingBox>;
  130389. private _colorShader;
  130390. private _vertexBuffers;
  130391. private _indexBuffer;
  130392. private _fillIndexBuffer;
  130393. private _fillIndexData;
  130394. /**
  130395. * Instantiates a new bounding box renderer in a scene.
  130396. * @param scene the scene the renderer renders in
  130397. */
  130398. constructor(scene: Scene);
  130399. /**
  130400. * Registers the component in a given scene
  130401. */
  130402. register(): void;
  130403. private _evaluateSubMesh;
  130404. private _activeMesh;
  130405. private _prepareRessources;
  130406. private _createIndexBuffer;
  130407. /**
  130408. * Rebuilds the elements related to this component in case of
  130409. * context lost for instance.
  130410. */
  130411. rebuild(): void;
  130412. /**
  130413. * @hidden
  130414. */
  130415. reset(): void;
  130416. /**
  130417. * Render the bounding boxes of a specific rendering group
  130418. * @param renderingGroupId defines the rendering group to render
  130419. */
  130420. render(renderingGroupId: number): void;
  130421. /**
  130422. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130423. * @param mesh Define the mesh to render the occlusion bounding box for
  130424. */
  130425. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130426. /**
  130427. * Dispose and release the resources attached to this renderer.
  130428. */
  130429. dispose(): void;
  130430. }
  130431. }
  130432. declare module BABYLON {
  130433. /** @hidden */
  130434. export var depthPixelShader: {
  130435. name: string;
  130436. shader: string;
  130437. };
  130438. }
  130439. declare module BABYLON {
  130440. /**
  130441. * This represents a depth renderer in Babylon.
  130442. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130443. */
  130444. export class DepthRenderer {
  130445. private _scene;
  130446. private _depthMap;
  130447. private _effect;
  130448. private readonly _storeNonLinearDepth;
  130449. private readonly _clearColor;
  130450. /** Get if the depth renderer is using packed depth or not */
  130451. readonly isPacked: boolean;
  130452. private _cachedDefines;
  130453. private _camera;
  130454. /**
  130455. * Specifiess that the depth renderer will only be used within
  130456. * the camera it is created for.
  130457. * This can help forcing its rendering during the camera processing.
  130458. */
  130459. useOnlyInActiveCamera: boolean;
  130460. /** @hidden */
  130461. static _SceneComponentInitialization: (scene: Scene) => void;
  130462. /**
  130463. * Instantiates a depth renderer
  130464. * @param scene The scene the renderer belongs to
  130465. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130466. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130467. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130468. */
  130469. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130470. /**
  130471. * Creates the depth rendering effect and checks if the effect is ready.
  130472. * @param subMesh The submesh to be used to render the depth map of
  130473. * @param useInstances If multiple world instances should be used
  130474. * @returns if the depth renderer is ready to render the depth map
  130475. */
  130476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130477. /**
  130478. * Gets the texture which the depth map will be written to.
  130479. * @returns The depth map texture
  130480. */
  130481. getDepthMap(): RenderTargetTexture;
  130482. /**
  130483. * Disposes of the depth renderer.
  130484. */
  130485. dispose(): void;
  130486. }
  130487. }
  130488. declare module BABYLON {
  130489. interface Scene {
  130490. /** @hidden (Backing field) */
  130491. _depthRenderer: {
  130492. [id: string]: DepthRenderer;
  130493. };
  130494. /**
  130495. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130496. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130497. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130498. * @returns the created depth renderer
  130499. */
  130500. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130501. /**
  130502. * Disables a depth renderer for a given camera
  130503. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130504. */
  130505. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130506. }
  130507. /**
  130508. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130509. * in several rendering techniques.
  130510. */
  130511. export class DepthRendererSceneComponent implements ISceneComponent {
  130512. /**
  130513. * The component name helpfull to identify the component in the list of scene components.
  130514. */
  130515. readonly name: string;
  130516. /**
  130517. * The scene the component belongs to.
  130518. */
  130519. scene: Scene;
  130520. /**
  130521. * Creates a new instance of the component for the given scene
  130522. * @param scene Defines the scene to register the component in
  130523. */
  130524. constructor(scene: Scene);
  130525. /**
  130526. * Registers the component in a given scene
  130527. */
  130528. register(): void;
  130529. /**
  130530. * Rebuilds the elements related to this component in case of
  130531. * context lost for instance.
  130532. */
  130533. rebuild(): void;
  130534. /**
  130535. * Disposes the component and the associated ressources
  130536. */
  130537. dispose(): void;
  130538. private _gatherRenderTargets;
  130539. private _gatherActiveCameraRenderTargets;
  130540. }
  130541. }
  130542. declare module BABYLON {
  130543. /** @hidden */
  130544. export var outlinePixelShader: {
  130545. name: string;
  130546. shader: string;
  130547. };
  130548. }
  130549. declare module BABYLON {
  130550. /** @hidden */
  130551. export var outlineVertexShader: {
  130552. name: string;
  130553. shader: string;
  130554. };
  130555. }
  130556. declare module BABYLON {
  130557. interface Scene {
  130558. /** @hidden */
  130559. _outlineRenderer: OutlineRenderer;
  130560. /**
  130561. * Gets the outline renderer associated with the scene
  130562. * @returns a OutlineRenderer
  130563. */
  130564. getOutlineRenderer(): OutlineRenderer;
  130565. }
  130566. interface AbstractMesh {
  130567. /** @hidden (Backing field) */
  130568. _renderOutline: boolean;
  130569. /**
  130570. * Gets or sets a boolean indicating if the outline must be rendered as well
  130571. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130572. */
  130573. renderOutline: boolean;
  130574. /** @hidden (Backing field) */
  130575. _renderOverlay: boolean;
  130576. /**
  130577. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130578. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130579. */
  130580. renderOverlay: boolean;
  130581. }
  130582. /**
  130583. * This class is responsible to draw bothe outline/overlay of meshes.
  130584. * It should not be used directly but through the available method on mesh.
  130585. */
  130586. export class OutlineRenderer implements ISceneComponent {
  130587. /**
  130588. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130589. */
  130590. private static _StencilReference;
  130591. /**
  130592. * The name of the component. Each component must have a unique name.
  130593. */
  130594. name: string;
  130595. /**
  130596. * The scene the component belongs to.
  130597. */
  130598. scene: Scene;
  130599. /**
  130600. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130601. */
  130602. zOffset: number;
  130603. private _engine;
  130604. private _effect;
  130605. private _cachedDefines;
  130606. private _savedDepthWrite;
  130607. /**
  130608. * Instantiates a new outline renderer. (There could be only one per scene).
  130609. * @param scene Defines the scene it belongs to
  130610. */
  130611. constructor(scene: Scene);
  130612. /**
  130613. * Register the component to one instance of a scene.
  130614. */
  130615. register(): void;
  130616. /**
  130617. * Rebuilds the elements related to this component in case of
  130618. * context lost for instance.
  130619. */
  130620. rebuild(): void;
  130621. /**
  130622. * Disposes the component and the associated ressources.
  130623. */
  130624. dispose(): void;
  130625. /**
  130626. * Renders the outline in the canvas.
  130627. * @param subMesh Defines the sumesh to render
  130628. * @param batch Defines the batch of meshes in case of instances
  130629. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130630. */
  130631. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130632. /**
  130633. * Returns whether or not the outline renderer is ready for a given submesh.
  130634. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130635. * @param subMesh Defines the submesh to check readyness for
  130636. * @param useInstances Defines wheter wee are trying to render instances or not
  130637. * @returns true if ready otherwise false
  130638. */
  130639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130640. private _beforeRenderingMesh;
  130641. private _afterRenderingMesh;
  130642. }
  130643. }
  130644. declare module BABYLON {
  130645. /**
  130646. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130647. * @see http://doc.babylonjs.com/babylon101/sprites
  130648. */
  130649. export class SpritePackedManager extends SpriteManager {
  130650. /** defines the packed manager's name */
  130651. name: string;
  130652. /**
  130653. * Creates a new sprite manager from a packed sprite sheet
  130654. * @param name defines the manager's name
  130655. * @param imgUrl defines the sprite sheet url
  130656. * @param capacity defines the maximum allowed number of sprites
  130657. * @param scene defines the hosting scene
  130658. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130659. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130660. * @param samplingMode defines the smapling mode to use with spritesheet
  130661. * @param fromPacked set to true; do not alter
  130662. */
  130663. constructor(
  130664. /** defines the packed manager's name */
  130665. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130666. }
  130667. }
  130668. declare module BABYLON {
  130669. /**
  130670. * Defines the list of states available for a task inside a AssetsManager
  130671. */
  130672. export enum AssetTaskState {
  130673. /**
  130674. * Initialization
  130675. */
  130676. INIT = 0,
  130677. /**
  130678. * Running
  130679. */
  130680. RUNNING = 1,
  130681. /**
  130682. * Done
  130683. */
  130684. DONE = 2,
  130685. /**
  130686. * Error
  130687. */
  130688. ERROR = 3
  130689. }
  130690. /**
  130691. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130692. */
  130693. export abstract class AbstractAssetTask {
  130694. /**
  130695. * Task name
  130696. */ name: string;
  130697. /**
  130698. * Callback called when the task is successful
  130699. */
  130700. onSuccess: (task: any) => void;
  130701. /**
  130702. * Callback called when the task is not successful
  130703. */
  130704. onError: (task: any, message?: string, exception?: any) => void;
  130705. /**
  130706. * Creates a new AssetsManager
  130707. * @param name defines the name of the task
  130708. */
  130709. constructor(
  130710. /**
  130711. * Task name
  130712. */ name: string);
  130713. private _isCompleted;
  130714. private _taskState;
  130715. private _errorObject;
  130716. /**
  130717. * Get if the task is completed
  130718. */
  130719. readonly isCompleted: boolean;
  130720. /**
  130721. * Gets the current state of the task
  130722. */
  130723. readonly taskState: AssetTaskState;
  130724. /**
  130725. * Gets the current error object (if task is in error)
  130726. */
  130727. readonly errorObject: {
  130728. message?: string;
  130729. exception?: any;
  130730. };
  130731. /**
  130732. * Internal only
  130733. * @hidden
  130734. */
  130735. _setErrorObject(message?: string, exception?: any): void;
  130736. /**
  130737. * Execute the current task
  130738. * @param scene defines the scene where you want your assets to be loaded
  130739. * @param onSuccess is a callback called when the task is successfully executed
  130740. * @param onError is a callback called if an error occurs
  130741. */
  130742. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130743. /**
  130744. * Execute the current task
  130745. * @param scene defines the scene where you want your assets to be loaded
  130746. * @param onSuccess is a callback called when the task is successfully executed
  130747. * @param onError is a callback called if an error occurs
  130748. */
  130749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130750. /**
  130751. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130752. * This can be used with failed tasks that have the reason for failure fixed.
  130753. */
  130754. reset(): void;
  130755. private onErrorCallback;
  130756. private onDoneCallback;
  130757. }
  130758. /**
  130759. * Define the interface used by progress events raised during assets loading
  130760. */
  130761. export interface IAssetsProgressEvent {
  130762. /**
  130763. * Defines the number of remaining tasks to process
  130764. */
  130765. remainingCount: number;
  130766. /**
  130767. * Defines the total number of tasks
  130768. */
  130769. totalCount: number;
  130770. /**
  130771. * Defines the task that was just processed
  130772. */
  130773. task: AbstractAssetTask;
  130774. }
  130775. /**
  130776. * Class used to share progress information about assets loading
  130777. */
  130778. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130779. /**
  130780. * Defines the number of remaining tasks to process
  130781. */
  130782. remainingCount: number;
  130783. /**
  130784. * Defines the total number of tasks
  130785. */
  130786. totalCount: number;
  130787. /**
  130788. * Defines the task that was just processed
  130789. */
  130790. task: AbstractAssetTask;
  130791. /**
  130792. * Creates a AssetsProgressEvent
  130793. * @param remainingCount defines the number of remaining tasks to process
  130794. * @param totalCount defines the total number of tasks
  130795. * @param task defines the task that was just processed
  130796. */
  130797. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130798. }
  130799. /**
  130800. * Define a task used by AssetsManager to load meshes
  130801. */
  130802. export class MeshAssetTask extends AbstractAssetTask {
  130803. /**
  130804. * Defines the name of the task
  130805. */
  130806. name: string;
  130807. /**
  130808. * Defines the list of mesh's names you want to load
  130809. */
  130810. meshesNames: any;
  130811. /**
  130812. * Defines the root url to use as a base to load your meshes and associated resources
  130813. */
  130814. rootUrl: string;
  130815. /**
  130816. * Defines the filename of the scene to load from
  130817. */
  130818. sceneFilename: string;
  130819. /**
  130820. * Gets the list of loaded meshes
  130821. */
  130822. loadedMeshes: Array<AbstractMesh>;
  130823. /**
  130824. * Gets the list of loaded particle systems
  130825. */
  130826. loadedParticleSystems: Array<IParticleSystem>;
  130827. /**
  130828. * Gets the list of loaded skeletons
  130829. */
  130830. loadedSkeletons: Array<Skeleton>;
  130831. /**
  130832. * Gets the list of loaded animation groups
  130833. */
  130834. loadedAnimationGroups: Array<AnimationGroup>;
  130835. /**
  130836. * Callback called when the task is successful
  130837. */
  130838. onSuccess: (task: MeshAssetTask) => void;
  130839. /**
  130840. * Callback called when the task is successful
  130841. */
  130842. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130843. /**
  130844. * Creates a new MeshAssetTask
  130845. * @param name defines the name of the task
  130846. * @param meshesNames defines the list of mesh's names you want to load
  130847. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130848. * @param sceneFilename defines the filename of the scene to load from
  130849. */
  130850. constructor(
  130851. /**
  130852. * Defines the name of the task
  130853. */
  130854. name: string,
  130855. /**
  130856. * Defines the list of mesh's names you want to load
  130857. */
  130858. meshesNames: any,
  130859. /**
  130860. * Defines the root url to use as a base to load your meshes and associated resources
  130861. */
  130862. rootUrl: string,
  130863. /**
  130864. * Defines the filename of the scene to load from
  130865. */
  130866. sceneFilename: string);
  130867. /**
  130868. * Execute the current task
  130869. * @param scene defines the scene where you want your assets to be loaded
  130870. * @param onSuccess is a callback called when the task is successfully executed
  130871. * @param onError is a callback called if an error occurs
  130872. */
  130873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130874. }
  130875. /**
  130876. * Define a task used by AssetsManager to load text content
  130877. */
  130878. export class TextFileAssetTask extends AbstractAssetTask {
  130879. /**
  130880. * Defines the name of the task
  130881. */
  130882. name: string;
  130883. /**
  130884. * Defines the location of the file to load
  130885. */
  130886. url: string;
  130887. /**
  130888. * Gets the loaded text string
  130889. */
  130890. text: string;
  130891. /**
  130892. * Callback called when the task is successful
  130893. */
  130894. onSuccess: (task: TextFileAssetTask) => void;
  130895. /**
  130896. * Callback called when the task is successful
  130897. */
  130898. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130899. /**
  130900. * Creates a new TextFileAssetTask object
  130901. * @param name defines the name of the task
  130902. * @param url defines the location of the file to load
  130903. */
  130904. constructor(
  130905. /**
  130906. * Defines the name of the task
  130907. */
  130908. name: string,
  130909. /**
  130910. * Defines the location of the file to load
  130911. */
  130912. url: string);
  130913. /**
  130914. * Execute the current task
  130915. * @param scene defines the scene where you want your assets to be loaded
  130916. * @param onSuccess is a callback called when the task is successfully executed
  130917. * @param onError is a callback called if an error occurs
  130918. */
  130919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130920. }
  130921. /**
  130922. * Define a task used by AssetsManager to load binary data
  130923. */
  130924. export class BinaryFileAssetTask extends AbstractAssetTask {
  130925. /**
  130926. * Defines the name of the task
  130927. */
  130928. name: string;
  130929. /**
  130930. * Defines the location of the file to load
  130931. */
  130932. url: string;
  130933. /**
  130934. * Gets the lodaded data (as an array buffer)
  130935. */
  130936. data: ArrayBuffer;
  130937. /**
  130938. * Callback called when the task is successful
  130939. */
  130940. onSuccess: (task: BinaryFileAssetTask) => void;
  130941. /**
  130942. * Callback called when the task is successful
  130943. */
  130944. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  130945. /**
  130946. * Creates a new BinaryFileAssetTask object
  130947. * @param name defines the name of the new task
  130948. * @param url defines the location of the file to load
  130949. */
  130950. constructor(
  130951. /**
  130952. * Defines the name of the task
  130953. */
  130954. name: string,
  130955. /**
  130956. * Defines the location of the file to load
  130957. */
  130958. url: string);
  130959. /**
  130960. * Execute the current task
  130961. * @param scene defines the scene where you want your assets to be loaded
  130962. * @param onSuccess is a callback called when the task is successfully executed
  130963. * @param onError is a callback called if an error occurs
  130964. */
  130965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130966. }
  130967. /**
  130968. * Define a task used by AssetsManager to load images
  130969. */
  130970. export class ImageAssetTask extends AbstractAssetTask {
  130971. /**
  130972. * Defines the name of the task
  130973. */
  130974. name: string;
  130975. /**
  130976. * Defines the location of the image to load
  130977. */
  130978. url: string;
  130979. /**
  130980. * Gets the loaded images
  130981. */
  130982. image: HTMLImageElement;
  130983. /**
  130984. * Callback called when the task is successful
  130985. */
  130986. onSuccess: (task: ImageAssetTask) => void;
  130987. /**
  130988. * Callback called when the task is successful
  130989. */
  130990. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  130991. /**
  130992. * Creates a new ImageAssetTask
  130993. * @param name defines the name of the task
  130994. * @param url defines the location of the image to load
  130995. */
  130996. constructor(
  130997. /**
  130998. * Defines the name of the task
  130999. */
  131000. name: string,
  131001. /**
  131002. * Defines the location of the image to load
  131003. */
  131004. url: string);
  131005. /**
  131006. * Execute the current task
  131007. * @param scene defines the scene where you want your assets to be loaded
  131008. * @param onSuccess is a callback called when the task is successfully executed
  131009. * @param onError is a callback called if an error occurs
  131010. */
  131011. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131012. }
  131013. /**
  131014. * Defines the interface used by texture loading tasks
  131015. */
  131016. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131017. /**
  131018. * Gets the loaded texture
  131019. */
  131020. texture: TEX;
  131021. }
  131022. /**
  131023. * Define a task used by AssetsManager to load 2D textures
  131024. */
  131025. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131026. /**
  131027. * Defines the name of the task
  131028. */
  131029. name: string;
  131030. /**
  131031. * Defines the location of the file to load
  131032. */
  131033. url: string;
  131034. /**
  131035. * Defines if mipmap should not be generated (default is false)
  131036. */
  131037. noMipmap?: boolean | undefined;
  131038. /**
  131039. * Defines if texture must be inverted on Y axis (default is false)
  131040. */
  131041. invertY?: boolean | undefined;
  131042. /**
  131043. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131044. */
  131045. samplingMode: number;
  131046. /**
  131047. * Gets the loaded texture
  131048. */
  131049. texture: Texture;
  131050. /**
  131051. * Callback called when the task is successful
  131052. */
  131053. onSuccess: (task: TextureAssetTask) => void;
  131054. /**
  131055. * Callback called when the task is successful
  131056. */
  131057. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131058. /**
  131059. * Creates a new TextureAssetTask object
  131060. * @param name defines the name of the task
  131061. * @param url defines the location of the file to load
  131062. * @param noMipmap defines if mipmap should not be generated (default is false)
  131063. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131064. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131065. */
  131066. constructor(
  131067. /**
  131068. * Defines the name of the task
  131069. */
  131070. name: string,
  131071. /**
  131072. * Defines the location of the file to load
  131073. */
  131074. url: string,
  131075. /**
  131076. * Defines if mipmap should not be generated (default is false)
  131077. */
  131078. noMipmap?: boolean | undefined,
  131079. /**
  131080. * Defines if texture must be inverted on Y axis (default is false)
  131081. */
  131082. invertY?: boolean | undefined,
  131083. /**
  131084. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131085. */
  131086. samplingMode?: number);
  131087. /**
  131088. * Execute the current task
  131089. * @param scene defines the scene where you want your assets to be loaded
  131090. * @param onSuccess is a callback called when the task is successfully executed
  131091. * @param onError is a callback called if an error occurs
  131092. */
  131093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131094. }
  131095. /**
  131096. * Define a task used by AssetsManager to load cube textures
  131097. */
  131098. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131099. /**
  131100. * Defines the name of the task
  131101. */
  131102. name: string;
  131103. /**
  131104. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131105. */
  131106. url: string;
  131107. /**
  131108. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131109. */
  131110. extensions?: string[] | undefined;
  131111. /**
  131112. * Defines if mipmaps should not be generated (default is false)
  131113. */
  131114. noMipmap?: boolean | undefined;
  131115. /**
  131116. * Defines the explicit list of files (undefined by default)
  131117. */
  131118. files?: string[] | undefined;
  131119. /**
  131120. * Gets the loaded texture
  131121. */
  131122. texture: CubeTexture;
  131123. /**
  131124. * Callback called when the task is successful
  131125. */
  131126. onSuccess: (task: CubeTextureAssetTask) => void;
  131127. /**
  131128. * Callback called when the task is successful
  131129. */
  131130. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131131. /**
  131132. * Creates a new CubeTextureAssetTask
  131133. * @param name defines the name of the task
  131134. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131135. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131136. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131137. * @param files defines the explicit list of files (undefined by default)
  131138. */
  131139. constructor(
  131140. /**
  131141. * Defines the name of the task
  131142. */
  131143. name: string,
  131144. /**
  131145. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131146. */
  131147. url: string,
  131148. /**
  131149. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131150. */
  131151. extensions?: string[] | undefined,
  131152. /**
  131153. * Defines if mipmaps should not be generated (default is false)
  131154. */
  131155. noMipmap?: boolean | undefined,
  131156. /**
  131157. * Defines the explicit list of files (undefined by default)
  131158. */
  131159. files?: string[] | undefined);
  131160. /**
  131161. * Execute the current task
  131162. * @param scene defines the scene where you want your assets to be loaded
  131163. * @param onSuccess is a callback called when the task is successfully executed
  131164. * @param onError is a callback called if an error occurs
  131165. */
  131166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131167. }
  131168. /**
  131169. * Define a task used by AssetsManager to load HDR cube textures
  131170. */
  131171. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131172. /**
  131173. * Defines the name of the task
  131174. */
  131175. name: string;
  131176. /**
  131177. * Defines the location of the file to load
  131178. */
  131179. url: string;
  131180. /**
  131181. * Defines the desired size (the more it increases the longer the generation will be)
  131182. */
  131183. size: number;
  131184. /**
  131185. * Defines if mipmaps should not be generated (default is false)
  131186. */
  131187. noMipmap: boolean;
  131188. /**
  131189. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131190. */
  131191. generateHarmonics: boolean;
  131192. /**
  131193. * 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)
  131194. */
  131195. gammaSpace: boolean;
  131196. /**
  131197. * Internal Use Only
  131198. */
  131199. reserved: boolean;
  131200. /**
  131201. * Gets the loaded texture
  131202. */
  131203. texture: HDRCubeTexture;
  131204. /**
  131205. * Callback called when the task is successful
  131206. */
  131207. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131208. /**
  131209. * Callback called when the task is successful
  131210. */
  131211. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131212. /**
  131213. * Creates a new HDRCubeTextureAssetTask object
  131214. * @param name defines the name of the task
  131215. * @param url defines the location of the file to load
  131216. * @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.
  131217. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131218. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131219. * @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)
  131220. * @param reserved Internal use only
  131221. */
  131222. constructor(
  131223. /**
  131224. * Defines the name of the task
  131225. */
  131226. name: string,
  131227. /**
  131228. * Defines the location of the file to load
  131229. */
  131230. url: string,
  131231. /**
  131232. * Defines the desired size (the more it increases the longer the generation will be)
  131233. */
  131234. size: number,
  131235. /**
  131236. * Defines if mipmaps should not be generated (default is false)
  131237. */
  131238. noMipmap?: boolean,
  131239. /**
  131240. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131241. */
  131242. generateHarmonics?: boolean,
  131243. /**
  131244. * 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)
  131245. */
  131246. gammaSpace?: boolean,
  131247. /**
  131248. * Internal Use Only
  131249. */
  131250. reserved?: boolean);
  131251. /**
  131252. * Execute the current task
  131253. * @param scene defines the scene where you want your assets to be loaded
  131254. * @param onSuccess is a callback called when the task is successfully executed
  131255. * @param onError is a callback called if an error occurs
  131256. */
  131257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131258. }
  131259. /**
  131260. * Define a task used by AssetsManager to load Equirectangular cube textures
  131261. */
  131262. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131263. /**
  131264. * Defines the name of the task
  131265. */
  131266. name: string;
  131267. /**
  131268. * Defines the location of the file to load
  131269. */
  131270. url: string;
  131271. /**
  131272. * Defines the desired size (the more it increases the longer the generation will be)
  131273. */
  131274. size: number;
  131275. /**
  131276. * Defines if mipmaps should not be generated (default is false)
  131277. */
  131278. noMipmap: boolean;
  131279. /**
  131280. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131281. * but the standard material would require them in Gamma space) (default is true)
  131282. */
  131283. gammaSpace: boolean;
  131284. /**
  131285. * Gets the loaded texture
  131286. */
  131287. texture: EquiRectangularCubeTexture;
  131288. /**
  131289. * Callback called when the task is successful
  131290. */
  131291. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131292. /**
  131293. * Callback called when the task is successful
  131294. */
  131295. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131296. /**
  131297. * Creates a new EquiRectangularCubeTextureAssetTask object
  131298. * @param name defines the name of the task
  131299. * @param url defines the location of the file to load
  131300. * @param size defines the desired size (the more it increases the longer the generation will be)
  131301. * If the size is omitted this implies you are using a preprocessed cubemap.
  131302. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131303. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131304. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131305. * (default is true)
  131306. */
  131307. constructor(
  131308. /**
  131309. * Defines the name of the task
  131310. */
  131311. name: string,
  131312. /**
  131313. * Defines the location of the file to load
  131314. */
  131315. url: string,
  131316. /**
  131317. * Defines the desired size (the more it increases the longer the generation will be)
  131318. */
  131319. size: number,
  131320. /**
  131321. * Defines if mipmaps should not be generated (default is false)
  131322. */
  131323. noMipmap?: boolean,
  131324. /**
  131325. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131326. * but the standard material would require them in Gamma space) (default is true)
  131327. */
  131328. gammaSpace?: boolean);
  131329. /**
  131330. * Execute the current task
  131331. * @param scene defines the scene where you want your assets to be loaded
  131332. * @param onSuccess is a callback called when the task is successfully executed
  131333. * @param onError is a callback called if an error occurs
  131334. */
  131335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131336. }
  131337. /**
  131338. * This class can be used to easily import assets into a scene
  131339. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131340. */
  131341. export class AssetsManager {
  131342. private _scene;
  131343. private _isLoading;
  131344. protected _tasks: AbstractAssetTask[];
  131345. protected _waitingTasksCount: number;
  131346. protected _totalTasksCount: number;
  131347. /**
  131348. * Callback called when all tasks are processed
  131349. */
  131350. onFinish: (tasks: AbstractAssetTask[]) => void;
  131351. /**
  131352. * Callback called when a task is successful
  131353. */
  131354. onTaskSuccess: (task: AbstractAssetTask) => void;
  131355. /**
  131356. * Callback called when a task had an error
  131357. */
  131358. onTaskError: (task: AbstractAssetTask) => void;
  131359. /**
  131360. * Callback called when a task is done (whatever the result is)
  131361. */
  131362. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131363. /**
  131364. * Observable called when all tasks are processed
  131365. */
  131366. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131367. /**
  131368. * Observable called when a task had an error
  131369. */
  131370. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131371. /**
  131372. * Observable called when all tasks were executed
  131373. */
  131374. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131375. /**
  131376. * Observable called when a task is done (whatever the result is)
  131377. */
  131378. onProgressObservable: Observable<IAssetsProgressEvent>;
  131379. /**
  131380. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131382. */
  131383. useDefaultLoadingScreen: boolean;
  131384. /**
  131385. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131386. * when all assets have been downloaded.
  131387. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131388. */
  131389. autoHideLoadingUI: boolean;
  131390. /**
  131391. * Creates a new AssetsManager
  131392. * @param scene defines the scene to work on
  131393. */
  131394. constructor(scene: Scene);
  131395. /**
  131396. * Add a MeshAssetTask to the list of active tasks
  131397. * @param taskName defines the name of the new task
  131398. * @param meshesNames defines the name of meshes to load
  131399. * @param rootUrl defines the root url to use to locate files
  131400. * @param sceneFilename defines the filename of the scene file
  131401. * @returns a new MeshAssetTask object
  131402. */
  131403. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131404. /**
  131405. * Add a TextFileAssetTask to the list of active tasks
  131406. * @param taskName defines the name of the new task
  131407. * @param url defines the url of the file to load
  131408. * @returns a new TextFileAssetTask object
  131409. */
  131410. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131411. /**
  131412. * Add a BinaryFileAssetTask to the list of active tasks
  131413. * @param taskName defines the name of the new task
  131414. * @param url defines the url of the file to load
  131415. * @returns a new BinaryFileAssetTask object
  131416. */
  131417. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131418. /**
  131419. * Add a ImageAssetTask to the list of active tasks
  131420. * @param taskName defines the name of the new task
  131421. * @param url defines the url of the file to load
  131422. * @returns a new ImageAssetTask object
  131423. */
  131424. addImageTask(taskName: string, url: string): ImageAssetTask;
  131425. /**
  131426. * Add a TextureAssetTask to the list of active tasks
  131427. * @param taskName defines the name of the new task
  131428. * @param url defines the url of the file to load
  131429. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131430. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131431. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131432. * @returns a new TextureAssetTask object
  131433. */
  131434. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131435. /**
  131436. * Add a CubeTextureAssetTask to the list of active tasks
  131437. * @param taskName defines the name of the new task
  131438. * @param url defines the url of the file to load
  131439. * @param extensions defines the extension to use to load the cube map (can be null)
  131440. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131441. * @param files defines the list of files to load (can be null)
  131442. * @returns a new CubeTextureAssetTask object
  131443. */
  131444. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131445. /**
  131446. *
  131447. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131448. * @param taskName defines the name of the new task
  131449. * @param url defines the url of the file to load
  131450. * @param size defines the size you want for the cubemap (can be null)
  131451. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131452. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131453. * @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)
  131454. * @param reserved Internal use only
  131455. * @returns a new HDRCubeTextureAssetTask object
  131456. */
  131457. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131458. /**
  131459. *
  131460. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131461. * @param taskName defines the name of the new task
  131462. * @param url defines the url of the file to load
  131463. * @param size defines the size you want for the cubemap (can be null)
  131464. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131465. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131466. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131467. * @returns a new EquiRectangularCubeTextureAssetTask object
  131468. */
  131469. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131470. /**
  131471. * Remove a task from the assets manager.
  131472. * @param task the task to remove
  131473. */
  131474. removeTask(task: AbstractAssetTask): void;
  131475. private _decreaseWaitingTasksCount;
  131476. private _runTask;
  131477. /**
  131478. * Reset the AssetsManager and remove all tasks
  131479. * @return the current instance of the AssetsManager
  131480. */
  131481. reset(): AssetsManager;
  131482. /**
  131483. * Start the loading process
  131484. * @return the current instance of the AssetsManager
  131485. */
  131486. load(): AssetsManager;
  131487. /**
  131488. * Start the loading process as an async operation
  131489. * @return a promise returning the list of failed tasks
  131490. */
  131491. loadAsync(): Promise<void>;
  131492. }
  131493. }
  131494. declare module BABYLON {
  131495. /**
  131496. * Wrapper class for promise with external resolve and reject.
  131497. */
  131498. export class Deferred<T> {
  131499. /**
  131500. * The promise associated with this deferred object.
  131501. */
  131502. readonly promise: Promise<T>;
  131503. private _resolve;
  131504. private _reject;
  131505. /**
  131506. * The resolve method of the promise associated with this deferred object.
  131507. */
  131508. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131509. /**
  131510. * The reject method of the promise associated with this deferred object.
  131511. */
  131512. readonly reject: (reason?: any) => void;
  131513. /**
  131514. * Constructor for this deferred object.
  131515. */
  131516. constructor();
  131517. }
  131518. }
  131519. declare module BABYLON {
  131520. /**
  131521. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131522. */
  131523. export class MeshExploder {
  131524. private _centerMesh;
  131525. private _meshes;
  131526. private _meshesOrigins;
  131527. private _toCenterVectors;
  131528. private _scaledDirection;
  131529. private _newPosition;
  131530. private _centerPosition;
  131531. /**
  131532. * Explodes meshes from a center mesh.
  131533. * @param meshes The meshes to explode.
  131534. * @param centerMesh The mesh to be center of explosion.
  131535. */
  131536. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131537. private _setCenterMesh;
  131538. /**
  131539. * Get class name
  131540. * @returns "MeshExploder"
  131541. */
  131542. getClassName(): string;
  131543. /**
  131544. * "Exploded meshes"
  131545. * @returns Array of meshes with the centerMesh at index 0.
  131546. */
  131547. getMeshes(): Array<Mesh>;
  131548. /**
  131549. * Explodes meshes giving a specific direction
  131550. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131551. */
  131552. explode(direction?: number): void;
  131553. }
  131554. }
  131555. declare module BABYLON {
  131556. /**
  131557. * Class used to help managing file picking and drag'n'drop
  131558. */
  131559. export class FilesInput {
  131560. /**
  131561. * List of files ready to be loaded
  131562. */
  131563. static readonly FilesToLoad: {
  131564. [key: string]: File;
  131565. };
  131566. /**
  131567. * Callback called when a file is processed
  131568. */
  131569. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131570. private _engine;
  131571. private _currentScene;
  131572. private _sceneLoadedCallback;
  131573. private _progressCallback;
  131574. private _additionalRenderLoopLogicCallback;
  131575. private _textureLoadingCallback;
  131576. private _startingProcessingFilesCallback;
  131577. private _onReloadCallback;
  131578. private _errorCallback;
  131579. private _elementToMonitor;
  131580. private _sceneFileToLoad;
  131581. private _filesToLoad;
  131582. /**
  131583. * Creates a new FilesInput
  131584. * @param engine defines the rendering engine
  131585. * @param scene defines the hosting scene
  131586. * @param sceneLoadedCallback callback called when scene is loaded
  131587. * @param progressCallback callback called to track progress
  131588. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131589. * @param textureLoadingCallback callback called when a texture is loading
  131590. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131591. * @param onReloadCallback callback called when a reload is requested
  131592. * @param errorCallback callback call if an error occurs
  131593. */
  131594. 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);
  131595. private _dragEnterHandler;
  131596. private _dragOverHandler;
  131597. private _dropHandler;
  131598. /**
  131599. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131600. * @param elementToMonitor defines the DOM element to track
  131601. */
  131602. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131603. /**
  131604. * Release all associated resources
  131605. */
  131606. dispose(): void;
  131607. private renderFunction;
  131608. private drag;
  131609. private drop;
  131610. private _traverseFolder;
  131611. private _processFiles;
  131612. /**
  131613. * Load files from a drop event
  131614. * @param event defines the drop event to use as source
  131615. */
  131616. loadFiles(event: any): void;
  131617. private _processReload;
  131618. /**
  131619. * Reload the current scene from the loaded files
  131620. */
  131621. reload(): void;
  131622. }
  131623. }
  131624. declare module BABYLON {
  131625. /**
  131626. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131628. */
  131629. export class SceneOptimization {
  131630. /**
  131631. * Defines the priority of this optimization (0 by default which means first in the list)
  131632. */
  131633. priority: number;
  131634. /**
  131635. * Gets a string describing the action executed by the current optimization
  131636. * @returns description string
  131637. */
  131638. getDescription(): string;
  131639. /**
  131640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131641. * @param scene defines the current scene where to apply this optimization
  131642. * @param optimizer defines the current optimizer
  131643. * @returns true if everything that can be done was applied
  131644. */
  131645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131646. /**
  131647. * Creates the SceneOptimization object
  131648. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131649. * @param desc defines the description associated with the optimization
  131650. */
  131651. constructor(
  131652. /**
  131653. * Defines the priority of this optimization (0 by default which means first in the list)
  131654. */
  131655. priority?: number);
  131656. }
  131657. /**
  131658. * Defines an optimization used to reduce the size of render target textures
  131659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131660. */
  131661. export class TextureOptimization extends SceneOptimization {
  131662. /**
  131663. * Defines the priority of this optimization (0 by default which means first in the list)
  131664. */
  131665. priority: number;
  131666. /**
  131667. * 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
  131668. */
  131669. maximumSize: number;
  131670. /**
  131671. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131672. */
  131673. step: number;
  131674. /**
  131675. * Gets a string describing the action executed by the current optimization
  131676. * @returns description string
  131677. */
  131678. getDescription(): string;
  131679. /**
  131680. * Creates the TextureOptimization object
  131681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131682. * @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
  131683. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131684. */
  131685. constructor(
  131686. /**
  131687. * Defines the priority of this optimization (0 by default which means first in the list)
  131688. */
  131689. priority?: number,
  131690. /**
  131691. * 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
  131692. */
  131693. maximumSize?: number,
  131694. /**
  131695. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131696. */
  131697. step?: number);
  131698. /**
  131699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131700. * @param scene defines the current scene where to apply this optimization
  131701. * @param optimizer defines the current optimizer
  131702. * @returns true if everything that can be done was applied
  131703. */
  131704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131705. }
  131706. /**
  131707. * Defines an optimization used to increase or decrease the rendering resolution
  131708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131709. */
  131710. export class HardwareScalingOptimization extends SceneOptimization {
  131711. /**
  131712. * Defines the priority of this optimization (0 by default which means first in the list)
  131713. */
  131714. priority: number;
  131715. /**
  131716. * Defines the maximum scale to use (2 by default)
  131717. */
  131718. maximumScale: number;
  131719. /**
  131720. * Defines the step to use between two passes (0.5 by default)
  131721. */
  131722. step: number;
  131723. private _currentScale;
  131724. private _directionOffset;
  131725. /**
  131726. * Gets a string describing the action executed by the current optimization
  131727. * @return description string
  131728. */
  131729. getDescription(): string;
  131730. /**
  131731. * Creates the HardwareScalingOptimization object
  131732. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131733. * @param maximumScale defines the maximum scale to use (2 by default)
  131734. * @param step defines the step to use between two passes (0.5 by default)
  131735. */
  131736. constructor(
  131737. /**
  131738. * Defines the priority of this optimization (0 by default which means first in the list)
  131739. */
  131740. priority?: number,
  131741. /**
  131742. * Defines the maximum scale to use (2 by default)
  131743. */
  131744. maximumScale?: number,
  131745. /**
  131746. * Defines the step to use between two passes (0.5 by default)
  131747. */
  131748. step?: number);
  131749. /**
  131750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131751. * @param scene defines the current scene where to apply this optimization
  131752. * @param optimizer defines the current optimizer
  131753. * @returns true if everything that can be done was applied
  131754. */
  131755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131756. }
  131757. /**
  131758. * Defines an optimization used to remove shadows
  131759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131760. */
  131761. export class ShadowsOptimization extends SceneOptimization {
  131762. /**
  131763. * Gets a string describing the action executed by the current optimization
  131764. * @return description string
  131765. */
  131766. getDescription(): string;
  131767. /**
  131768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131769. * @param scene defines the current scene where to apply this optimization
  131770. * @param optimizer defines the current optimizer
  131771. * @returns true if everything that can be done was applied
  131772. */
  131773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131774. }
  131775. /**
  131776. * Defines an optimization used to turn post-processes off
  131777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131778. */
  131779. export class PostProcessesOptimization extends SceneOptimization {
  131780. /**
  131781. * Gets a string describing the action executed by the current optimization
  131782. * @return description string
  131783. */
  131784. getDescription(): string;
  131785. /**
  131786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131787. * @param scene defines the current scene where to apply this optimization
  131788. * @param optimizer defines the current optimizer
  131789. * @returns true if everything that can be done was applied
  131790. */
  131791. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131792. }
  131793. /**
  131794. * Defines an optimization used to turn lens flares off
  131795. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131796. */
  131797. export class LensFlaresOptimization extends SceneOptimization {
  131798. /**
  131799. * Gets a string describing the action executed by the current optimization
  131800. * @return description string
  131801. */
  131802. getDescription(): string;
  131803. /**
  131804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131805. * @param scene defines the current scene where to apply this optimization
  131806. * @param optimizer defines the current optimizer
  131807. * @returns true if everything that can be done was applied
  131808. */
  131809. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131810. }
  131811. /**
  131812. * Defines an optimization based on user defined callback.
  131813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131814. */
  131815. export class CustomOptimization extends SceneOptimization {
  131816. /**
  131817. * Callback called to apply the custom optimization.
  131818. */
  131819. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131820. /**
  131821. * Callback called to get custom description
  131822. */
  131823. onGetDescription: () => string;
  131824. /**
  131825. * Gets a string describing the action executed by the current optimization
  131826. * @returns description string
  131827. */
  131828. getDescription(): string;
  131829. /**
  131830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131831. * @param scene defines the current scene where to apply this optimization
  131832. * @param optimizer defines the current optimizer
  131833. * @returns true if everything that can be done was applied
  131834. */
  131835. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131836. }
  131837. /**
  131838. * Defines an optimization used to turn particles off
  131839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131840. */
  131841. export class ParticlesOptimization extends SceneOptimization {
  131842. /**
  131843. * Gets a string describing the action executed by the current optimization
  131844. * @return description string
  131845. */
  131846. getDescription(): string;
  131847. /**
  131848. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131849. * @param scene defines the current scene where to apply this optimization
  131850. * @param optimizer defines the current optimizer
  131851. * @returns true if everything that can be done was applied
  131852. */
  131853. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131854. }
  131855. /**
  131856. * Defines an optimization used to turn render targets off
  131857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131858. */
  131859. export class RenderTargetsOptimization extends SceneOptimization {
  131860. /**
  131861. * Gets a string describing the action executed by the current optimization
  131862. * @return description string
  131863. */
  131864. getDescription(): string;
  131865. /**
  131866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131867. * @param scene defines the current scene where to apply this optimization
  131868. * @param optimizer defines the current optimizer
  131869. * @returns true if everything that can be done was applied
  131870. */
  131871. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131872. }
  131873. /**
  131874. * Defines an optimization used to merge meshes with compatible materials
  131875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131876. */
  131877. export class MergeMeshesOptimization extends SceneOptimization {
  131878. private static _UpdateSelectionTree;
  131879. /**
  131880. * Gets or sets a boolean which defines if optimization octree has to be updated
  131881. */
  131882. /**
  131883. * Gets or sets a boolean which defines if optimization octree has to be updated
  131884. */
  131885. static UpdateSelectionTree: boolean;
  131886. /**
  131887. * Gets a string describing the action executed by the current optimization
  131888. * @return description string
  131889. */
  131890. getDescription(): string;
  131891. private _canBeMerged;
  131892. /**
  131893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131894. * @param scene defines the current scene where to apply this optimization
  131895. * @param optimizer defines the current optimizer
  131896. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131897. * @returns true if everything that can be done was applied
  131898. */
  131899. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131900. }
  131901. /**
  131902. * Defines a list of options used by SceneOptimizer
  131903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131904. */
  131905. export class SceneOptimizerOptions {
  131906. /**
  131907. * Defines the target frame rate to reach (60 by default)
  131908. */
  131909. targetFrameRate: number;
  131910. /**
  131911. * Defines the interval between two checkes (2000ms by default)
  131912. */
  131913. trackerDuration: number;
  131914. /**
  131915. * Gets the list of optimizations to apply
  131916. */
  131917. optimizations: SceneOptimization[];
  131918. /**
  131919. * Creates a new list of options used by SceneOptimizer
  131920. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131921. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131922. */
  131923. constructor(
  131924. /**
  131925. * Defines the target frame rate to reach (60 by default)
  131926. */
  131927. targetFrameRate?: number,
  131928. /**
  131929. * Defines the interval between two checkes (2000ms by default)
  131930. */
  131931. trackerDuration?: number);
  131932. /**
  131933. * Add a new optimization
  131934. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  131935. * @returns the current SceneOptimizerOptions
  131936. */
  131937. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  131938. /**
  131939. * Add a new custom optimization
  131940. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  131941. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  131942. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131943. * @returns the current SceneOptimizerOptions
  131944. */
  131945. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  131946. /**
  131947. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  131948. * @param targetFrameRate defines the target frame rate (60 by default)
  131949. * @returns a SceneOptimizerOptions object
  131950. */
  131951. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131952. /**
  131953. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  131954. * @param targetFrameRate defines the target frame rate (60 by default)
  131955. * @returns a SceneOptimizerOptions object
  131956. */
  131957. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131958. /**
  131959. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  131960. * @param targetFrameRate defines the target frame rate (60 by default)
  131961. * @returns a SceneOptimizerOptions object
  131962. */
  131963. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131964. }
  131965. /**
  131966. * Class used to run optimizations in order to reach a target frame rate
  131967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131968. */
  131969. export class SceneOptimizer implements IDisposable {
  131970. private _isRunning;
  131971. private _options;
  131972. private _scene;
  131973. private _currentPriorityLevel;
  131974. private _targetFrameRate;
  131975. private _trackerDuration;
  131976. private _currentFrameRate;
  131977. private _sceneDisposeObserver;
  131978. private _improvementMode;
  131979. /**
  131980. * Defines an observable called when the optimizer reaches the target frame rate
  131981. */
  131982. onSuccessObservable: Observable<SceneOptimizer>;
  131983. /**
  131984. * Defines an observable called when the optimizer enables an optimization
  131985. */
  131986. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  131987. /**
  131988. * Defines an observable called when the optimizer is not able to reach the target frame rate
  131989. */
  131990. onFailureObservable: Observable<SceneOptimizer>;
  131991. /**
  131992. * Gets a boolean indicating if the optimizer is in improvement mode
  131993. */
  131994. readonly isInImprovementMode: boolean;
  131995. /**
  131996. * Gets the current priority level (0 at start)
  131997. */
  131998. readonly currentPriorityLevel: number;
  131999. /**
  132000. * Gets the current frame rate checked by the SceneOptimizer
  132001. */
  132002. readonly currentFrameRate: number;
  132003. /**
  132004. * Gets or sets the current target frame rate (60 by default)
  132005. */
  132006. /**
  132007. * Gets or sets the current target frame rate (60 by default)
  132008. */
  132009. targetFrameRate: number;
  132010. /**
  132011. * Gets or sets the current interval between two checks (every 2000ms by default)
  132012. */
  132013. /**
  132014. * Gets or sets the current interval between two checks (every 2000ms by default)
  132015. */
  132016. trackerDuration: number;
  132017. /**
  132018. * Gets the list of active optimizations
  132019. */
  132020. readonly optimizations: SceneOptimization[];
  132021. /**
  132022. * Creates a new SceneOptimizer
  132023. * @param scene defines the scene to work on
  132024. * @param options defines the options to use with the SceneOptimizer
  132025. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132026. * @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)
  132027. */
  132028. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132029. /**
  132030. * Stops the current optimizer
  132031. */
  132032. stop(): void;
  132033. /**
  132034. * Reset the optimizer to initial step (current priority level = 0)
  132035. */
  132036. reset(): void;
  132037. /**
  132038. * Start the optimizer. By default it will try to reach a specific framerate
  132039. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132040. */
  132041. start(): void;
  132042. private _checkCurrentState;
  132043. /**
  132044. * Release all resources
  132045. */
  132046. dispose(): void;
  132047. /**
  132048. * Helper function to create a SceneOptimizer with one single line of code
  132049. * @param scene defines the scene to work on
  132050. * @param options defines the options to use with the SceneOptimizer
  132051. * @param onSuccess defines a callback to call on success
  132052. * @param onFailure defines a callback to call on failure
  132053. * @returns the new SceneOptimizer object
  132054. */
  132055. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132056. }
  132057. }
  132058. declare module BABYLON {
  132059. /**
  132060. * Class used to serialize a scene into a string
  132061. */
  132062. export class SceneSerializer {
  132063. /**
  132064. * Clear cache used by a previous serialization
  132065. */
  132066. static ClearCache(): void;
  132067. /**
  132068. * Serialize a scene into a JSON compatible object
  132069. * @param scene defines the scene to serialize
  132070. * @returns a JSON compatible object
  132071. */
  132072. static Serialize(scene: Scene): any;
  132073. /**
  132074. * Serialize a mesh into a JSON compatible object
  132075. * @param toSerialize defines the mesh to serialize
  132076. * @param withParents defines if parents must be serialized as well
  132077. * @param withChildren defines if children must be serialized as well
  132078. * @returns a JSON compatible object
  132079. */
  132080. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132081. }
  132082. }
  132083. declare module BABYLON {
  132084. /**
  132085. * Class used to host texture specific utilities
  132086. */
  132087. export class TextureTools {
  132088. /**
  132089. * Uses the GPU to create a copy texture rescaled at a given size
  132090. * @param texture Texture to copy from
  132091. * @param width defines the desired width
  132092. * @param height defines the desired height
  132093. * @param useBilinearMode defines if bilinear mode has to be used
  132094. * @return the generated texture
  132095. */
  132096. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132097. }
  132098. }
  132099. declare module BABYLON {
  132100. /**
  132101. * This represents the different options available for the video capture.
  132102. */
  132103. export interface VideoRecorderOptions {
  132104. /** Defines the mime type of the video. */
  132105. mimeType: string;
  132106. /** Defines the FPS the video should be recorded at. */
  132107. fps: number;
  132108. /** Defines the chunk size for the recording data. */
  132109. recordChunckSize: number;
  132110. /** The audio tracks to attach to the recording. */
  132111. audioTracks?: MediaStreamTrack[];
  132112. }
  132113. /**
  132114. * This can help with recording videos from BabylonJS.
  132115. * This is based on the available WebRTC functionalities of the browser.
  132116. *
  132117. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132118. */
  132119. export class VideoRecorder {
  132120. private static readonly _defaultOptions;
  132121. /**
  132122. * Returns whether or not the VideoRecorder is available in your browser.
  132123. * @param engine Defines the Babylon Engine.
  132124. * @returns true if supported otherwise false.
  132125. */
  132126. static IsSupported(engine: Engine): boolean;
  132127. private readonly _options;
  132128. private _canvas;
  132129. private _mediaRecorder;
  132130. private _recordedChunks;
  132131. private _fileName;
  132132. private _resolve;
  132133. private _reject;
  132134. /**
  132135. * True when a recording is already in progress.
  132136. */
  132137. readonly isRecording: boolean;
  132138. /**
  132139. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132140. * @param engine Defines the BabylonJS Engine you wish to record.
  132141. * @param options Defines options that can be used to customize the capture.
  132142. */
  132143. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132144. /**
  132145. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132146. */
  132147. stopRecording(): void;
  132148. /**
  132149. * Starts recording the canvas for a max duration specified in parameters.
  132150. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132151. * If null no automatic download will start and you can rely on the promise to get the data back.
  132152. * @param maxDuration Defines the maximum recording time in seconds.
  132153. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132154. * @return A promise callback at the end of the recording with the video data in Blob.
  132155. */
  132156. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132157. /**
  132158. * Releases internal resources used during the recording.
  132159. */
  132160. dispose(): void;
  132161. private _handleDataAvailable;
  132162. private _handleError;
  132163. private _handleStop;
  132164. }
  132165. }
  132166. declare module BABYLON {
  132167. /**
  132168. * Class containing a set of static utilities functions for screenshots
  132169. */
  132170. export class ScreenshotTools {
  132171. /**
  132172. * Captures a screenshot of the current rendering
  132173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132174. * @param engine defines the rendering engine
  132175. * @param camera defines the source camera
  132176. * @param size This parameter can be set to a single number or to an object with the
  132177. * following (optional) properties: precision, width, height. If a single number is passed,
  132178. * it will be used for both width and height. If an object is passed, the screenshot size
  132179. * will be derived from the parameters. The precision property is a multiplier allowing
  132180. * rendering at a higher or lower resolution
  132181. * @param successCallback defines the callback receives a single parameter which contains the
  132182. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132183. * src parameter of an <img> to display it
  132184. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132185. * Check your browser for supported MIME types
  132186. */
  132187. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132188. /**
  132189. * Captures a screenshot of the current rendering
  132190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132191. * @param engine defines the rendering engine
  132192. * @param camera defines the source camera
  132193. * @param size This parameter can be set to a single number or to an object with the
  132194. * following (optional) properties: precision, width, height. If a single number is passed,
  132195. * it will be used for both width and height. If an object is passed, the screenshot size
  132196. * will be derived from the parameters. The precision property is a multiplier allowing
  132197. * rendering at a higher or lower resolution
  132198. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132199. * Check your browser for supported MIME types
  132200. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132201. * to the src parameter of an <img> to display it
  132202. */
  132203. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132204. /**
  132205. * Generates an image screenshot from the specified camera.
  132206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132207. * @param engine The engine to use for rendering
  132208. * @param camera The camera to use for rendering
  132209. * @param size This parameter can be set to a single number or to an object with the
  132210. * following (optional) properties: precision, width, height. If a single number is passed,
  132211. * it will be used for both width and height. If an object is passed, the screenshot size
  132212. * will be derived from the parameters. The precision property is a multiplier allowing
  132213. * rendering at a higher or lower resolution
  132214. * @param successCallback The callback receives a single parameter which contains the
  132215. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132216. * src parameter of an <img> to display it
  132217. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132218. * Check your browser for supported MIME types
  132219. * @param samples Texture samples (default: 1)
  132220. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132221. * @param fileName A name for for the downloaded file.
  132222. */
  132223. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132224. /**
  132225. * Generates an image screenshot from the specified camera.
  132226. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132227. * @param engine The engine to use for rendering
  132228. * @param camera The camera to use for rendering
  132229. * @param size This parameter can be set to a single number or to an object with the
  132230. * following (optional) properties: precision, width, height. If a single number is passed,
  132231. * it will be used for both width and height. If an object is passed, the screenshot size
  132232. * will be derived from the parameters. The precision property is a multiplier allowing
  132233. * rendering at a higher or lower resolution
  132234. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132235. * Check your browser for supported MIME types
  132236. * @param samples Texture samples (default: 1)
  132237. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132238. * @param fileName A name for for the downloaded file.
  132239. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132240. * to the src parameter of an <img> to display it
  132241. */
  132242. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132243. /**
  132244. * Gets height and width for screenshot size
  132245. * @private
  132246. */
  132247. private static _getScreenshotSize;
  132248. }
  132249. }
  132250. declare module BABYLON {
  132251. /**
  132252. * Interface for a data buffer
  132253. */
  132254. export interface IDataBuffer {
  132255. /**
  132256. * Reads bytes from the data buffer.
  132257. * @param byteOffset The byte offset to read
  132258. * @param byteLength The byte length to read
  132259. * @returns A promise that resolves when the bytes are read
  132260. */
  132261. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132262. /**
  132263. * The byte length of the buffer.
  132264. */
  132265. readonly byteLength: number;
  132266. }
  132267. /**
  132268. * Utility class for reading from a data buffer
  132269. */
  132270. export class DataReader {
  132271. /**
  132272. * The data buffer associated with this data reader.
  132273. */
  132274. readonly buffer: IDataBuffer;
  132275. /**
  132276. * The current byte offset from the beginning of the data buffer.
  132277. */
  132278. byteOffset: number;
  132279. private _dataView;
  132280. private _dataByteOffset;
  132281. /**
  132282. * Constructor
  132283. * @param buffer The buffer to read
  132284. */
  132285. constructor(buffer: IDataBuffer);
  132286. /**
  132287. * Loads the given byte length.
  132288. * @param byteLength The byte length to load
  132289. * @returns A promise that resolves when the load is complete
  132290. */
  132291. loadAsync(byteLength: number): Promise<void>;
  132292. /**
  132293. * Read a unsigned 32-bit integer from the currently loaded data range.
  132294. * @returns The 32-bit integer read
  132295. */
  132296. readUint32(): number;
  132297. /**
  132298. * Read a byte array from the currently loaded data range.
  132299. * @param byteLength The byte length to read
  132300. * @returns The byte array read
  132301. */
  132302. readUint8Array(byteLength: number): Uint8Array;
  132303. /**
  132304. * Read a string from the currently loaded data range.
  132305. * @param byteLength The byte length to read
  132306. * @returns The string read
  132307. */
  132308. readString(byteLength: number): string;
  132309. /**
  132310. * Skips the given byte length the currently loaded data range.
  132311. * @param byteLength The byte length to skip
  132312. */
  132313. skipBytes(byteLength: number): void;
  132314. }
  132315. }
  132316. declare module BABYLON {
  132317. /**
  132318. * A cursor which tracks a point on a path
  132319. */
  132320. export class PathCursor {
  132321. private path;
  132322. /**
  132323. * Stores path cursor callbacks for when an onchange event is triggered
  132324. */
  132325. private _onchange;
  132326. /**
  132327. * The value of the path cursor
  132328. */
  132329. value: number;
  132330. /**
  132331. * The animation array of the path cursor
  132332. */
  132333. animations: Animation[];
  132334. /**
  132335. * Initializes the path cursor
  132336. * @param path The path to track
  132337. */
  132338. constructor(path: Path2);
  132339. /**
  132340. * Gets the cursor point on the path
  132341. * @returns A point on the path cursor at the cursor location
  132342. */
  132343. getPoint(): Vector3;
  132344. /**
  132345. * Moves the cursor ahead by the step amount
  132346. * @param step The amount to move the cursor forward
  132347. * @returns This path cursor
  132348. */
  132349. moveAhead(step?: number): PathCursor;
  132350. /**
  132351. * Moves the cursor behind by the step amount
  132352. * @param step The amount to move the cursor back
  132353. * @returns This path cursor
  132354. */
  132355. moveBack(step?: number): PathCursor;
  132356. /**
  132357. * Moves the cursor by the step amount
  132358. * If the step amount is greater than one, an exception is thrown
  132359. * @param step The amount to move the cursor
  132360. * @returns This path cursor
  132361. */
  132362. move(step: number): PathCursor;
  132363. /**
  132364. * Ensures that the value is limited between zero and one
  132365. * @returns This path cursor
  132366. */
  132367. private ensureLimits;
  132368. /**
  132369. * Runs onchange callbacks on change (used by the animation engine)
  132370. * @returns This path cursor
  132371. */
  132372. private raiseOnChange;
  132373. /**
  132374. * Executes a function on change
  132375. * @param f A path cursor onchange callback
  132376. * @returns This path cursor
  132377. */
  132378. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132379. }
  132380. }
  132381. declare module BABYLON {
  132382. /** @hidden */
  132383. export var blurPixelShader: {
  132384. name: string;
  132385. shader: string;
  132386. };
  132387. }
  132388. declare module BABYLON {
  132389. /** @hidden */
  132390. export var pointCloudVertexDeclaration: {
  132391. name: string;
  132392. shader: string;
  132393. };
  132394. }
  132395. // Mixins
  132396. interface Window {
  132397. mozIndexedDB: IDBFactory;
  132398. webkitIndexedDB: IDBFactory;
  132399. msIndexedDB: IDBFactory;
  132400. webkitURL: typeof URL;
  132401. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132402. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132403. WebGLRenderingContext: WebGLRenderingContext;
  132404. MSGesture: MSGesture;
  132405. CANNON: any;
  132406. AudioContext: AudioContext;
  132407. webkitAudioContext: AudioContext;
  132408. PointerEvent: any;
  132409. Math: Math;
  132410. Uint8Array: Uint8ArrayConstructor;
  132411. Float32Array: Float32ArrayConstructor;
  132412. mozURL: typeof URL;
  132413. msURL: typeof URL;
  132414. VRFrameData: any; // WebVR, from specs 1.1
  132415. DracoDecoderModule: any;
  132416. setImmediate(handler: (...args: any[]) => void): number;
  132417. }
  132418. interface HTMLCanvasElement {
  132419. requestPointerLock(): void;
  132420. msRequestPointerLock?(): void;
  132421. mozRequestPointerLock?(): void;
  132422. webkitRequestPointerLock?(): void;
  132423. /** Track wether a record is in progress */
  132424. isRecording: boolean;
  132425. /** Capture Stream method defined by some browsers */
  132426. captureStream(fps?: number): MediaStream;
  132427. }
  132428. interface CanvasRenderingContext2D {
  132429. msImageSmoothingEnabled: boolean;
  132430. }
  132431. interface MouseEvent {
  132432. mozMovementX: number;
  132433. mozMovementY: number;
  132434. webkitMovementX: number;
  132435. webkitMovementY: number;
  132436. msMovementX: number;
  132437. msMovementY: number;
  132438. }
  132439. interface Navigator {
  132440. mozGetVRDevices: (any: any) => any;
  132441. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132442. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132443. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132444. webkitGetGamepads(): Gamepad[];
  132445. msGetGamepads(): Gamepad[];
  132446. webkitGamepads(): Gamepad[];
  132447. }
  132448. interface HTMLVideoElement {
  132449. mozSrcObject: any;
  132450. }
  132451. interface Math {
  132452. fround(x: number): number;
  132453. imul(a: number, b: number): number;
  132454. }
  132455. interface WebGLRenderingContext {
  132456. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132457. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132458. vertexAttribDivisor(index: number, divisor: number): void;
  132459. createVertexArray(): any;
  132460. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132461. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132462. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132463. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132464. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132465. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132466. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132467. // Queries
  132468. createQuery(): WebGLQuery;
  132469. deleteQuery(query: WebGLQuery): void;
  132470. beginQuery(target: number, query: WebGLQuery): void;
  132471. endQuery(target: number): void;
  132472. getQueryParameter(query: WebGLQuery, pname: number): any;
  132473. getQuery(target: number, pname: number): any;
  132474. MAX_SAMPLES: number;
  132475. RGBA8: number;
  132476. READ_FRAMEBUFFER: number;
  132477. DRAW_FRAMEBUFFER: number;
  132478. UNIFORM_BUFFER: number;
  132479. HALF_FLOAT_OES: number;
  132480. RGBA16F: number;
  132481. RGBA32F: number;
  132482. R32F: number;
  132483. RG32F: number;
  132484. RGB32F: number;
  132485. R16F: number;
  132486. RG16F: number;
  132487. RGB16F: number;
  132488. RED: number;
  132489. RG: number;
  132490. R8: number;
  132491. RG8: number;
  132492. UNSIGNED_INT_24_8: number;
  132493. DEPTH24_STENCIL8: number;
  132494. MIN: number;
  132495. MAX: number;
  132496. /* Multiple Render Targets */
  132497. drawBuffers(buffers: number[]): void;
  132498. readBuffer(src: number): void;
  132499. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132500. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132501. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132502. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132503. // Occlusion Query
  132504. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132505. ANY_SAMPLES_PASSED: number;
  132506. QUERY_RESULT_AVAILABLE: number;
  132507. QUERY_RESULT: number;
  132508. }
  132509. interface WebGLProgram {
  132510. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132511. }
  132512. interface EXT_disjoint_timer_query {
  132513. QUERY_COUNTER_BITS_EXT: number;
  132514. TIME_ELAPSED_EXT: number;
  132515. TIMESTAMP_EXT: number;
  132516. GPU_DISJOINT_EXT: number;
  132517. QUERY_RESULT_EXT: number;
  132518. QUERY_RESULT_AVAILABLE_EXT: number;
  132519. queryCounterEXT(query: WebGLQuery, target: number): void;
  132520. createQueryEXT(): WebGLQuery;
  132521. beginQueryEXT(target: number, query: WebGLQuery): void;
  132522. endQueryEXT(target: number): void;
  132523. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132524. deleteQueryEXT(query: WebGLQuery): void;
  132525. }
  132526. interface WebGLUniformLocation {
  132527. _currentState: any;
  132528. }
  132529. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132530. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132531. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132532. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132533. interface WebGLRenderingContext {
  132534. readonly RASTERIZER_DISCARD: number;
  132535. readonly DEPTH_COMPONENT24: number;
  132536. readonly TEXTURE_3D: number;
  132537. readonly TEXTURE_2D_ARRAY: number;
  132538. readonly TEXTURE_COMPARE_FUNC: number;
  132539. readonly TEXTURE_COMPARE_MODE: number;
  132540. readonly COMPARE_REF_TO_TEXTURE: number;
  132541. readonly TEXTURE_WRAP_R: number;
  132542. readonly HALF_FLOAT: number;
  132543. readonly RGB8: number;
  132544. readonly RED_INTEGER: number;
  132545. readonly RG_INTEGER: number;
  132546. readonly RGB_INTEGER: number;
  132547. readonly RGBA_INTEGER: number;
  132548. readonly R8_SNORM: number;
  132549. readonly RG8_SNORM: number;
  132550. readonly RGB8_SNORM: number;
  132551. readonly RGBA8_SNORM: number;
  132552. readonly R8I: number;
  132553. readonly RG8I: number;
  132554. readonly RGB8I: number;
  132555. readonly RGBA8I: number;
  132556. readonly R8UI: number;
  132557. readonly RG8UI: number;
  132558. readonly RGB8UI: number;
  132559. readonly RGBA8UI: number;
  132560. readonly R16I: number;
  132561. readonly RG16I: number;
  132562. readonly RGB16I: number;
  132563. readonly RGBA16I: number;
  132564. readonly R16UI: number;
  132565. readonly RG16UI: number;
  132566. readonly RGB16UI: number;
  132567. readonly RGBA16UI: number;
  132568. readonly R32I: number;
  132569. readonly RG32I: number;
  132570. readonly RGB32I: number;
  132571. readonly RGBA32I: number;
  132572. readonly R32UI: number;
  132573. readonly RG32UI: number;
  132574. readonly RGB32UI: number;
  132575. readonly RGBA32UI: number;
  132576. readonly RGB10_A2UI: number;
  132577. readonly R11F_G11F_B10F: number;
  132578. readonly RGB9_E5: number;
  132579. readonly RGB10_A2: number;
  132580. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132581. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132582. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132583. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132584. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132585. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132586. 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;
  132587. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132588. readonly TRANSFORM_FEEDBACK: number;
  132589. readonly INTERLEAVED_ATTRIBS: number;
  132590. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132591. createTransformFeedback(): WebGLTransformFeedback;
  132592. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132593. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132594. beginTransformFeedback(primitiveMode: number): void;
  132595. endTransformFeedback(): void;
  132596. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132597. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132598. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132599. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132600. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132601. }
  132602. interface ImageBitmap {
  132603. readonly width: number;
  132604. readonly height: number;
  132605. close(): void;
  132606. }
  132607. interface WebGLQuery extends WebGLObject {
  132608. }
  132609. declare var WebGLQuery: {
  132610. prototype: WebGLQuery;
  132611. new(): WebGLQuery;
  132612. };
  132613. interface WebGLSampler extends WebGLObject {
  132614. }
  132615. declare var WebGLSampler: {
  132616. prototype: WebGLSampler;
  132617. new(): WebGLSampler;
  132618. };
  132619. interface WebGLSync extends WebGLObject {
  132620. }
  132621. declare var WebGLSync: {
  132622. prototype: WebGLSync;
  132623. new(): WebGLSync;
  132624. };
  132625. interface WebGLTransformFeedback extends WebGLObject {
  132626. }
  132627. declare var WebGLTransformFeedback: {
  132628. prototype: WebGLTransformFeedback;
  132629. new(): WebGLTransformFeedback;
  132630. };
  132631. interface WebGLVertexArrayObject extends WebGLObject {
  132632. }
  132633. declare var WebGLVertexArrayObject: {
  132634. prototype: WebGLVertexArrayObject;
  132635. new(): WebGLVertexArrayObject;
  132636. };
  132637. // Type definitions for WebVR API
  132638. // Project: https://w3c.github.io/webvr/
  132639. // Definitions by: six a <https://github.com/lostfictions>
  132640. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132641. interface VRDisplay extends EventTarget {
  132642. /**
  132643. * Dictionary of capabilities describing the VRDisplay.
  132644. */
  132645. readonly capabilities: VRDisplayCapabilities;
  132646. /**
  132647. * z-depth defining the far plane of the eye view frustum
  132648. * enables mapping of values in the render target depth
  132649. * attachment to scene coordinates. Initially set to 10000.0.
  132650. */
  132651. depthFar: number;
  132652. /**
  132653. * z-depth defining the near plane of the eye view frustum
  132654. * enables mapping of values in the render target depth
  132655. * attachment to scene coordinates. Initially set to 0.01.
  132656. */
  132657. depthNear: number;
  132658. /**
  132659. * An identifier for this distinct VRDisplay. Used as an
  132660. * association point in the Gamepad API.
  132661. */
  132662. readonly displayId: number;
  132663. /**
  132664. * A display name, a user-readable name identifying it.
  132665. */
  132666. readonly displayName: string;
  132667. readonly isConnected: boolean;
  132668. readonly isPresenting: boolean;
  132669. /**
  132670. * If this VRDisplay supports room-scale experiences, the optional
  132671. * stage attribute contains details on the room-scale parameters.
  132672. */
  132673. readonly stageParameters: VRStageParameters | null;
  132674. /**
  132675. * Passing the value returned by `requestAnimationFrame` to
  132676. * `cancelAnimationFrame` will unregister the callback.
  132677. * @param handle Define the hanle of the request to cancel
  132678. */
  132679. cancelAnimationFrame(handle: number): void;
  132680. /**
  132681. * Stops presenting to the VRDisplay.
  132682. * @returns a promise to know when it stopped
  132683. */
  132684. exitPresent(): Promise<void>;
  132685. /**
  132686. * Return the current VREyeParameters for the given eye.
  132687. * @param whichEye Define the eye we want the parameter for
  132688. * @returns the eye parameters
  132689. */
  132690. getEyeParameters(whichEye: string): VREyeParameters;
  132691. /**
  132692. * Populates the passed VRFrameData with the information required to render
  132693. * the current frame.
  132694. * @param frameData Define the data structure to populate
  132695. * @returns true if ok otherwise false
  132696. */
  132697. getFrameData(frameData: VRFrameData): boolean;
  132698. /**
  132699. * Get the layers currently being presented.
  132700. * @returns the list of VR layers
  132701. */
  132702. getLayers(): VRLayer[];
  132703. /**
  132704. * Return a VRPose containing the future predicted pose of the VRDisplay
  132705. * when the current frame will be presented. The value returned will not
  132706. * change until JavaScript has returned control to the browser.
  132707. *
  132708. * The VRPose will contain the position, orientation, velocity,
  132709. * and acceleration of each of these properties.
  132710. * @returns the pose object
  132711. */
  132712. getPose(): VRPose;
  132713. /**
  132714. * Return the current instantaneous pose of the VRDisplay, with no
  132715. * prediction applied.
  132716. * @returns the current instantaneous pose
  132717. */
  132718. getImmediatePose(): VRPose;
  132719. /**
  132720. * The callback passed to `requestAnimationFrame` will be called
  132721. * any time a new frame should be rendered. When the VRDisplay is
  132722. * presenting the callback will be called at the native refresh
  132723. * rate of the HMD. When not presenting this function acts
  132724. * identically to how window.requestAnimationFrame acts. Content should
  132725. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132726. * asynchronously from other displays and at differing refresh rates.
  132727. * @param callback Define the eaction to run next frame
  132728. * @returns the request handle it
  132729. */
  132730. requestAnimationFrame(callback: FrameRequestCallback): number;
  132731. /**
  132732. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132733. * Repeat calls while already presenting will update the VRLayers being displayed.
  132734. * @param layers Define the list of layer to present
  132735. * @returns a promise to know when the request has been fulfilled
  132736. */
  132737. requestPresent(layers: VRLayer[]): Promise<void>;
  132738. /**
  132739. * Reset the pose for this display, treating its current position and
  132740. * orientation as the "origin/zero" values. VRPose.position,
  132741. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132742. * updated when calling resetPose(). This should be called in only
  132743. * sitting-space experiences.
  132744. */
  132745. resetPose(): void;
  132746. /**
  132747. * The VRLayer provided to the VRDisplay will be captured and presented
  132748. * in the HMD. Calling this function has the same effect on the source
  132749. * canvas as any other operation that uses its source image, and canvases
  132750. * created without preserveDrawingBuffer set to true will be cleared.
  132751. * @param pose Define the pose to submit
  132752. */
  132753. submitFrame(pose?: VRPose): void;
  132754. }
  132755. declare var VRDisplay: {
  132756. prototype: VRDisplay;
  132757. new(): VRDisplay;
  132758. };
  132759. interface VRLayer {
  132760. leftBounds?: number[] | Float32Array | null;
  132761. rightBounds?: number[] | Float32Array | null;
  132762. source?: HTMLCanvasElement | null;
  132763. }
  132764. interface VRDisplayCapabilities {
  132765. readonly canPresent: boolean;
  132766. readonly hasExternalDisplay: boolean;
  132767. readonly hasOrientation: boolean;
  132768. readonly hasPosition: boolean;
  132769. readonly maxLayers: number;
  132770. }
  132771. interface VREyeParameters {
  132772. /** @deprecated */
  132773. readonly fieldOfView: VRFieldOfView;
  132774. readonly offset: Float32Array;
  132775. readonly renderHeight: number;
  132776. readonly renderWidth: number;
  132777. }
  132778. interface VRFieldOfView {
  132779. readonly downDegrees: number;
  132780. readonly leftDegrees: number;
  132781. readonly rightDegrees: number;
  132782. readonly upDegrees: number;
  132783. }
  132784. interface VRFrameData {
  132785. readonly leftProjectionMatrix: Float32Array;
  132786. readonly leftViewMatrix: Float32Array;
  132787. readonly pose: VRPose;
  132788. readonly rightProjectionMatrix: Float32Array;
  132789. readonly rightViewMatrix: Float32Array;
  132790. readonly timestamp: number;
  132791. }
  132792. interface VRPose {
  132793. readonly angularAcceleration: Float32Array | null;
  132794. readonly angularVelocity: Float32Array | null;
  132795. readonly linearAcceleration: Float32Array | null;
  132796. readonly linearVelocity: Float32Array | null;
  132797. readonly orientation: Float32Array | null;
  132798. readonly position: Float32Array | null;
  132799. readonly timestamp: number;
  132800. }
  132801. interface VRStageParameters {
  132802. sittingToStandingTransform?: Float32Array;
  132803. sizeX?: number;
  132804. sizeY?: number;
  132805. }
  132806. interface Navigator {
  132807. getVRDisplays(): Promise<VRDisplay[]>;
  132808. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132809. }
  132810. interface Window {
  132811. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132812. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132813. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132814. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132815. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132816. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132817. }
  132818. interface Gamepad {
  132819. readonly displayId: number;
  132820. }
  132821. type XRSessionMode =
  132822. | "inline"
  132823. | "immersive-vr"
  132824. | "immersive-ar";
  132825. type XRReferenceSpaceType =
  132826. | "viewer"
  132827. | "local"
  132828. | "local-floor"
  132829. | "bounded-floor"
  132830. | "unbounded";
  132831. type XREnvironmentBlendMode =
  132832. | "opaque"
  132833. | "additive"
  132834. | "alpha-blend";
  132835. type XRVisibilityState =
  132836. | "visible"
  132837. | "visible-blurred"
  132838. | "hidden";
  132839. type XRHandedness =
  132840. | "none"
  132841. | "left"
  132842. | "right";
  132843. type XRTargetRayMode =
  132844. | "gaze"
  132845. | "tracked-pointer"
  132846. | "screen";
  132847. type XREye =
  132848. | "none"
  132849. | "left"
  132850. | "right";
  132851. interface XRSpace extends EventTarget {
  132852. }
  132853. interface XRRenderState {
  132854. depthNear?: number;
  132855. depthFar?: number;
  132856. inlineVerticalFieldOfView?: number;
  132857. baseLayer?: XRWebGLLayer;
  132858. }
  132859. interface XRInputSource {
  132860. handedness: XRHandedness;
  132861. targetRayMode: XRTargetRayMode;
  132862. targetRaySpace: XRSpace;
  132863. gripSpace: XRSpace | undefined;
  132864. gamepad: Gamepad | undefined;
  132865. profiles: Array<string>;
  132866. }
  132867. interface XRSession {
  132868. addEventListener: Function;
  132869. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132870. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132871. requestAnimationFrame: Function;
  132872. end(): Promise<void>;
  132873. renderState: XRRenderState;
  132874. inputSources: Array<XRInputSource>;
  132875. }
  132876. interface XRReferenceSpace extends XRSpace {
  132877. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132878. onreset: any;
  132879. }
  132880. interface XRFrame {
  132881. session: XRSession;
  132882. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132883. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132884. }
  132885. interface XRViewerPose extends XRPose {
  132886. views: Array<XRView>;
  132887. }
  132888. interface XRPose {
  132889. transform: XRRigidTransform;
  132890. emulatedPosition: boolean;
  132891. }
  132892. declare var XRWebGLLayer: {
  132893. prototype: XRWebGLLayer;
  132894. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132895. };
  132896. interface XRWebGLLayer {
  132897. framebuffer: WebGLFramebuffer;
  132898. framebufferWidth: number;
  132899. framebufferHeight: number;
  132900. getViewport: Function;
  132901. }
  132902. interface XRRigidTransform {
  132903. position: DOMPointReadOnly;
  132904. orientation: DOMPointReadOnly;
  132905. matrix: Float32Array;
  132906. inverse: XRRigidTransform;
  132907. }
  132908. interface XRView {
  132909. eye: XREye;
  132910. projectionMatrix: Float32Array;
  132911. transform: XRRigidTransform;
  132912. }
  132913. interface XRInputSourceChangeEvent {
  132914. session: XRSession;
  132915. removed: Array<XRInputSource>;
  132916. added: Array<XRInputSource>;
  132917. }